Skip to content

Commit

Permalink
Fix bad interaction between dynamic dropping and limiting by truncati…
Browse files Browse the repository at this point in the history
…on (#260)

* Fix bad interaction between dynamic dropping and limiting by truncation

* Don't enforce the tile size limit here if they said not to
  • Loading branch information
e-n-f authored Sep 5, 2024
1 parent 5b18eea commit 51fcf14
Show file tree
Hide file tree
Showing 4 changed files with 348 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.62.0

* Fix another bad interaction, this time between dropping-as-needed and --limit-tile-feature-count

# 2.61.0

* Added --calculate-feature-index option
Expand Down

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
adjusted_feature_count = adjusted_feature_count * (skipped + kept) / kept;
}

if (too_many_bytes || adjusted_feature_count > adjusted_max_tile_size) {
if (too_many_bytes || (adjusted_feature_count > adjusted_max_tile_size && !prevent[P_KILOBYTE_LIMIT])) {
// Even being maximally conservative, each feature is still going to be
// at least one byte in the output tile, so this can't possibly work.
skipped++;
Expand Down Expand Up @@ -2490,13 +2490,17 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch

if (z == maxzoom && limit_tile_feature_count_at_maxzoom != 0) {
if (layer_features.size() > limit_tile_feature_count_at_maxzoom) {
can_stop_early = false;
// this is maxzoom; ok to stop early still because they said to limit abruptly
layer_features.resize(limit_tile_feature_count_at_maxzoom);
too_many_features = false; // don't try to drop; we have already truncated
skipped = 0; // doesn't matter that we skipped features; we have truncated
}
} else if (limit_tile_feature_count != 0) {
if (layer_features.size() > limit_tile_feature_count) {
can_stop_early = false;
layer_features.resize(limit_tile_feature_count);
too_many_features = false; // don't try to drop; we have already truncated
skipped = 0; // doesn't matter that we skipped features; we have truncated
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP

#define VERSION "v2.61.0"
#define VERSION "v2.62.0"

#endif

0 comments on commit 51fcf14

Please sign in to comment.