Commit Graph
9 Commits
Author SHA1 Message Date
Claude b8e8542dfa Treat hot pixels as half-open when snapping to a layer's common set
With consistent snapping, edges are snapped to every hot pixel they touch,
including those whose corners they only touch. But with closed pixels, an
edge passing diagonally through a lattice point touches the corners of the
two pixels beside it as well, and is snapped into a zigzag through all four.
Two edges from different polygons that cross at a pixel corner zigzag
through the same pixels in different orders, and the zigzags cross each
other. (In Dane County tile 10/258/376, this left a quarter-pixel gap and a
quarter-pixel overlap between two blocks on either side of a sliver.)

Hobby's snap rounding, whose guarantee that snapped edges don't cross is
what makes snapping to a common set of hot pixels work, uses half-open
pixels, [x - 0.5, x + 0.5) by [y - 0.5, y + 0.5), consistent with rounding
halves up, which is how wagyu rounds intersection points. So when snapping
to a common set of hot pixels, find the range of pixels an edge passes
through in each row that way, so that a point on a pixel boundary belongs
to only one pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
2026-12-01 00:58:29 +00:00
Claude 162cb1c1b0 With -pn, snap-round each layer's polygons consistently with each other
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
2026-12-01 00:09:18 +00:00
Claude 5b35e5dacf Only skip corner-touching hot pixels for edges without intersections
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
2026-11-30 22:27:53 +00:00
Claude 1b17becfa3 Don't let wagyu snap edges to hot pixels whose corners they only touch
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
2026-11-30 22:15:42 +00:00
Eric Fischer e0c7f1b91a Upgrade Wagyu to version 0.5.0 2020-08-25 17:00:50 -07:00
Eric Fischer e9eca57393 Upgrade to Wagyu 0.4.3 2018-07-31 17:47:52 -07:00
Eric Fischer 72086b7e92 Upgrade Wagyu to cfc895 and use its Sutherland-Hodgman implementation 2017-01-11 15:43:07 -08:00
Eric Fischer bdac4d4e80 Upgrade Wagyu to bfbf2893 2017-01-04 16:33:43 -08:00
Eric Fischer 22cb5186d7 Copy of wagyu-0.2.0 (b3fa127) 2016-12-07 14:14:56 -08:00