mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
With -pn, union spindle strips in the same pass that cleans each polygon
With consistent snapping, each polygon was cleaned with the layer's hot pixels, but then its spindle strips (if it had any) were unioned with it in a separate pass, which snapped the whole polygon to tile coordinates a second time. Snapping already-snapped geometry doesn't necessarily leave it the same, and the neighbors it shares borders with weren't snapped again to match. In Dane County tile 12/1027/1502, a narrow water channel's strips were added where it crossed the edge of the tile's buffer, and that second pass bent its border with the block next to it, far from the strips, through the hot pixel at (11, 249), so their edges crossed and overlapped. So include the rounded strips of every polygon in the layer's hot pixels, and union each polygon with its strips (with the non-zero fill rule, as before) in the same wagyu pass that cleans it, so that every polygon is snapped exactly once, consistently with its neighbors, including where strips meet other polygons. For Dane County Census blocks at -D8 -d8 -pt -pn -zg, this reduces the number of polygons whose overlaps have to be removed afterwards from 2732 to 2482, and the number that are still changing after 4 rounds of overlap removal from 156 to 14, with still no points covered by more than one polygon at z8 to z12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
This commit is contained in:
@@ -741,9 +741,14 @@ static void *simplification_worker(void *v) {
|
||||
}
|
||||
}
|
||||
|
||||
// With the layer's hot pixels, clean the polygon and union it with its
|
||||
// spindle strips in the same pass, so that it is only snapped once.
|
||||
// (Snapping it again would not necessarily leave it the same,
|
||||
// and the other polygons it shares borders with would not be
|
||||
// snapped again to match.)
|
||||
bool cleaned = false;
|
||||
if (hot != NULL && geom.size() < 100000) {
|
||||
geom = clean_polygon_with_hot_pixels(before, *hot, &cleaned);
|
||||
geom = clean_polygon_with_hot_pixels(before, sf.strips, *hot, &cleaned);
|
||||
if (!cleaned) {
|
||||
geom = before;
|
||||
}
|
||||
@@ -751,8 +756,8 @@ static void *simplification_worker(void *v) {
|
||||
if (!cleaned) {
|
||||
// we can try scaling up because this is now tile scale
|
||||
coalesce_polygon(geom, true);
|
||||
geom = union_polygon_strips(geom, sf.strips, hot);
|
||||
}
|
||||
geom = union_polygon_strips(geom, sf.strips, hot);
|
||||
if (additional[A_DEBUG_POLYGON]) {
|
||||
check_polygon(geom);
|
||||
}
|
||||
@@ -2578,10 +2583,16 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
for (int snap_pass = consistent_snapping ? 1 : 0; snap_pass <= (consistent_snapping ? 2 : 0); snap_pass++) {
|
||||
if (snap_pass == 2) {
|
||||
// The hot pixels include those of the spindle strips, which are
|
||||
// unioned with the polygons as they are cleaned, so that where the
|
||||
// strips meet other polygons, they are snapped consistently too.
|
||||
std::map<long long, std::vector<drawvec const *>> layer_polygons;
|
||||
for (auto const &f : features) {
|
||||
if (f->t == VT_POLYGON) {
|
||||
layer_polygons[f->layer].push_back(&f->geometry);
|
||||
for (size_t i = 0; i < features.size(); i++) {
|
||||
if (features[i]->t == VT_POLYGON) {
|
||||
layer_polygons[features[i]->layer].push_back(&features[i]->geometry);
|
||||
if (simplified[i].strips.size() > 0) {
|
||||
layer_polygons[features[i]->layer].push_back(&simplified[i].strips);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto const &lp : layer_polygons) {
|
||||
|
||||
Reference in New Issue
Block a user