Wagyu snaps each edge to every "hot pixel" (vertex or rounded intersection)
that it passes through. Each polygon was cleaned on its own, with only its
own hot pixels, so a border shared by two polygons could be bent through a
hot pixel in one of them and not in the other, leaving a shard gap or overlap
between them even though --no-simplification-of-shared-nodes had simplified
and rounded the border identically in both. (In Dane County tile 11/515/751,
rounding moved one of a block's own vertices across its border with a sliver,
and cleaning bent the block's copy of the border through a hot pixel that the
sliver's copy didn't have.)
Wagyu now has hot_pixels(), which returns the hot pixels of the rings added
to it, and add_hot_pixels(), which gives execute() more hot pixels to snap
to. When extra hot pixels are given, edges are snapped to every hot pixel
they touch, including corner touches, so that whether a shared edge is
snapped to a hot pixel can't depend on which polygon it is in.
With -pn, the simplification worker now runs in two passes. The first
simplifies and rounds every feature in the tile. Then the hot pixels of all
the polygons in each layer are found together, which also finds crossings
between features that no single feature would see. The second pass cleans
each polygon with the layer's hot pixels near it as well as its own, so
the borders it shares are snapped identically in each polygon. This is
snap rounding of the whole layer's arrangement at once, so the result is
still free of crossings.
For Dane County Census blocks at -D8 -d8 -pt -pn, tiles 12/1031/1503 and
11/515/751 now have no gaps between blocks (from 10 and 23 pixels), and the
gaps and overlaps at z9 and z10 go from 55/113 and 155/175 to 13/56 and 23/59
pixels, with no self-intersecting polygons. Natural Earth 10m countries at
-z8 -pn take about 7% longer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
The previous change, which stopped wagyu from snapping an edge to a hot
pixel whose corner it only touches, made two of upstream wagyu's 3320
geometry fixtures produce spikes. When an intersection lies exactly on a
pixel corner, it is rounded to that pixel, and the edges that intersect
there must be snapped to it; and once an edge has been snapped to one hot
pixel, its new segments may pass through the interior of another hot pixel
whose corner the original edge only touched.
So now the inward rounding of the hot pixel range only applies to an edge
that intersects no other edge (which is recorded while the hot pixels are
built), and never to a hot pixel that is the rounded location of an
intersection (which are now kept in a separate sorted list). Edges that are
part of intersections are snapped exactly as before. With this, upstream
wagyu's unit tests and all 3320 of its geometry fixtures pass, and the
narrow diagonal Census block in Dane County is still preserved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
Wagyu's snap rounding finds the hot pixels (pixels containing a vertex or
intersection) that each edge passes through, row by row, by rounding the
x range that the edge covers within the row outward. A value exactly
halfway between two integers was rounded outward too, so a pixel whose
corner the edge merely touched counted as one it passed through.
For a 45-degree edge, the x range always ends exactly on pixel corners,
so two parallel diagonal edges one unit apart were each snapped to the
other's endpoints, and a perfectly valid diagonal polygon one unit wide
(for example, a narrow Census block between two others, after rounding to
tile coordinates) was collapsed to nothing by cleaning, leaving a diagonal
gap between the blocks on either side of it.
Round halfway values inward instead, for this purpose only (the rounding
of intersection points is unchanged). On Dane County census blocks at
-D8 -d8 -pn -pt, this removes about 10-20% of the gaps between blocks at
z9 and z10, without introducing any self-intersecting polygons (checked
independently with exact orientation tests at z6-z12). Upstream wagyu's
rounding is unchanged since 2020.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
* wagyu: drop a hole no remaining ring can parent instead of throwing
correct_tree() throws "Could not properly place hole to a parent" when
topology correction leaves a hole whose parent ring was removed (degenerate
input such as stacked duplicate rings from coalesced tiny-polygon
placeholders). That aborts the entire tiling run over one unrepresentable
sliver. Remove the ring and its points instead, matching how other
unresolvable degeneracies are handled.
* Add a regression test for dropping an unplaceable hole
A fuzzer-minimized pair of mutually reversed self-intersecting rings that
makes wagyu's correct_tree fail to find a parent for a hole — the same
failure reported in mapbox/tippecanoe#761. Before the topology_correction
change, running this test exits with EXIT_IMPOSSIBLE via the polygon
cleaning error handler; with it, the clean returns.