locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.99k stars 443 forks source link

Fix TopologyPreservingSimplifier to avoid jumping components #1096

Closed dr-jts closed 3 weeks ago

dr-jts commented 3 weeks ago

Fix TaggedLineString to return a valid component point for simplified lines. This fixes some cases which can cause TopologyPreservingSimplifier to "jump" components and create invalid geometry.

No unit tests are provided, since it has not been possible to create a simple reproducer. The issue was seen in test case 19 from https://github.com/libgeos/geos/issues/1180. If this is simplified with tolerance 0.01 a hole is left outside the simplified shell.

network-as-polygon-edgecase-19.txt

image

One thing preventing creating a simple test case is that TopologyPreservingSimplifier is non-deterministic in the order of simplifying rings. It would be good to change to a deterministic evaluation order, to allow simpler test cases and provide consistency across JTS derivatives such as GEOS.