Fix TopologyPreservingSimplifier to avoid jumping components #1096
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.
Fix
TaggedLineString
to return a valid component point for simplified lines. This fixes some cases which can causeTopologyPreservingSimplifier
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 libgeos/geos#1180. If this is simplified with tolerance 0.01 a hole is left outside the simplified shell.
network-as-polygon-edgecase-19.txt
![image](https://private-user-images.githubusercontent.com/3529053/383337941-e6fe27bd-f2ca-4c18-b437-a4db898cebdd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MzU3NTEsIm5iZiI6MTczODkzNTQ1MSwicGF0aCI6Ii8zNTI5MDUzLzM4MzMzNzk0MS1lNmZlMjdiZC1mMmNhLTRjMTgtYjQzNy1hNGRiODk4Y2ViZGQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMTMzNzMxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDk4MmRmNjE4NzgyMjNmZjQ3NGNjMTE3NDA5NTE4ODYxNmRhYzg5ZDc5NDM1OGEyZmU5YWQ4ZjY5YzIzNDM4MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.eLsRj-sVizty1G5EzyxmF-Pa9wtqid3QLwhK3vGEgX0)
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.