Skip to content

Conversation

@micycle1
Copy link
Contributor

@micycle1 micycle1 commented Dec 30, 2025

This PR addresses #1113 by adding type parameter declarations to the geom.util extractor utilities, reducing raw List/Collection usage and the need for casts in user code.

Changes:

  • Extractor methods now return typed collections (List<Polygon>, List<LineString>, List<Point>)
  • Added Collection<? super T> overloads so you can collect into either Collection<T> or Collection<Geometry>
  • Consolidated extraction logic into GeometryExtracter (new extractByClass(...) helpers) to avoid duplication
  • Kept extracters implementing GeometryFilter for Geometry#apply(...) compatibility

Compatibility:
Mostly backwards compatible. Note that due to Java generics, returned values like List<LineString> cannot be assigned to List<Geometry>:

List<Geometry> rings = LinearComponentExtracter.getLines(geom); // won't compile
List<? extends Geometry> rings = LinearComponentExtracter.getLines(geom); // works
List<LineString> rings = LinearComponentExtracter.getLines(geom); // works

This PR only touches geom.util. These changes involve more design decisions than straightforward "add generics" fixes (like getNodedSubstrings), so broader changes are left for a future PR.

@micycle1
Copy link
Contributor Author

I've kept untyped methods like List extract(Geometry geom, Class clz, List list) and such in GeometryExtracter, but this could be a time to remove them completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant