Skip to content

Commit

Permalink
Dropping a feature into a multiplier cluster still effectively drops it
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Aug 20, 2024
1 parent 114e7f2 commit 8265594
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"maxzoom": "10",
"minzoom": "0",
"name": "tests/muni/out/-z10_--retain-points-multiplier_10_-M10000_--drop-smallest-as-needed.json.check.mbtiles",
"strategies": "[{\"dropped_by_rate\":4591},{\"dropped_by_rate\":4591},{\"dropped_by_rate\":4561},{\"dropped_by_rate\":4511},{\"dropped_by_rate\":4401},{\"dropped_by_rate\":4121},{\"dropped_by_rate\":3411},{\"dropped_by_rate\":1650},{\"dropped_by_rate\":1066,\"dropped_as_needed\":107,\"tile_size_desired\":68538},{\"dropped_by_rate\":1058,\"dropped_as_needed\":696,\"tile_size_desired\":72665},{\"dropped_as_needed\":1976,\"tile_size_desired\":67958}]",
"strategies": "[{\"dropped_by_rate\":4591},{\"dropped_by_rate\":4591},{\"dropped_by_rate\":4561},{\"dropped_by_rate\":4511},{\"dropped_by_rate\":4401},{\"dropped_by_rate\":4121},{\"dropped_by_rate\":3411},{\"dropped_by_rate\":1650},{\"dropped_by_rate\":1066,\"dropped_as_needed\":311,\"tile_size_desired\":68538},{\"dropped_by_rate\":1058,\"dropped_as_needed\":1579,\"tile_size_desired\":72665},{\"dropped_as_needed\":4452,\"tile_size_desired\":67958}]",
"tippecanoe_decisions": "{\"basezoom\":10,\"droprate\":2.5,\"retain_points_multiplier\":10}",
"type": "overlay",
"version": "2"
Expand Down
11 changes: 4 additions & 7 deletions tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1525,14 +1525,14 @@ bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features
ssize_t which_serial_feature;

if (find_feature_to_accumulate_onto(layer.features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
strategy.dropped_as_needed++;
if (layer.multiplier_cluster_size < (size_t) retain_points_multiplier) {
// we have capacity to keep this feature as part of an existing multiplier cluster that isn't full yet
// so do that instead of dropping it
sf.dropped = layer.multiplier_cluster_size + 1;
return false; // converted rather than dropped
} else {
preserve_attributes(attribute_accum, sf, layer.features[which_serial_feature]);
strategy.dropped_as_needed++;
drop_rest = true;
return true; // dropped
}
Expand Down Expand Up @@ -1589,7 +1589,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
// empirical estimate from ne_10m_admin_0_countries, CPAD units, Cal fires.
// only try to make an overzoomable final tile if it seems like it might work
long long estimated_output_tile_size = 0.6693 * estimated_complexity - 3.36e+04;

if (estimated_output_tile_size < (long long) (0.9 * max_tile_size)) {
first_detail = 30 - z;
second_detail = detail;
Expand Down Expand Up @@ -1870,8 +1869,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
} else if (additional[A_DROP_DENSEST_AS_NEEDED]) {
add_sample_to(gaps, sf.gap, gaps_increment, seq);
if (sf.gap < mingap) {
can_stop_early = false;
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
can_stop_early = false;
continue;
}
}
Expand Down Expand Up @@ -1915,8 +1914,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
// search here is for LLONG_MAX, not minextent, because we are dropping features, not coalescing them,
// so we shouldn't expect to find anything small that we can related this feature to.
if (minextent != 0 && sf.extent + coalesced_area <= minextent) {
can_stop_early = false;
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
can_stop_early = false;
continue;
}
}
Expand All @@ -1934,11 +1933,9 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
} else if (additional[A_DROP_FRACTION_AS_NEEDED] || prevent[P_DYNAMIC_DROP]) {
add_sample_to(drop_sequences, drop_sequence, drop_sequences_increment, seq);
// search here is for LLONG_MAX, not minextent, because we are dropping features, not coalescing them,
// so we shouldn't expect to find anything small that we can related this feature to.
if (mindrop_sequence != 0 && drop_sequence <= mindrop_sequence) {
can_stop_early = false;
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
can_stop_early = false;
continue;
}
}
Expand Down

0 comments on commit 8265594

Please sign in to comment.