Guard against degenerate rings in SimplifyTopology#32
Merged
SimonCropp merged 1 commit intoJul 10, 2026
Conversation
SimplifyRing splits a ring at its junctions and thins each arc as an open line, whose floor is two points. Nothing rechecks the reassembled ring, so a ring whose arcs all fall within the tolerance collapses below a triangle. Two polygons sharing an edge -- the case the function exists to serve -- each split into two arcs between the same junction pair and reassemble to (j0, j1, j0): three positions, zero area, an invalid linear ring under RFC 7946 3.1.6. GeoJson and WKT emit it as-is. Validate the reassembled ring and fall back to the closed-ring simplifier, whose minPoints = 4 floors it at MinimalRing exactly as the plain Simplify path already does. Both halves of the check are load-bearing: a self-touching ring can reach four positions with only two distinct vertices, which a position-count check alone waves through. The guard sits above the method switch, so it covers Douglas-Peucker and Visvalingam alike.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SimplifyRing splits a ring at its junctions and thins each arc as an open line, whose floor is two points. Nothing rechecks the reassembled ring, so a ring whose arcs all fall within the tolerance collapses below a triangle. Two polygons sharing an edge -- the case the function exists to serve -- each split into two arcs between the same junction pair and reassemble to (j0, j1, j0): three positions, zero area, an invalid linear ring under RFC 7946 3.1.6. GeoJson and WKT emit it as-is.
Validate the reassembled ring and fall back to the closed-ring simplifier, whose minPoints = 4 floors it at MinimalRing exactly as the plain Simplify path already does. Both halves of the check are load-bearing: a self-touching ring can reach four positions with only two distinct vertices, which a position-count check alone waves through.
The guard sits above the method switch, so it covers Douglas-Peucker and Visvalingam alike.