mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
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:
+15
@@ -0,0 +1,15 @@
|
||||
#ifndef POLYGON_HPP
|
||||
#define POLYGON_HPP
|
||||
|
||||
#include "geometry.hpp"
|
||||
|
||||
// Find the parts of a polygon (in world coordinates) that are narrower than
|
||||
// a pixel at zoom level z with the specified tile detail, and return strips
|
||||
// (in tile coordinates) covering the pixels along them.
|
||||
drawvec thin_polygon_strips(drawvec const &geom, int z, int detail);
|
||||
|
||||
// Union the strips from thin_polygon_strips() with a cleaned polygon
|
||||
// (both in tile coordinates)
|
||||
drawvec union_polygon_strips(drawvec const &geom, drawvec const &strips);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user