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
This commit is contained in:
Claude
2026-11-30 22:15:42 +00:00
parent 2468cdba25
commit 1b17becfa3
18 changed files with 107 additions and 52 deletions
+6
View File
@@ -22,6 +22,12 @@
part with open space on its far side, like a coastal strip, is still kept.
Since strips are only needed for edges that are already known to be narrow,
the shared edges are only looked up for those, not for every vertex.
* Fix Wagyu's snap rounding so that an edge that only touches the corner of
a pixel containing a vertex is no longer treated as passing through that
pixel. Previously, two parallel 45-degree edges one tile unit apart were
each snapped to the other's vertices, so a perfectly valid diagonal polygon
one unit wide collapsed to nothing during cleaning, leaving gaps between
the features on either side of it.
# 2.82.0