ToGo compatibility gaps with Shapely#67
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to close key Shapely-compatibility gaps by expanding module-level helpers, stabilizing multi-geometry typing, and improving multi/collection traversal and boundary behavior.
Changes:
- Added Shapely-style helpers
shape(...)(GeoJSON /__geo_interface__) andbox(...), and exported them via__all__. - Converted
MultiPointandGeometryCollectionfrom factory functions into classes to support stableisinstancechecks; addedGeometry.geomsfor multi/collection child access; extendedGeometry.__getitem__to supportMultiPointindexing. - Updated boundary handling for polygonal multi-geometries and expanded test coverage; bumped project version to
0.4.5.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
togo.pyx |
Adds shape/box, introduces class-based MultiPoint/GeometryCollection, adds .geoms, extends indexing, and adjusts boundary logic for polygonal geometries. |
tests/test_shapely_api.py |
Adds/extends Shapely-parity tests for shape, box, and .geoms. |
tests/test_pickle_boundary_compat.py |
Extends pickle roundtrip coverage to include MultiPoint and GeometryCollection. |
pyproject.toml |
Bumps version from 0.4.4 to 0.4.5. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This MR closes key ToGo compatibility gaps observed in MBP by improving Shapely-parity APIs and multi-geometry behavior.
What changed
shape(...)for GeoJSON dict/string and__geo_interface__inputsbox(minx, miny, maxx, maxy, ccw=True)MultiPointandGeometryCollectionare now classes (not function factories), improvingisinstancebehavior.Geometry.geomsfor multi/collection geometries:MultiPoint,MultiLineString,MultiPolygon, andGeometryCollection.Geometry.__getitem__to supportMultiPointindexing.Polygon.boundarynow includes hole boundaries (returnsMultiLineStringwhen holes exist).MultiPolygon.boundarynow includes boundaries for both exteriors and holes.__all__.Tests
tests/test_shapely_api.pytests/test_pickle_boundary_compat.py125 passedacrosstests/test_shapely_api.pyandtests/test_pickle_boundary_compat.py.Why this matters
These changes reduce downstream shims in MBP by providing missing native API surface and more predictable geometry typing/serialization behavior.