mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
Replace polygons that collapse entirely with their outlines, not rectangles
When a polygon collapsed away to nothing during cleaning, revive_polygon() replaced it with a rectangle with the polygon's area, centered on the average of its vertices. That looked bad for two reasons. Most polygons that collapse are much smaller than a pixel, and the rectangle is at least a pixel, so it was usually far too big: for Dane County Census blocks at -D8 -d8 -pt -pn, 88% of the 27,206 revived polygons had less than half a pixel of area, and the median rectangle had 11 times the area of the polygon it replaced. And the larger polygons that collapse are almost all long and narrow, like blocks between roads, so a square at their midpoint looked nothing like them. Now a polygon that collapses entirely is first replaced by the union of one-pixel strips along every edge of its simplified outline, which traces its shape in the right place. Only if that is empty too, because the whole polygon is within a pixel or so, is it replaced by the rectangle, which is then a single pixel. This is part of spindle preservation, so with --no-spindle-preservation the rectangle is still used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
This commit is contained in:
@@ -30,6 +30,11 @@ drawvec thin_polygon_strips(drawvec const &geom, int z, int detail, double simpl
|
||||
// a tile origin at (ox, oy)) that is not made of edges shared with other features
|
||||
double unshared_perimeter(drawvec const &geom, size_t i, size_t j, long long ox, long long oy);
|
||||
|
||||
// Strips (in tile coordinates) one pixel wide along every edge of a polygon
|
||||
// (in world coordinates), which together trace its outline. This is used to
|
||||
// stand in for a polygon that has collapsed away to nothing entirely.
|
||||
drawvec outline_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);
|
||||
|
||||
Reference in New Issue
Block a user