You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✨ Extend Annotation to Support Init from WKB (#639)
I have created this as a proof of concept in regard to my comments on #632.
This PR extends the `Annotation` class to enable the creation from either a set of coordinates and a geometry type (int) for direct decoding of the WKB OR from a shapely geometry object. The shapely geometry is created lazily, and vice versa; the coordinates can be accessed lazily if the Annotation was created from a Shapely object.
# Summary
1. Enables init of `Annotation` from WKB bytes instead of from Shapely geometry object. This can shorten the path from database WKB -> Shapely -> Numpy Array for applications which just need the raw coordinates and not any Shapely/geos methods.
1. Move `decode_wkb` to an Annotation static method. This could potentially be optimized with numba or similar in future.
1. Lazily create a Shapely geometry object, WKB, or raw numpy coordinates as needed. This can avoid converting WKB to shapely and then to coordinates and go directly from WKB to coordinates.
1. Add tests.
1. Update code relying on `as_wkb`.
1. Bug fixes including fixing exceptions on appending unsupported geometry and generation of coordinates from WKB in `decode_wkb`.
2. Ensures the coordinates generates from Shapely and from `decode_wkb` via `Annotation.coords` are in the same format as each other. I.e. 1x2 array for points, nx2 array for lines, list of nx2 arrays for poylgons and lists for the multi forms.
---------
Co-authored-by: measty <[email protected]>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
0 commit comments