Preserve spindle polygons as one-pixel-wide strips instead of letting them collapse

A polygon (or part of a polygon) narrower than a tile pixel, like a
1-meter buffer around a long linestring, used to collapse away to nothing
at most zoom levels when it was rounded to tile coordinates, except for
scattered fragments wherever the rounding happened to keep its two sides
apart.

Now, before the geometry is rounded, thin_polygon_strips() looks for edges
that have an oppositely-directed edge less than sqrt(2) tile units away
(the most that rounding can move two boundaries toward each other) and
that is not just the other side of a corner (the two points must also be
far apart along the ring). Candidate pairs are found with a sweep over the
edges' bounding boxes, so polygons without narrow parts cost little more
than sorting their edges. Each narrow edge gets a one-unit-wide strip, one
side of which is the edge as it will be rounded and the other side of which
is offset one unit toward the polygon's interior, so the strips lie within
the polygon wherever it is already thick enough, and they are unioned with
the cleaned polygon. The union is done at 16x resolution, because the
strips from the two sides of a spindle are nearly coincident and wagyu's
own snap rounding would otherwise collapse them in places.

Long, narrow polygons whose perimeter is more than 8 times the tiny polygon
size are also no longer combined into tiny-polygon squares, so a spindle
stays visible down to the zoom level where it is shorter than that.

--no-spindle-preservation restores the old behavior.

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 20:03:31 +00:00
parent a888304b19
commit 957b1cd9b9
79 changed files with 10076 additions and 9090 deletions
+1
View File
@@ -513,6 +513,7 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
* `-pt` or `--no-tiny-polygon-reduction`: Don't combine the area of very small polygons into small squares that represent their combined area.
* `-pT` or `--no-tiny-polygon-reduction-at-maximum-zoom`: Combine the area of very small polygons into small squares that represent their combined area only at zoom levels below the maximum.
* `--tiny-polygon-size=`_size_: Use the specified _size_ for tiny polygons instead of the default 2. Anything above 6 or so will lead to visible artifacts with the default tile detail.
* `--no-spindle-preservation`: Don't preserve the narrow parts of polygons. Normally, parts of polygons that are too narrow to survive being rounded to tile coordinates (like a buffer of a few meters around a long road or river) are kept as continuous lines of polygon one pixel wide, and long, narrow polygons are kept as polygons rather than being combined into tiny-polygon squares. With this option, they are allowed to collapse away, which leaves them as scattered fragments wherever the rounding happens to keep their two sides apart.
* `-av` or `--visvalingam`: Use Visvalingam's simplification algorithm rather than Douglas-Peucker's.
### Attempts to improve shared polygon boundaries