mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
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
46 lines
2.2 KiB
C++
46 lines
2.2 KiB
C++
#ifndef POLYGON_HPP
|
|
#define POLYGON_HPP
|
|
|
|
#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.
|
|
//
|
|
// `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);
|
|
|
|
// The length of the ring from geom[i] to geom[j] (world coordinates relative to
|
|
// 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 relative to a tile origin at (ox, oy)), which together
|
|
// trace its outline. This is used to stand in for a polygon that has collapsed
|
|
// away to nothing entirely. Edges shared with other features (with
|
|
// --no-simplification-of-shared-nodes) are left out, since those features
|
|
// already cover the space, and *all_shared is set if every edge was shared.
|
|
drawvec outline_strips(drawvec const &geom, int z, int detail, double simplification, long long ox, long long oy, bool *all_shared);
|
|
|
|
// 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);
|
|
|
|
#endif
|