Fix GeometryFixer via buffer-0 noding robustness check #867
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.
This PR fixes the
GeometryFixer
failure cases identified in #852.The
GeometryFixer
problem is that invalid hole rings in the input are fixed viabuffer(0)
, but the output ofbuffer(0)
is still invalid. This causes the union of the "fixed" holes to fail with aTopologyException
.The fundamental problem is that the fast noding used in the buffer algorithm is non-robust, and thus can produce incorrect topology. In the Overlay code this is handled by checking the correctness of the noding after it is created. This is effective, but does impact performance. This is not done in the buffer algorithm, probably because buffer topology building catches noding errors later on. It hasn't caused any known problems - until this issue.
The fix is to check the fast noding done in buffer. If this check fails, the buffer code retries using a more robust noding strategy. To avoid impacting performance for other buffers the noding check is done only for distance=0.
This fix also contains an improvement to
CascadedPolygonUnion
to switch to using OverlayNG as the robustness fallback, since the test case was affected by the buffer changes. (This code path will soon be obsolete anyway, once OverlayNG becomes the default.)NOTE: for some reason GEOS works for these test cases, so this fix does not need to be ported.
Signed-off-by: Martin Davis [email protected]