mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-28 03:11:18 +01:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc59c6ba84 | ||
|
|
1a38b43f49 | ||
|
|
c3fa99bc86 |
@@ -3113,11 +3113,9 @@ int main(int argc, char **argv) {
|
||||
{"drop-densest-as-needed", no_argument, &additional[A_DROP_DENSEST_AS_NEEDED], 1},
|
||||
{"drop-fraction-as-needed", no_argument, &additional[A_DROP_FRACTION_AS_NEEDED], 1},
|
||||
{"drop-smallest-as-needed", no_argument, &additional[A_DROP_SMALLEST_AS_NEEDED], 1},
|
||||
{"drop-sparsest-as-needed", no_argument, &additional[A_DROP_SPARSEST_AS_NEEDED], 1},
|
||||
{"coalesce-densest-as-needed", no_argument, &additional[A_COALESCE_DENSEST_AS_NEEDED], 1},
|
||||
{"coalesce-fraction-as-needed", no_argument, &additional[A_COALESCE_FRACTION_AS_NEEDED], 1},
|
||||
{"coalesce-smallest-as-needed", no_argument, &additional[A_COALESCE_SMALLEST_AS_NEEDED], 1},
|
||||
{"coalesce-sparsest-as-needed", no_argument, &additional[A_COALESCE_SPARSEST_AS_NEEDED], 1},
|
||||
{"force-feature-limit", no_argument, &prevent[P_DYNAMIC_DROP], 1},
|
||||
{"cluster-densest-as-needed", no_argument, &additional[A_CLUSTER_DENSEST_AS_NEEDED], 1},
|
||||
|
||||
|
||||
@@ -14,11 +14,9 @@
|
||||
#define A_DROP_DENSEST_AS_NEEDED ((int) 's')
|
||||
#define A_DROP_FRACTION_AS_NEEDED ((int) 'd')
|
||||
#define A_DROP_SMALLEST_AS_NEEDED ((int) 'n')
|
||||
#define A_DROP_SPARSEST_AS_NEEDED ((int) 's' & 0x1F)
|
||||
#define A_COALESCE_DENSEST_AS_NEEDED ((int) 'S')
|
||||
#define A_COALESCE_SMALLEST_AS_NEEDED ((int) 'N')
|
||||
#define A_COALESCE_FRACTION_AS_NEEDED ((int) 'D')
|
||||
#define A_COALESCE_SPARSEST_AS_NEEDED ((int) 't' & 0x1F)
|
||||
#define A_GRID_LOW_ZOOMS ((int) 'L')
|
||||
#define A_DETECT_WRAPAROUND ((int) 'w')
|
||||
#define A_EXTEND_ZOOMS ((int) 'e')
|
||||
|
||||
+1
-3
@@ -681,7 +681,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
|
||||
// keep old behavior, which loses one bit of precision at the bottom
|
||||
midx = (sf.bbox[0] / 2 + sf.bbox[2] / 2) & ((1LL << 32) - 1);
|
||||
midy = (sf.bbox[1] / 2 + sf.bbox[3] / 2) & ((1LL << 32) - 1);
|
||||
} else if ((additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_DROP_SPARSEST_AS_NEEDED] || additional[A_COALESCE_SPARSEST_AS_NEEDED]) && sf.t == VT_POLYGON) {
|
||||
} else if ((additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED]) && sf.t == VT_POLYGON) {
|
||||
// This probably should really apply to all polygons,
|
||||
// but I hate to change the feature sequence in all the
|
||||
// test fixtures again
|
||||
@@ -725,8 +725,6 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
|
||||
|
||||
if (additional[A_DROP_DENSEST_AS_NEEDED] ||
|
||||
additional[A_COALESCE_DENSEST_AS_NEEDED] ||
|
||||
additional[A_DROP_SPARSEST_AS_NEEDED] ||
|
||||
additional[A_COALESCE_SPARSEST_AS_NEEDED] ||
|
||||
additional[A_CLUSTER_DENSEST_AS_NEEDED] ||
|
||||
additional[A_CALCULATE_FEATURE_DENSITY] ||
|
||||
additional[A_DROP_SMALLEST_AS_NEEDED] ||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -772,17 +772,6 @@ static unsigned long long choose_mingap(std::vector<unsigned long long> &gaps, d
|
||||
return gaps[ix];
|
||||
}
|
||||
|
||||
static unsigned long long choose_maxgap(std::vector<unsigned long long> &gaps, double f, unsigned long long existing_gap) {
|
||||
std::stable_sort(gaps.begin(), gaps.end());
|
||||
|
||||
size_t ix = (gaps.size() - 1) * f;
|
||||
while (ix > 0 && gaps[ix] == existing_gap) {
|
||||
ix--;
|
||||
}
|
||||
|
||||
return gaps[ix];
|
||||
}
|
||||
|
||||
// This function is called to choose the new "extent" threshold to try when a tile exceeds the
|
||||
// tile size limit or feature limit and `--drop-smallest-as-needed` or `--coalesce-smallest-as-needed`
|
||||
// has been set.
|
||||
@@ -899,8 +888,6 @@ struct write_tile_args {
|
||||
size_t pass = 0;
|
||||
unsigned long long mingap = 0;
|
||||
unsigned long long mingap_out = 0;
|
||||
unsigned long long maxgap = 0;
|
||||
unsigned long long maxgap_out = 0;
|
||||
long long minextent = 0;
|
||||
long long minextent_out = 0;
|
||||
unsigned long long mindrop_sequence = 0;
|
||||
@@ -1534,7 +1521,7 @@ struct layer_features {
|
||||
size_t multiplier_cluster_size = 0; // The feature count of the current multiplier cluster
|
||||
};
|
||||
|
||||
bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features &layer, serial_feature &sf, std::vector<std::vector<std::string>> *layer_unmaps, size_t &multiplier_seq, strategy &strategy, bool &drop_rest, std::unordered_map<std::string, attribute_op> const *attribute_accum) {
|
||||
bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features &layer, serial_feature &sf, std::vector<std::vector<std::string>> *layer_unmaps, size_t &multiplier_seq, strategy &strategy, bool &drop_rest_of_cluster, std::unordered_map<std::string, attribute_op> const *attribute_accum) {
|
||||
ssize_t which_serial_feature;
|
||||
|
||||
if (find_feature_to_accumulate_onto(layer.features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
|
||||
@@ -1546,7 +1533,7 @@ bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features
|
||||
} else {
|
||||
preserve_attributes(attribute_accum, sf, layer.features[which_serial_feature]);
|
||||
strategy.dropped_as_needed++;
|
||||
drop_rest = true;
|
||||
drop_rest_of_cluster = true;
|
||||
return true; // dropped
|
||||
}
|
||||
}
|
||||
@@ -1560,10 +1547,9 @@ void skip_tile(decompressor *geoms, std::atomic<long long> *geompos_in, bool com
|
||||
}
|
||||
}
|
||||
|
||||
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, std::atomic<long long> *geompos, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, unsigned *initial_x, unsigned *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, unsigned long long mingap, unsigned long long maxgap, long long minextent, unsigned long long mindrop_sequence, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy_out, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, std::vector<std::string> const &unidecode_data, long long estimated_complexity, std::set<zxy> &skip_children_out) {
|
||||
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, std::atomic<long long> *geompos, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, unsigned *initial_x, unsigned *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy_out, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, std::vector<std::string> const &unidecode_data, long long estimated_complexity, std::set<zxy> &skip_children_out) {
|
||||
double merge_fraction = 1;
|
||||
double mingap_fraction = 1;
|
||||
double maxgap_fraction = 1;
|
||||
double minextent_fraction = 1;
|
||||
double mindrop_sequence_fraction = 1;
|
||||
|
||||
@@ -1654,6 +1640,9 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
size_t lead_features_count = 0; // of the tile so far
|
||||
size_t other_multiplier_cluster_features_count = 0; // of the tile so far
|
||||
|
||||
bool too_many_features = false;
|
||||
bool too_many_bytes = false;
|
||||
|
||||
std::atomic<bool> within[child_shards];
|
||||
long long start_geompos[child_shards];
|
||||
for (size_t i = 0; i < (size_t) child_shards; i++) {
|
||||
@@ -1755,8 +1744,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
struct multiplier_state multiplier_state;
|
||||
size_t multiplier_seq = retain_points_multiplier - 1;
|
||||
bool drop_rest = false; // are we dropping the remainder of a multiplier cluster whose first point was dropped?
|
||||
bool dropping_by_rate = false; // are we dropping anything by rate in this tile, or keeping it only as part of a multiplier?
|
||||
bool drop_rest_of_cluster = false; // are we dropping the remainder of a multiplier cluster whose first point was dropped?
|
||||
bool dropping_by_rate = false; // are we dropping anything by rate in this tile, or keeping it only as part of a multiplier?
|
||||
unsigned long long next_feature_previndex = 0;
|
||||
|
||||
strategy strategy;
|
||||
@@ -1811,7 +1800,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
if (sf.dropped == FEATURE_KEPT) {
|
||||
// this is a new multiplier cluster, so stop dropping features
|
||||
// that were dropped because the previous lead feature was dropped
|
||||
drop_rest = false;
|
||||
drop_rest_of_cluster = false;
|
||||
} else {
|
||||
can_stop_early = false;
|
||||
|
||||
@@ -1825,7 +1814,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
}
|
||||
|
||||
if (sf.dropped == FEATURE_DROPPED || drop_rest) {
|
||||
if (sf.dropped == FEATURE_DROPPED || drop_rest_of_cluster) {
|
||||
multiplier_seq = (multiplier_seq + 1) % retain_points_multiplier;
|
||||
|
||||
if (find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
|
||||
@@ -1840,13 +1829,13 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
// only the first point of a multiplier cluster can be dropped
|
||||
// by any of these mechanisms. (but if one is, it drags the whole
|
||||
// cluster down with it by setting drop_rest).
|
||||
// cluster down with it by setting drop_rest_of_cluster).
|
||||
if (sf.dropped == FEATURE_KEPT) {
|
||||
if (gamma > 0) {
|
||||
if (manage_gap(sf.index, &previndex, scale, gamma, &gap) && find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy.dropped_by_gamma++;
|
||||
drop_rest = true;
|
||||
drop_rest_of_cluster = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1874,14 +1863,14 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
drop_rest_of_cluster = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
} else if (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_DROP_SPARSEST_AS_NEEDED]) {
|
||||
} else if (additional[A_DROP_DENSEST_AS_NEEDED]) {
|
||||
add_sample_to(gaps, sf.gap, gaps_increment, seq);
|
||||
if (sf.gap < mingap || sf.gap > maxgap) {
|
||||
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
|
||||
if (sf.gap < mingap) {
|
||||
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest_of_cluster, arg->attribute_accum)) {
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1906,18 +1895,18 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
drop_rest_of_cluster = true;
|
||||
continue;
|
||||
}
|
||||
} else if (additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_COALESCE_SPARSEST_AS_NEEDED]) {
|
||||
} else if (additional[A_COALESCE_DENSEST_AS_NEEDED]) {
|
||||
add_sample_to(gaps, sf.gap, gaps_increment, seq);
|
||||
if ((sf.gap < mingap || sf.gap > maxgap) && find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
|
||||
if (sf.gap < mingap && find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
|
||||
coalesce_geometry(features[which_serial_feature], sf);
|
||||
features[which_serial_feature].coalesced = true;
|
||||
coalesced_area += sf.extent;
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
drop_rest_of_cluster = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1926,7 +1915,7 @@ 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) {
|
||||
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
|
||||
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest_of_cluster, arg->attribute_accum)) {
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1939,7 +1928,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
coalesced_area += sf.extent;
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
drop_rest_of_cluster = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1948,7 +1937,7 @@ 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 (mindrop_sequence != 0 && drop_sequence <= mindrop_sequence) {
|
||||
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
|
||||
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest_of_cluster, arg->attribute_accum)) {
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1960,7 +1949,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
features[which_serial_feature].coalesced = true;
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
drop_rest_of_cluster = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -2009,10 +1998,24 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
unsigned long long sfindex = sf.index;
|
||||
|
||||
if (sf.geometry.size() > 0) {
|
||||
if (lead_features_count > max_tile_size || (lead_features_count + other_multiplier_cluster_features_count > max_tile_features && !prevent[P_FEATURE_LIMIT])) {
|
||||
// Adjust tile size limit based on the ratio of multiplier cluster features to lead features
|
||||
size_t scaled_max_tile_size = max_tile_size;
|
||||
if (lead_features_count > 0) {
|
||||
scaled_max_tile_size *= (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
|
||||
}
|
||||
size_t scaled_max_tile_features = max_tile_features;
|
||||
if (lead_features_count > 0) {
|
||||
scaled_max_tile_features *= (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
|
||||
}
|
||||
|
||||
if (too_many_bytes || lead_features_count > scaled_max_tile_size) {
|
||||
// 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++;
|
||||
too_many_bytes = true;
|
||||
} else if (too_many_features || (lead_features_count + other_multiplier_cluster_features_count > scaled_max_tile_features && !prevent[P_FEATURE_LIMIT])) {
|
||||
skipped++;
|
||||
too_many_features = true;
|
||||
} else {
|
||||
kept++;
|
||||
|
||||
@@ -2497,13 +2500,15 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
|
||||
if (totalsize > 0 && tile.layers.size() > 0) {
|
||||
if (totalsize > scaled_max_tile_features && !prevent[P_FEATURE_LIMIT]) {
|
||||
if (too_many_features || (totalsize > scaled_max_tile_features && !prevent[P_FEATURE_LIMIT])) {
|
||||
if (totalsize > arg->feature_count_out) {
|
||||
arg->feature_count_out = totalsize;
|
||||
}
|
||||
|
||||
size_t estimated = totalsize * (skipped + kept) / kept;
|
||||
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "tile %d/%u/%u has %zu features, >%zu \n", z, tx, ty, totalsize, scaled_max_tile_features);
|
||||
fprintf(stderr, "tile %d/%u/%u has %zu (estimated %zu) features, >%zu \n", z, tx, ty, totalsize, estimated, scaled_max_tile_features);
|
||||
}
|
||||
|
||||
if (trying_to_stop_early && line_detail == first_detail) {
|
||||
@@ -2529,7 +2534,7 @@ 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 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 * scaled_max_tile_features / totalsize * 0.80;
|
||||
mingap_fraction = mingap_fraction * scaled_max_tile_features / estimated * 0.80;
|
||||
unsigned long long m = choose_mingap(gaps, mingap_fraction, mingap);
|
||||
if (m != mingap) {
|
||||
mingap = m;
|
||||
@@ -2543,23 +2548,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++;
|
||||
continue;
|
||||
}
|
||||
} else if (maxgap > 0 && (additional[A_DROP_SPARSEST_AS_NEEDED] || additional[A_COALESCE_SPARSEST_AS_NEEDED])) {
|
||||
maxgap_fraction = maxgap_fraction * scaled_max_tile_features / totalsize * 0.80;
|
||||
unsigned long long m = choose_maxgap(gaps, maxgap_fraction, maxgap);
|
||||
if (m != maxgap) {
|
||||
maxgap = m;
|
||||
if (maxgap < arg->maxgap_out) {
|
||||
arg->maxgap_out = maxgap;
|
||||
arg->still_dropping = true;
|
||||
}
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Going to try keeping the densest %0.2f%% of the features to make it fit\n", maxgap_fraction * 100.0);
|
||||
}
|
||||
line_detail++;
|
||||
continue;
|
||||
}
|
||||
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
minextent_fraction = minextent_fraction * scaled_max_tile_features / totalsize * 0.75;
|
||||
minextent_fraction = minextent_fraction * scaled_max_tile_features / estimated * 0.75;
|
||||
long long m = choose_minextent(extents, minextent_fraction, minextent);
|
||||
if (m != minextent) {
|
||||
minextent = m;
|
||||
@@ -2577,7 +2567,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
// The 95% is a guess to avoid too many retries
|
||||
// and probably actually varies based on how much duplicated metadata there is
|
||||
|
||||
mindrop_sequence_fraction = mindrop_sequence_fraction * scaled_max_tile_features / totalsize * 0.95;
|
||||
mindrop_sequence_fraction = mindrop_sequence_fraction * scaled_max_tile_features / estimated * 0.95;
|
||||
unsigned long long m = choose_mindrop_sequence(drop_sequences, mindrop_sequence_fraction, mindrop_sequence);
|
||||
if (m != mindrop_sequence) {
|
||||
mindrop_sequence = m;
|
||||
@@ -2614,7 +2604,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
// printf("%lld %zu\n", estimated_complexity, compressed.size());
|
||||
}
|
||||
|
||||
if (compressed.size() > scaled_max_tile_size && !prevent[P_KILOBYTE_LIMIT]) {
|
||||
if (too_many_bytes || (compressed.size() > scaled_max_tile_size && !prevent[P_KILOBYTE_LIMIT])) {
|
||||
// Estimate how big it really should have been compressed
|
||||
// from how many features were kept vs skipped for already being
|
||||
// over the threshold
|
||||
@@ -2670,21 +2660,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++;
|
||||
continue;
|
||||
}
|
||||
} else if (maxgap > 0 && (additional[A_DROP_SPARSEST_AS_NEEDED] || additional[A_COALESCE_SPARSEST_AS_NEEDED])) {
|
||||
maxgap_fraction = maxgap_fraction * scaled_max_tile_size / (kept_adjust * compressed.size()) * 0.80;
|
||||
unsigned long long m = choose_maxgap(gaps, maxgap_fraction, maxgap);
|
||||
if (m != maxgap) {
|
||||
maxgap = m;
|
||||
if (maxgap < arg->maxgap_out) {
|
||||
arg->maxgap_out = maxgap;
|
||||
arg->still_dropping = true;
|
||||
}
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Going to try keeping the densest %0.2f%% of the features to make it fit\n", maxgap_fraction * 100.0);
|
||||
}
|
||||
line_detail++;
|
||||
continue;
|
||||
}
|
||||
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
minextent_fraction = minextent_fraction * scaled_max_tile_size / (kept_adjust * compressed.size()) * 0.75;
|
||||
long long m = choose_minextent(extents, minextent_fraction, minextent);
|
||||
@@ -2726,6 +2701,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
exit(EXIT_PTHREAD);
|
||||
}
|
||||
|
||||
if (skipped > 0 || too_many_bytes || too_many_features) {
|
||||
fprintf(stderr, "Can't happen: writing tile even though we skipped\n");
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
if (outdb != NULL) {
|
||||
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
|
||||
} else if (outdir != NULL) {
|
||||
@@ -2854,7 +2834,7 @@ exit(EXIT_IMPOSSIBLE);
|
||||
skip_tile(&dc, &geompos, arg->compressed);
|
||||
len = 1;
|
||||
} else {
|
||||
len = write_tile(&dc, &geompos, arg->global_stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->outdb, arg->outdir, arg->buffer, arg->fname, arg->geomfile, arg->geompos, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps, arg->tiling_seg, arg->pass, arg->mingap, arg->maxgap, arg->minextent, arg->mindrop_sequence, arg->prefilter, arg->postfilter, arg->filter, arg, arg->strategy, arg->compressed, arg->shared_nodes_map, arg->nodepos, *(arg->shared_nodes_bloom), (*arg->unidecode_data), estimated_complexity, arg->skip_children_out);
|
||||
len = write_tile(&dc, &geompos, arg->global_stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->outdb, arg->outdir, arg->buffer, arg->fname, arg->geomfile, arg->geompos, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps, arg->tiling_seg, arg->pass, arg->mingap, arg->minextent, arg->mindrop_sequence, arg->prefilter, arg->postfilter, arg->filter, arg, arg->strategy, arg->compressed, arg->shared_nodes_map, arg->nodepos, *(arg->shared_nodes_bloom), (*arg->unidecode_data), estimated_complexity, arg->skip_children_out);
|
||||
}
|
||||
|
||||
if (pthread_mutex_lock(&var_lock) != 0) {
|
||||
@@ -3031,7 +3011,6 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
|
||||
double zoom_gamma = gamma;
|
||||
unsigned long long zoom_mingap = 0;
|
||||
unsigned long long zoom_maxgap = ULLONG_MAX;
|
||||
long long zoom_minextent = 0;
|
||||
unsigned long long zoom_mindrop_sequence = 0;
|
||||
size_t zoom_tile_size = 0;
|
||||
@@ -3065,9 +3044,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
args[thread].gamma = zoom_gamma;
|
||||
args[thread].gamma_out = zoom_gamma;
|
||||
args[thread].mingap = zoom_mingap;
|
||||
args[thread].maxgap = zoom_maxgap;
|
||||
args[thread].mingap_out = zoom_mingap;
|
||||
args[thread].maxgap_out = zoom_maxgap;
|
||||
args[thread].minextent = zoom_minextent;
|
||||
args[thread].minextent_out = zoom_minextent;
|
||||
args[thread].mindrop_sequence = zoom_mindrop_sequence;
|
||||
@@ -3150,10 +3127,6 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
zoom_mingap = args[thread].mingap_out;
|
||||
again = true;
|
||||
}
|
||||
if (args[thread].maxgap_out < zoom_maxgap) {
|
||||
zoom_maxgap = args[thread].maxgap_out;
|
||||
again = true;
|
||||
}
|
||||
if (args[thread].minextent_out > zoom_minextent) {
|
||||
zoom_minextent = args[thread].minextent_out;
|
||||
again = true;
|
||||
|
||||
Reference in New Issue
Block a user