With -pn, don't add spindle strips that would overlap neighboring features

A spindle strip extends one pixel past the far side of the narrow part it
preserves, so a panhandle between two neighboring features (or any narrow
part whose far side borders another feature) would overlap its neighbors
by up to a pixel, which is unfortunate for datasets that are meant to tile
exactly.

With --no-simplification-of-shared-nodes, the vertex pass already sorts every
polygon vertex with its neighbors to find the shared nodes. Each vertex record
now also carries the feature it came from, and the same pass writes out each
edge that is part of two or more different polygon features, as a sorted
table of half-edges. When a narrow edge's strip would extend past an edge
that is in that table, the strip is left out, so the panhandle collapses as
it used to and the features still tile exactly. A narrow part with open space
on its far side, like a coastal strip whose other side is a shared border,
still gets the strip along its shared side, which extends away from the
neighbor.

The table is only searched for edges that have already been found to be
narrow, not for every vertex, and since simplification may have removed
vertices along a shared border, an edge counts as shared if a shared edge
leaves either of its endpoints in its direction, within the simplification
tolerance. On a synthetic tiling (tests/spindle-shared), spindle
preservation with -pn adds no overlapping pixels at all compared to
--no-spindle-preservation, while without -pn the same data overlaps by
several hundred pixels per zoom level. On ne_10m_admin_0_countries -z8 -pn,
the time difference is within noise.

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 21:31:47 +00:00
parent 1963076817
commit 4352b1498f
14 changed files with 546 additions and 21 deletions
+8
View File
@@ -14,6 +14,14 @@
are also no longer combined into tiny-polygon squares, though they still
are once the zoom level is low enough that they are shorter than that.
`--no-spindle-preservation` restores the old behavior.
* With `--no-simplification-of-shared-nodes`, also find the polygon edges that
are shared between different features while finding the shared nodes, and
don't add a spindle strip along a narrow part where it would extend past a
shared edge into the neighboring feature. So a panhandle between two
neighbors still collapses, and the features still tile exactly, but a narrow
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.
# 2.82.0