Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Remove ReverseShapePathIterator in favour of JTS' Polygonizer #3825

Merged
merged 5 commits into from
Jan 29, 2023

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Jan 25, 2023

Identify the Bug or Feature request

Implements #3484

Description of the Change

The ReverseShapePathIterator was added to shuffle the results of a PathIterator in such a way that JTS' ShapeReader.read() will correctly recognize holes in the polygons. This PR introduces a more robust approach that uses JTS' Polygonizer which is capable of assembling LineStrings into polygons with holes without us needing to mess with the input first.

During the conversion, we also make sure the coordinates respect the precision model by calling makePrecise() on them before passing them off to the Polygonizer.

Possible Drawbacks

  • It's possible there is a performance drawback to using Polygonizer, especially for maps with lots of complex topology.
  • There could be subtle differences between the Polygonizer and existing behaviour.

Documentation Notes

N/A (internal change)

Release Notes

N/A (internal change)


This change is Reviewable

The new method is `GeometryUtil.toJts()`. This uses to the precision model already present in `GeometryUtil`, while also
using a newly added `GeometryFactory`. That `GeometryFactory` is also exposed so that other components can be sure to
use a matching factory.
In addition to relying on `GeometryUtil.toJts()`, `FogUtil` also uses its `GeometryUtil.getGeometryFactory()` instead of
creating its own.
Copy link
Contributor

@Phergus Phergus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @kwvanderlinde)

@Phergus Phergus merged commit 72c0638 into RPTools:develop Jan 29, 2023
@kwvanderlinde kwvanderlinde deleted the refactor/3484-jts-polygonizer branch January 30, 2023 00:26
@cwisniew cwisniew added the performance A performance or quality of life improvement label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance A performance or quality of life improvement
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

3 participants