mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
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:
+19
-1
@@ -3,10 +3,28 @@
|
||||
|
||||
#include "geometry.hpp"
|
||||
|
||||
// One direction of a polygon edge that is shared between two or more
|
||||
// different polygon features, as identified by --no-simplification-of-shared-nodes,
|
||||
// in world coordinates. The list of these is sorted by `a` (y, then x)
|
||||
// and then by `b` (y, then x), and is used to avoid adding spindle strips
|
||||
// along edges that border other features, where they would overlap them.
|
||||
struct shared_edge {
|
||||
long long ax, ay;
|
||||
long long bx, by;
|
||||
};
|
||||
|
||||
extern shared_edge *shared_edges_map;
|
||||
extern size_t shared_edges_count;
|
||||
|
||||
// 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);
|
||||
//
|
||||
// `simplification` is the simplification tolerance, in tile units, that the
|
||||
// geometry was simplified with, which is how far a simplified shared border
|
||||
// may have strayed from the original shared edges. (ox, oy) is the world
|
||||
// coordinate of the tile origin that the geometry is relative to.
|
||||
drawvec thin_polygon_strips(drawvec const &geom, int z, int detail, double simplification = 1, long long ox = 0, long long oy = 0);
|
||||
|
||||
// Union the strips from thin_polygon_strips() with a cleaned polygon
|
||||
// (both in tile coordinates)
|
||||
|
||||
Reference in New Issue
Block a user