mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
With -pn, let neighbors close over polygons that collapse entirely
A polygon that collapses away entirely is replaced by its outline, but with --no-simplification-of-shared-nodes that outline overlaps the neighboring features along every shared border, and those features already cover the space. So leave the shared borders out of the outline, as the spindle strips already do, and if every border is shared, leave the polygon out entirely instead of falling back to a rectangle. For Dane County Census blocks at -D8 -d8 -pt -pn, this reduces the overlapping pixels in tile 12/1031/1503 from 141 to 11 and in 11/515/751 from 915 to 38, and the number of revived rectangles at z8 from 6307 to 1414, at the cost of a few more one-pixel gaps (7 to 10 and 14 to 23) where a block of less than a pixel is left out and its neighbors' borders don't round to the same line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
This commit is contained in:
+21
-1
@@ -421,14 +421,19 @@ drawvec thin_polygon_strips(drawvec const &geom, int z, int detail, double simpl
|
||||
return out;
|
||||
}
|
||||
|
||||
drawvec outline_strips(drawvec const &geom, int z, int detail) {
|
||||
drawvec outline_strips(drawvec const &geom, int z, int detail, double simplification, long long ox, long long oy, bool *all_shared) {
|
||||
drawvec out;
|
||||
*all_shared = false;
|
||||
|
||||
int shift = 32 - detail - z;
|
||||
if (shift <= 0) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// How far a simplified shared border may have strayed from the original shared edges
|
||||
const double tolerance = (1 + std::max(simplification, 0.0)) * (1LL << shift);
|
||||
size_t edges = 0, shared = 0;
|
||||
|
||||
for (size_t i = 0; i < geom.size(); i++) {
|
||||
if (geom[i].op == VT_MOVETO) {
|
||||
size_t j;
|
||||
@@ -441,6 +446,20 @@ drawvec outline_strips(drawvec const &geom, int z, int detail) {
|
||||
if (j - i >= 3) {
|
||||
for (size_t k = i; k < j; k++) {
|
||||
size_t n = (k + 1 < j) ? k + 1 : i; // close the ring if it isn't already
|
||||
if (geom[k].x == geom[n].x && geom[k].y == geom[n].y) {
|
||||
continue;
|
||||
}
|
||||
edges++;
|
||||
|
||||
// Along a border shared with another feature, that feature
|
||||
// already covers the space, so leave it to close over it.
|
||||
if (shared_edges_count > 0 &&
|
||||
(shared_toward(geom[k].x + ox, geom[k].y + oy, geom[n].x + ox, geom[n].y + oy, tolerance) ||
|
||||
shared_toward(geom[n].x + ox, geom[n].y + oy, geom[k].x + ox, geom[k].y + oy, tolerance))) {
|
||||
shared++;
|
||||
continue;
|
||||
}
|
||||
|
||||
add_strip(out, geom[k].x, geom[k].y, geom[n].x, geom[n].y, shift);
|
||||
}
|
||||
}
|
||||
@@ -449,6 +468,7 @@ drawvec outline_strips(drawvec const &geom, int z, int detail) {
|
||||
}
|
||||
}
|
||||
|
||||
*all_shared = edges > 0 && shared == edges;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user