locationtech / jts

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

CoverageSimplifier creates invalid coverage for dataset with holes #953

Closed dr-jts closed 1 year ago

dr-jts commented 1 year ago

This example creates an invalid coverage output when simplified with tolerance 100:

GEOMETRYCOLLECTION (POLYGON ((200 300, 300 300, 300 100, 100 100, 100 300, 200 300), (170 220, 170 160, 200 140, 200 250, 170 220), (170 250, 200 250, 200 300, 170 250)), POLYGON ((170 220, 200 250, 200 140, 170 160, 170 220)), POLYGON ((170 250, 200 300, 200 250, 170 250)))

image

The cause is likely something to do with not respecting ring end-nodes in the same way on both inside and outside ring.

mukoki commented 1 year ago

Also coverage including holes often produce simplified coverages with valid geometries but unexpected gaps and overlaps. It is easy to produce such coverage with two holes touching each other (don't know if it is the only case producing overlaps/gaps). Example with the three following polygons and a parameter of 1.0: POLYGON (( 0 0, 0 11, 19 11, 19 0, 0 0 ), ( 4 5, 12 5, 12 6, 10 6, 10 8, 9 8, 9 9, 7 9, 7 8, 6 8, 6 6, 4 6, 4 5 ), ( 12 6, 14 6, 14 9, 13 9, 13 7, 12 7, 12 6 )) POLYGON (( 12 6, 12 5, 4 5, 4 6, 6 6, 6 8, 7 8, 7 9, 9 9, 9 8, 10 8, 10 6, 12 6 )) POLYGON (( 12 6, 12 7, 13 7, 13 9, 14 9, 14 6, 12 6 ))

dr-jts commented 1 year ago

Also coverage including holes often produce simplified coverages with valid geometries but unexpected gaps and overlaps.

Yes, this is the same issue.