Compare commits

..
Author SHA1 Message Date
Erica Fischer e33a52bf75 Update version and changelog 2025-04-02 14:01:49 -07:00
Erica Fischer 0d22f3dfeb Add test, fix default 2025-04-02 14:00:56 -07:00
Erica Fischer 4a17aecd3b Add option to deduplicate by feature ID in overzoom 2025-04-02 12:18:57 -07:00
8 changed files with 231 additions and 1103 deletions
-5
View File
@@ -1,8 +1,3 @@
# 2.78.0
* Fix potential infinite loops in as-needed dropping and coalescing. When the threshold cannot be increased,
it is now an error, rather than falling back to trying to lower the detail.
# 2.77.0
* Add --deduplicate-by-id option to tippecanoe-overzoom
-23
View File
@@ -2469,26 +2469,3 @@ drawvec fix_polygon(const drawvec &geom, bool use_winding, bool reverse_winding)
return out;
}
bool line_is_too_small(drawvec const &geometry, int z, int detail) {
if (geometry.size() == 0) {
return true;
}
long long x = 0, y = 0;
for (auto &g : geometry) {
if (g.op == VT_MOVETO) {
x = std::llround((double) g.x / (1LL << (32 - detail - z)));
y = std::llround((double) g.y / (1LL << (32 - detail - z)));
} else {
long long xx = std::llround((double) g.x / (1LL << (32 - detail - z)));
long long yy = std::llround((double) g.y / (1LL << (32 - detail - z)));
if (xx != x || yy != y) {
return false;
}
}
}
return true;
}
-1
View File
@@ -172,6 +172,5 @@ void get_quadkey_bounds(long long xmin, long long ymin, long long xmax, long lon
unsigned long long *start, unsigned long long *end);
clipbbox parse_clip_poly(std::string arg);
bool line_is_too_small(drawvec const &geometry, int z, int detail);
#endif
+29 -27
View File
@@ -769,7 +769,7 @@ static unsigned long long choose_mingap(std::vector<unsigned long long> &gaps, d
std::stable_sort(gaps.begin(), gaps.end());
size_t ix = (gaps.size() - 1) * (1 - f);
while (ix + 1 < gaps.size() && gaps[ix] <= existing_gap) {
while (ix + 1 < gaps.size() && gaps[ix] == existing_gap) {
ix++;
}
@@ -809,7 +809,7 @@ static long long choose_minextent(std::vector<long long> &extents, double f, lon
std::stable_sort(extents.begin(), extents.end());
size_t ix = (extents.size() - 1) * (1 - f);
while (ix + 1 < extents.size() && extents[ix] <= existing_extent) {
while (ix + 1 < extents.size() && extents[ix] == existing_extent) {
ix++;
}
@@ -824,7 +824,7 @@ static unsigned long long choose_mindrop_sequence(std::vector<unsigned long long
std::stable_sort(drop_sequences.begin(), drop_sequences.end());
size_t ix = (drop_sequences.size() - 1) * (1 - f);
while (ix + 1 < drop_sequences.size() && drop_sequences[ix] <= existing_drop_sequence) {
while (ix + 1 < drop_sequences.size() && drop_sequences[ix] == existing_drop_sequence) {
ix++;
}
@@ -1551,6 +1551,26 @@ bool find_feature_to_accumulate_onto(std::vector<std::shared_ptr<serial_feature>
return false;
}
static bool line_is_too_small(drawvec const &geometry, int z, int detail) {
if (geometry.size() == 0) {
return true;
}
long long x = std::round((double) geometry[0].x / (1LL << (32 - detail - z)));
long long y = std::round((double) geometry[0].y / (1LL << (32 - detail - z)));
for (auto &g : geometry) {
long long xx = std::round((double) g.x / (1LL << (32 - detail - z)));
long long yy = std::round((double) g.y / (1LL << (32 - detail - z)));
if (xx != x || yy != y) {
return false;
}
}
return true;
}
// Keep only a sample of 100K extents for feature dropping,
// to avoid spending lots of memory on a complete list when there are
// hundreds of millions of features.
@@ -2636,7 +2656,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
} else if (mingap < ULONG_MAX && (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED])) {
mingap_fraction = mingap_fraction * adjusted_max_tile_features / adjusted_feature_count * 0.80;
unsigned long long m = choose_mingap(gaps, mingap_fraction, mingap);
if (m > mingap) {
if (m != mingap) {
mingap = m;
if (mingap > arg->mingap_out) {
arg->mingap_out = mingap;
@@ -2647,14 +2667,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
line_detail++;
continue;
} else {
fprintf(stderr, "Can't increase feature gap threshold further\n");
exit(EXIT_INCOMPLETE);
}
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
minextent_fraction = minextent_fraction * adjusted_max_tile_features / adjusted_feature_count * 0.75;
long long m = choose_minextent(extents, minextent_fraction, minextent);
if (m > minextent) {
if (m != minextent) {
minextent = m;
if (minextent > arg->minextent_out) {
arg->minextent_out = minextent;
@@ -2665,9 +2682,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
line_detail++;
continue;
} else {
fprintf(stderr, "Can't increase feature extent threshold further\n");
exit(EXIT_INCOMPLETE);
}
} else if (feature_count > layers.size() && (additional[A_DROP_FRACTION_AS_NEEDED] || additional[A_COALESCE_FRACTION_AS_NEEDED] || prevent[P_DYNAMIC_DROP])) {
// The 95% is a guess to avoid too many retries
@@ -2675,7 +2689,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
mindrop_sequence_fraction = mindrop_sequence_fraction * adjusted_max_tile_features / adjusted_feature_count * 0.95;
unsigned long long m = choose_mindrop_sequence(drop_sequences, mindrop_sequence_fraction, mindrop_sequence);
if (m > mindrop_sequence) {
if (m != mindrop_sequence) {
mindrop_sequence = m;
if (mindrop_sequence > arg->mindrop_sequence_out) {
if (!prevent[P_DYNAMIC_DROP]) {
@@ -2688,9 +2702,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
line_detail++; // to keep it the same when the loop decrements it
continue;
} else {
fprintf(stderr, "Can't increase feature fraction threshold further\n");
exit(EXIT_INCOMPLETE);
}
} else {
fprintf(stderr, "Try using --drop-fraction-as-needed or --drop-densest-as-needed.\n");
@@ -2755,7 +2766,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
} else if (mingap < ULONG_MAX && (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED])) {
mingap_fraction = mingap_fraction * adjusted_max_tile_size / adjusted_tile_size * 0.80;
unsigned long long m = choose_mingap(gaps, mingap_fraction, mingap);
if (m > mingap) {
if (m != mingap) {
mingap = m;
if (mingap > arg->mingap_out) {
arg->mingap_out = mingap;
@@ -2766,14 +2777,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
line_detail++;
continue;
} else {
fprintf(stderr, "Can't increase feature gap threshold further\n");
exit(EXIT_INCOMPLETE);
}
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
minextent_fraction = minextent_fraction * adjusted_max_tile_size / adjusted_tile_size * 0.75;
long long m = choose_minextent(extents, minextent_fraction, minextent);
if (m > minextent) {
if (m != minextent) {
minextent = m;
if (minextent > arg->minextent_out) {
arg->minextent_out = minextent;
@@ -2784,14 +2792,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
line_detail++;
continue;
} else {
fprintf(stderr, "Can't increase feature extent threshold further\n");
exit(EXIT_INCOMPLETE);
}
} else if (feature_count > layers.size() && (additional[A_DROP_FRACTION_AS_NEEDED] || additional[A_COALESCE_FRACTION_AS_NEEDED] || prevent[P_DYNAMIC_DROP])) {
mindrop_sequence_fraction = mindrop_sequence_fraction * adjusted_max_tile_size / adjusted_tile_size * 0.75;
unsigned long long m = choose_mindrop_sequence(drop_sequences, mindrop_sequence_fraction, mindrop_sequence);
if (m > mindrop_sequence) {
if (m != mindrop_sequence) {
mindrop_sequence = m;
if (mindrop_sequence > arg->mindrop_sequence_out) {
if (!prevent[P_DYNAMIC_DROP]) {
@@ -2804,9 +2809,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
line_detail++;
continue;
} else {
fprintf(stderr, "Can't increase feature fraction threshold further\n");
exit(EXIT_INCOMPLETE);
}
} else {
detail_reduced++;
-9
View File
@@ -152,12 +152,3 @@ TEST_CASE("mvt_geometry bbox") {
REQUIRE(start == 0x1c84fc0000000000);
REQUIRE(end == 0x1c84ffffffffffff);
}
TEST_CASE("line_is_too_small") {
drawvec dv;
dv.emplace_back(VT_MOVETO, 4243099709, 2683872952);
dv.emplace_back(VT_LINETO, 4243102487, 2683873977);
dv.emplace_back(VT_MOVETO, -51867587, 2683872952);
dv.emplace_back(VT_LINETO, -51864809, 2683873977);
REQUIRE(line_is_too_small(dv, 0, 10));
}
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.78.0"
#define VERSION "v2.77.0"
#endif