mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
Only exempt the unshared length of a ring from tiny polygon reduction
Long, narrow rings were exempted from tiny polygon reduction so that spindle preservation could keep them as lines. But with -pn, no strips are added along borders shared with other features, so a narrow block whose length is mostly shared border was exempted, then collapsed completely in cleaning, and was then replaced by revive_polygon()'s placeholder rectangle, which overlaps its neighbors. (In Dane County census blocks at -D8 -d8 -pn, this raised the number of revived polygons at z12 from 57 to 92.) Now only the part of the ring's length that is not made of shared edges counts toward the exemption, so such blocks are combined into tiny polygons as before. The shared edges can be matched exactly here, because tiny polygon reduction happens before simplification. reduce_tiny_poly() takes the length function as a callback because clip.cpp is also linked into tools that don't include polygon.cpp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
This commit is contained in:
@@ -2169,10 +2169,19 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
if (sf.t == VT_POLYGON) {
|
||||
bool simplified_away_by_reduction = false;
|
||||
|
||||
// How much of a ring's length spindle preservation would be able to preserve
|
||||
std::function<double(drawvec const &, size_t, size_t)> spindle_length;
|
||||
if (!prevent[P_SPINDLES]) {
|
||||
long long ox = (long long) tx << (32 - z), oy = (long long) ty << (32 - z);
|
||||
spindle_length = [ox, oy](drawvec const &g, size_t i, size_t j) {
|
||||
return unshared_perimeter(g, i, j, ox, oy);
|
||||
};
|
||||
}
|
||||
|
||||
bool prevent_tiny = prevent[P_TINY_POLYGON_REDUCTION] ||
|
||||
(prevent[P_TINY_POLYGON_REDUCTION_AT_MAXZOOM] && z == maxzoom);
|
||||
if (!prevent_tiny && !additional[A_GRID_LOW_ZOOMS]) {
|
||||
sf.geometry = reduce_tiny_poly(sf.geometry, z, line_detail, &still_need_simplification_after_reduction, &simplified_away_by_reduction, &accum_area, tiny_polygon_size, !prevent[P_SPINDLES]);
|
||||
sf.geometry = reduce_tiny_poly(sf.geometry, z, line_detail, &still_need_simplification_after_reduction, &simplified_away_by_reduction, &accum_area, tiny_polygon_size, spindle_length);
|
||||
if (simplified_away_by_reduction) {
|
||||
strategy.tiny_polygons++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user