Fix GeometryCollection::getAll extension method #3295
Merged
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.
Overview
As noted in #3289, we have some problems dealing with
GeometryCollection
s. This bug was traced to the implementation ofgetAll
which used reflection to extract the contained geometries that matched a desired type. This was intended to be used to extract specific types or subclasses (gc.getAll[Geometry]
would be useful). The problem was withgc.getAll(GeometryCollection)
, sinceMultiPoint
,MultiLineString
, andMultiPolygon
are subclasses ofGeometryCollection
. Therefore,gc.getAll[GeometryCollection]
would return allMulti*
andGeometryCollection
entities. This caused problems for methods likereproject
, which would duplicateMulti*
elements.This PR, in it's first form, is for discussion purposes. The simple solution presented here is that
getAll
loses it's subclass semantic. This is the most straightforward, requiring no additional changes, but it does break the semantics, and therefore, technically must wait for GT 4. A more laborious change could be implemented, keeping the subclass semantics of the oldgetAll
implementation, but reimplementingreproject
and other functions that don't correctly differentiate types. This latter solution is more work, but may be preferred to maintain certain functionality.In all cases, GT 3 broke with the model of GT 2 and down where the contents of geometry collections were explicitly compartmentalized, so we might have some latitude for bending semver rules, as this PR's content can be seen as a bugfix of a broken API rather than a change of interface.
Signed-off-by: jpolchlo [email protected]
Checklist
Notes
Closes #3289