Repository navigation
Fix Feature.contains for GeometryCollection geometries - #265
Merged
Merged
Conversation
Feature.contains guarded on PolygonGeometry, so features wrapping a GeometryCollection always returned false; FeatureCollection.contains inherited the bug. Dispatch on the concrete geometry and delegate to GeometryCollection.contains. Make GeometryCollection.contains recurse into nested collections so a collection-wrapping-collection resolves to its polygon members. Add tests for Feature/FeatureCollection containment, nested collections, non-polygon collections, and EPSG:4326/3857/4978/noSRID coverage. Fixes #259
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
Feature.containsandFeatureCollection.containsalways returnedfalsefor features whose geometry is aGeometryCollection, even thoughGeometryCollection.containsitself worked.Root cause
Feature.containsguarded onPolygonGeometry:GeometryCollectiondoes not conform toPolygonGeometry, so the feature was never matched.FeatureCollection.containsdelegates toFeature.containsand inherited the bug.Changes
Feature.containsnow dispatches on the concrete geometry:PolygonGeometry→ itscontains,GeometryCollection→GeometryCollection.contains, otherwisefalse.GeometryCollection.containsnow recurses into nestedGeometryCollections, so a collection-wrapping-collection resolves to its polygon members instead of being silently ignored. This keepsFeatureandGeometryCollectionbehaviour consistent.Tests
Added to
BooleanPointInPolygonTests:featureContainsGeometryCollection— the reproducer fromFeature.containsandFeatureCollection.containsalways returnfalsefor features whose geometry is aGeometryCollection#259 (inside →true, outside →false).featureCollectionContainsGeometryCollection— delegation through a collection.geometryCollectionContainsNestedCollection— nested collections, directly and via aFeature.geometryCollectionContainsNonPolygon— collections containing only Points still returnfalse.featureContainsGeometryCollection3857,...4978,...NoSRID.Full suite: 2579 tests / 192 suites pass. With the fix reverted, the new
featureContainsGeometryCollection*tests fail as expected, so the regression tests are effective.Fixes #259