Skip to content

Guard against degenerate rings in SimplifyTopology#32

Merged
SimonCropp merged 1 commit into
mainfrom
Guard-against-degenerate-rings-in-SimplifyTopology
Jul 10, 2026
Merged

Guard against degenerate rings in SimplifyTopology#32
SimonCropp merged 1 commit into
mainfrom
Guard-against-degenerate-rings-in-SimplifyTopology

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

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.

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.
@SimonCropp SimonCropp added this to the 2.0.2 milestone Jul 10, 2026
@SimonCropp SimonCropp merged commit 2fb7873 into main Jul 10, 2026
5 checks passed
@SimonCropp SimonCropp deleted the Guard-against-degenerate-rings-in-SimplifyTopology branch July 10, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant