mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
With -pn, snap-round each layer's polygons consistently with each other
Wagyu snaps each edge to every "hot pixel" (vertex or rounded intersection) that it passes through. Each polygon was cleaned on its own, with only its own hot pixels, so a border shared by two polygons could be bent through a hot pixel in one of them and not in the other, leaving a shard gap or overlap between them even though --no-simplification-of-shared-nodes had simplified and rounded the border identically in both. (In Dane County tile 11/515/751, rounding moved one of a block's own vertices across its border with a sliver, and cleaning bent the block's copy of the border through a hot pixel that the sliver's copy didn't have.) Wagyu now has hot_pixels(), which returns the hot pixels of the rings added to it, and add_hot_pixels(), which gives execute() more hot pixels to snap to. When extra hot pixels are given, edges are snapped to every hot pixel they touch, including corner touches, so that whether a shared edge is snapped to a hot pixel can't depend on which polygon it is in. With -pn, the simplification worker now runs in two passes. The first simplifies and rounds every feature in the tile. Then the hot pixels of all the polygons in each layer are found together, which also finds crossings between features that no single feature would see. The second pass cleans each polygon with the layer's hot pixels near it as well as its own, so the borders it shares are snapped identically in each polygon. This is snap rounding of the whole layer's arrangement at once, so the result is still free of crossings. For Dane County Census blocks at -D8 -d8 -pt -pn, tiles 12/1031/1503 and 11/515/751 now have no gaps between blocks (from 10 and 23 pixels), and the gaps and overlaps at z9 and z10 go from 55/113 and 155/175 to 13/56 and 23/59 pixels, with no self-intersecting polygons. Natural Earth 10m countries at -z8 -pn take about 7% longer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
This commit is contained in:
@@ -31,12 +31,36 @@ class wagyu {
|
||||
private:
|
||||
local_minimum_list<T> minima_list;
|
||||
bool reverse_output;
|
||||
std::vector<mapbox::geometry::point<T>> extra_hot_pixels;
|
||||
|
||||
wagyu(wagyu const&) = delete;
|
||||
wagyu& operator=(wagyu const&) = delete;
|
||||
|
||||
public:
|
||||
wagyu() : minima_list(), reverse_output(false) {
|
||||
wagyu() : minima_list(), reverse_output(false), extra_hot_pixels() {
|
||||
}
|
||||
|
||||
// The hot pixels (the vertices and the rounded locations of intersections)
|
||||
// of the rings that have been added so far. Running this on all the rings
|
||||
// of several separate geometries, and passing the result to add_hot_pixels()
|
||||
// for each of them, makes edges that the geometries share snap identically
|
||||
// in each of them. This uses up the added rings, so it should be called on a
|
||||
// wagyu that is only being used to find hot pixels, not to execute.
|
||||
std::vector<mapbox::geometry::point<T>> hot_pixels() {
|
||||
ring_manager<T> manager;
|
||||
if (!minima_list.empty()) {
|
||||
build_hot_pixels(minima_list, manager);
|
||||
}
|
||||
return std::move(manager.hot_pixels);
|
||||
}
|
||||
|
||||
// Additional hot pixels, from hot_pixels() of a larger set of rings, for edges
|
||||
// to be snapped to as well as the hot pixels of the rings themselves. When these
|
||||
// are provided, edges are snapped to every hot pixel they touch, including those
|
||||
// whose corners they only touch, so that whether a shared edge is snapped to a
|
||||
// hot pixel does not depend on which geometry it is part of.
|
||||
void add_hot_pixels(std::vector<mapbox::geometry::point<T>> const& pixels) {
|
||||
extra_hot_pixels.insert(extra_hot_pixels.end(), pixels.begin(), pixels.end());
|
||||
}
|
||||
|
||||
~wagyu() {
|
||||
@@ -126,6 +150,11 @@ public:
|
||||
interrupt_check(); // Check for interruptions
|
||||
|
||||
build_hot_pixels(minima_list, manager);
|
||||
if (!extra_hot_pixels.empty()) {
|
||||
manager.snap_all_corners = true;
|
||||
manager.hot_pixels.insert(manager.hot_pixels.end(), extra_hot_pixels.begin(), extra_hot_pixels.end());
|
||||
sort_hot_pixels(manager);
|
||||
}
|
||||
|
||||
interrupt_check(); // Check for interruptions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user