mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-28 11:21:19 +01:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b5e51815d | ||
|
|
aec0d2692b | ||
|
|
527a764b35 | ||
|
|
040b6388ab | ||
|
|
04d7de757b |
@@ -352,7 +352,7 @@ Parallel processing will also be automatic if the input file is in FlatGeobuf fo
|
||||
specified maximum zoom and to any levels added beyond that.
|
||||
* `--extend-zooms-if-still-dropping-maximum=`_count_: Increase the maxzoom if features are still being dropped at that zoom level
|
||||
by up to _count_ zoom levels.
|
||||
* `-at` or `--truncate-zooms`: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with `--extra-detail` detail and simplification. Tiles with point features below the basezoom or where any features have to be dropped dynamically, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles.
|
||||
* `-at` or `--truncate-zooms`: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail and no simplification. Tiles with point features below the basezoom or where any features have to be dropped dynamically, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles.
|
||||
* `-R` _zoom_`/`_x_`/`_y_ or `--one-tile=`_zoom_`/`_x_`/`_y_: Set the minzoom and maxzoom to _zoom_ and produce only
|
||||
the single specified tile at that zoom level.
|
||||
|
||||
|
||||
+1
-1
@@ -416,7 +416,7 @@ specified maximum zoom and to any levels added beyond that.
|
||||
\fB\fC\-\-extend\-zooms\-if\-still\-dropping\-maximum=\fR\fIcount\fP: Increase the maxzoom if features are still being dropped at that zoom level
|
||||
by up to \fIcount\fP zoom levels.
|
||||
.IP \(bu 2
|
||||
\fB\fC\-at\fR or \fB\fC\-\-truncate\-zooms\fR: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with \fB\fC\-\-extra\-detail\fR detail and simplification. Tiles with point features below the basezoom or where any features have to be dropped dynamically, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles.
|
||||
\fB\fC\-at\fR or \fB\fC\-\-truncate\-zooms\fR: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail and no simplification. Tiles with point features below the basezoom or where any features have to be dropped dynamically, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles.
|
||||
.IP \(bu 2
|
||||
\fB\fC\-R\fR \fIzoom\fP\fB\fC/\fR\fIx\fP\fB\fC/\fR\fIy\fP or \fB\fC\-\-one\-tile=\fR\fIzoom\fP\fB\fC/\fR\fIx\fP\fB\fC/\fR\fIy\fP: Set the minzoom and maxzoom to \fIzoom\fP and produce only
|
||||
the single specified tile at that zoom level.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "13",
|
||||
"minzoom": "11",
|
||||
"name": "tests/muni/out/-Z11_-z13_-M10000.json.check.mbtiles",
|
||||
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":18540,\"detail_reduced\":4,\"tile_size_desired\":10887},{\"dropped_by_rate\":6391,\"detail_reduced\":3,\"tile_size_desired\":10721},{}]",
|
||||
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":4080,\"detail_reduced\":4,\"tile_size_desired\":10887},{\"dropped_by_rate\":2974,\"detail_reduced\":3,\"tile_size_desired\":10721},{}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "13",
|
||||
"minzoom": "11",
|
||||
"name": "tests/muni/out/-Z11_-z13_-M10000_-aG.json.check.mbtiles",
|
||||
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":14925,\"dropped_by_gamma\":53,\"detail_reduced\":3,\"tile_size_desired\":10887},{\"dropped_by_rate\":6391,\"dropped_by_gamma\":190,\"detail_reduced\":3,\"tile_size_desired\":10721},{}]",
|
||||
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":4080,\"dropped_by_gamma\":17,\"detail_reduced\":3,\"tile_size_desired\":10887},{\"dropped_by_rate\":2974,\"dropped_by_gamma\":85,\"detail_reduced\":3,\"tile_size_desired\":10721},{}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "13",
|
||||
"minzoom": "11",
|
||||
"name": "tests/muni/out/-Z11_-z13_-M10000_-pd.json.check.mbtiles",
|
||||
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":7695,\"dropped_as_needed\":212,\"tile_size_desired\":10887},{\"dropped_by_rate\":4113,\"dropped_as_needed\":225,\"tile_size_desired\":10721},{}]",
|
||||
"strategies": "[{},{},{},{},{},{},{},{},{},{},{},{\"dropped_by_rate\":4080,\"dropped_as_needed\":212,\"tile_size_desired\":10887},{\"dropped_by_rate\":2974,\"dropped_as_needed\":225,\"tile_size_desired\":10721},{}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "5",
|
||||
"minzoom": "0",
|
||||
"name": "tests/ne_110m_admin_0_countries/out/-ae_-zg_-M5000_--force-feature-limit.json.check.mbtiles",
|
||||
"strategies": "[{\"dropped_as_needed\":324,\"tile_size_desired\":39239},{\"dropped_as_needed\":160,\"tiny_polygons\":2,\"tile_size_desired\":25163},{\"dropped_as_needed\":124,\"tiny_polygons\":2,\"tile_size_desired\":21214},{\"dropped_as_needed\":80,\"tile_size_desired\":10758},{\"dropped_as_needed\":12,\"tile_size_desired\":6601},{\"tiny_polygons\":2}]",
|
||||
"strategies": "[{\"dropped_as_needed\":165,\"tile_size_desired\":39239},{\"dropped_as_needed\":160,\"tiny_polygons\":1,\"tile_size_desired\":25163},{\"dropped_as_needed\":124,\"tiny_polygons\":1,\"tile_size_desired\":21214},{\"dropped_as_needed\":80,\"tile_size_desired\":10758},{\"dropped_as_needed\":12,\"tile_size_desired\":6601},{\"tiny_polygons\":2}]",
|
||||
"tippecanoe_decisions": "{\"basezoom\":0,\"droprate\":2.5,\"retain_points_multiplier\":1}",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "5",
|
||||
"minzoom": "0",
|
||||
"name": "tests/ne_110m_admin_0_countries/out/-z5_-M5000_--coalesce-densest-as-needed.json.check.mbtiles",
|
||||
"strategies": "[{\"coalesced_as_needed\":10005,\"tiny_polygons\":2,\"tile_size_desired\":39268},{\"coalesced_as_needed\":213,\"tile_size_desired\":25177},{\"coalesced_as_needed\":197,\"tile_size_desired\":21227},{\"coalesced_as_needed\":150,\"tile_size_desired\":10748},{\"coalesced_as_needed\":60,\"tile_size_desired\":6588},{\"tiny_polygons\":1}]",
|
||||
"strategies": "[{\"coalesced_as_needed\":175,\"tiny_polygons\":1,\"tile_size_desired\":39268},{\"coalesced_as_needed\":213,\"tile_size_desired\":25177},{\"coalesced_as_needed\":197,\"tile_size_desired\":21227},{\"coalesced_as_needed\":150,\"tile_size_desired\":10748},{\"coalesced_as_needed\":60,\"tile_size_desired\":6588},{\"tiny_polygons\":1}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "5",
|
||||
"minzoom": "0",
|
||||
"name": "tests/ne_110m_admin_0_countries/out/-z5_-M5000_--coalesce-fraction-as-needed.json.check.mbtiles",
|
||||
"strategies": "[{\"coalesced_as_needed\":528,\"detail_reduced\":2,\"tiny_polygons\":2,\"tile_size_desired\":39240},{\"coalesced_as_needed\":216,\"tile_size_desired\":25160},{\"coalesced_as_needed\":213,\"tile_size_desired\":21223},{\"coalesced_as_needed\":204,\"tile_size_desired\":10749},{\"coalesced_as_needed\":126,\"tile_size_desired\":6591},{\"tiny_polygons\":1}]",
|
||||
"strategies": "[{\"coalesced_as_needed\":176,\"detail_reduced\":2,\"tiny_polygons\":1,\"tile_size_desired\":39240},{\"coalesced_as_needed\":216,\"tile_size_desired\":25160},{\"coalesced_as_needed\":213,\"tile_size_desired\":21223},{\"coalesced_as_needed\":204,\"tile_size_desired\":10749},{\"coalesced_as_needed\":126,\"tile_size_desired\":6591},{\"tiny_polygons\":1}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "5",
|
||||
"minzoom": "0",
|
||||
"name": "tests/ne_110m_admin_0_countries/out/-z5_-M5000_--coalesce-smallest-as-needed.json.check.mbtiles",
|
||||
"strategies": "[{\"coalesced_as_needed\":7519,\"tiny_polygons\":2,\"tile_size_desired\":39240},{\"coalesced_as_needed\":442,\"tile_size_desired\":25160},{\"coalesced_as_needed\":214,\"tiny_polygons\":1,\"tile_size_desired\":21223},{\"coalesced_as_needed\":179,\"tile_size_desired\":10749},{\"coalesced_as_needed\":73,\"tile_size_desired\":6591},{\"tiny_polygons\":1}]",
|
||||
"strategies": "[{\"coalesced_as_needed\":175,\"tiny_polygons\":1,\"tile_size_desired\":39240},{\"coalesced_as_needed\":212,\"tile_size_desired\":25160},{\"coalesced_as_needed\":214,\"tiny_polygons\":1,\"tile_size_desired\":21223},{\"coalesced_as_needed\":179,\"tile_size_desired\":10749},{\"coalesced_as_needed\":73,\"tile_size_desired\":6591},{\"tiny_polygons\":1}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
Binary file not shown.
+1243
File diff suppressed because one or more lines are too long
@@ -437,27 +437,6 @@ static std::vector<serial_feature> disassemble_multiplier_clusters(std::vector<s
|
||||
return out;
|
||||
}
|
||||
|
||||
void prune_children(std::atomic<long long> *geompos, long long start_geompos[], compressor *geomfile[], size_t child_shards) {
|
||||
// printf("prune %zu\n", child_shards);
|
||||
for (size_t i = 0; i < child_shards; i++) {
|
||||
if (start_geompos[i] >= 0) {
|
||||
// printf("truncating %zu at %lld\n", i, start_geompos[i]);
|
||||
|
||||
if (fseek(geomfile[i]->fp, start_geompos[i], SEEK_SET) != 0) {
|
||||
fprintf(stderr, "Couldn't seek child tile output to %lld: %s\n", start_geompos[i], strerror(errno));
|
||||
exit(EXIT_WRITE);
|
||||
}
|
||||
|
||||
if (ftruncate(fileno(geomfile[i]->fp), start_geompos[i]) != 0) {
|
||||
fprintf(stderr, "Couldn't truncate child tile output to %lld: %s\n", start_geompos[i], strerror(errno));
|
||||
exit(EXIT_WRITE);
|
||||
}
|
||||
|
||||
geompos[i] = start_geompos[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write out copies of a feature into the temporary files for the next zoom level
|
||||
static void rewrite(serial_feature const &osf, int z, int nextzoom, int maxzoom, unsigned tx, unsigned ty, int buffer, std::atomic<bool> within[], std::atomic<long long> *geompos, long long start_geompos[], compressor *geomfile[], const char *fname, int child_shards, int max_zoom_increment, int segment, unsigned *initial_x, unsigned *initial_y) {
|
||||
if (osf.geometry.size() > 0 && (nextzoom <= maxzoom || additional[A_EXTEND_ZOOMS] || extend_zooms_max > 0)) {
|
||||
@@ -917,6 +896,8 @@ struct write_tile_args {
|
||||
bool compressed;
|
||||
node *shared_nodes_map;
|
||||
size_t nodepos;
|
||||
std::set<zxy> const *skip_children; // what is being skipped at this zoom
|
||||
std::set<zxy> skip_children_out; // what will be skipped in the next zoom
|
||||
};
|
||||
|
||||
// Clips a feature's geometry to the tile bounds at the specified zoom level
|
||||
@@ -1033,6 +1014,32 @@ struct multiplier_state {
|
||||
std::map<std::string, int> count;
|
||||
};
|
||||
|
||||
static bool skip_next_feature(decompressor *geoms, std::atomic<long long> *geompos_in, bool compressed) {
|
||||
long long len;
|
||||
|
||||
if (geoms->deserialize_long_long(&len, geompos_in) == 0) {
|
||||
fprintf(stderr, "Unexpected physical EOF in feature stream\n");
|
||||
exit(EXIT_READ);
|
||||
}
|
||||
if (len <= 0) {
|
||||
if (compressed) {
|
||||
geoms->end(geompos_in);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string s;
|
||||
s.resize(len);
|
||||
size_t n = geoms->fread((void *) s.c_str(), sizeof(char), s.size(), geompos_in);
|
||||
if (n != s.size()) {
|
||||
fprintf(stderr, "Short read (%zu for %zu) from geometry\n", n, s.size());
|
||||
exit(EXIT_READ);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This function is called repeatedly from write_tile() to retrieve the next feature
|
||||
// from the input stream. If the stream is at an end, it returns a feature with the
|
||||
// geometry type set to -2.
|
||||
@@ -1501,7 +1508,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, atomic_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, 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)) {
|
||||
@@ -1512,7 +1519,7 @@ bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features
|
||||
return false; // converted rather than dropped
|
||||
} else {
|
||||
preserve_attributes(attribute_accum, sf, layer.features[which_serial_feature]);
|
||||
strategy->dropped_as_needed++;
|
||||
strategy.dropped_as_needed++;
|
||||
drop_rest = true;
|
||||
return true; // dropped
|
||||
}
|
||||
@@ -1521,7 +1528,13 @@ bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features
|
||||
return false; // did not drop because nothing could be found to accumulate attributes onto
|
||||
}
|
||||
|
||||
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, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::vector<std::string> const &unidecode_data, long long estimated_complexity) {
|
||||
void skip_tile(decompressor *geoms, std::atomic<long long> *geompos_in, bool compressed_input) {
|
||||
while (skip_next_feature(geoms, geompos_in, compressed_input)) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
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::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 minextent_fraction = 1;
|
||||
@@ -1572,6 +1585,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
}
|
||||
|
||||
size_t detail_reduced = 0;
|
||||
bool first_time = true;
|
||||
// This only loops if the tile data didn't fit, in which case the detail
|
||||
// goes down and the progress indicator goes backward for the next try.
|
||||
@@ -1719,6 +1733,9 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
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;
|
||||
strategy.detail_reduced = detail_reduced;
|
||||
|
||||
for (size_t seq = 0;; seq++) {
|
||||
serial_feature sf;
|
||||
ssize_t which_serial_feature = -1;
|
||||
@@ -1787,7 +1804,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
|
||||
if (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_rate++;
|
||||
strategy.dropped_by_rate++;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
}
|
||||
@@ -1802,7 +1819,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
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++;
|
||||
strategy.dropped_by_gamma++;
|
||||
drop_rest = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
@@ -1830,7 +1847,7 @@ 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++;
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
@@ -1862,7 +1879,7 @@ 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++;
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
continue;
|
||||
}
|
||||
@@ -1873,7 +1890,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
features[which_serial_feature].coalesced = true;
|
||||
coalesced_area += sf.extent;
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy->coalesced_as_needed++;
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
@@ -1895,7 +1912,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
features[which_serial_feature].coalesced = true;
|
||||
coalesced_area += sf.extent;
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy->coalesced_as_needed++;
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
@@ -1916,7 +1933,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
coalesce_geometry(features[which_serial_feature], sf);
|
||||
features[which_serial_feature].coalesced = true;
|
||||
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
|
||||
strategy->coalesced_as_needed++;
|
||||
strategy.coalesced_as_needed++;
|
||||
drop_rest = true;
|
||||
can_stop_early = false;
|
||||
continue;
|
||||
@@ -1945,7 +1962,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
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);
|
||||
if (simplified_away_by_reduction) {
|
||||
strategy->tiny_polygons++;
|
||||
strategy.tiny_polygons++;
|
||||
}
|
||||
if (sf.geometry.size() == 0) {
|
||||
continue;
|
||||
@@ -2639,7 +2656,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
strategy->detail_reduced++;
|
||||
detail_reduced++;
|
||||
}
|
||||
} else {
|
||||
if (pthread_mutex_lock(&db_lock) != 0) {
|
||||
@@ -2662,12 +2679,14 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
// We succeeded in stopping early.
|
||||
// Prune the child tiles.
|
||||
|
||||
prune_children(geompos, start_geompos, geomfile, child_shards);
|
||||
skip_children_out.insert(zxy(z, tx, ty));
|
||||
}
|
||||
|
||||
strategy_out->add_from(strategy);
|
||||
return count;
|
||||
}
|
||||
} else {
|
||||
strategy_out->add_from(strategy);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -2747,10 +2766,15 @@ exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
arg->wrote_zoom = z;
|
||||
long long len;
|
||||
|
||||
// fprintf(stderr, "%d/%u/%u\n", z, x, y);
|
||||
|
||||
long long 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->unidecode_data), estimated_complexity);
|
||||
struct zxy parent(z - 1, x / 2, y / 2);
|
||||
if (arg->skip_children->count(parent) > 0) {
|
||||
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->minextent, arg->mindrop_sequence, arg->prefilter, arg->postfilter, arg->filter, arg, arg->strategy, arg->compressed, arg->shared_nodes_map, arg->nodepos, (*arg->unidecode_data), estimated_complexity, arg->skip_children_out);
|
||||
}
|
||||
|
||||
if (pthread_mutex_lock(&var_lock) != 0) {
|
||||
perror("pthread_mutex_lock");
|
||||
@@ -2839,6 +2863,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
}
|
||||
}
|
||||
|
||||
std::set<zxy> skip_children;
|
||||
|
||||
int z;
|
||||
for (z = iz; z <= maxzoom; z++) {
|
||||
std::atomic<long long> most(0);
|
||||
@@ -2957,6 +2983,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
unsigned long long zoom_mindrop_sequence = 0;
|
||||
size_t zoom_tile_size = 0;
|
||||
size_t zoom_feature_count = 0;
|
||||
std::set<zxy> skip_children_out;
|
||||
|
||||
for (size_t pass = 0;; pass++) {
|
||||
pthread_t pthreads[threads];
|
||||
@@ -2965,6 +2992,7 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
std::atomic<int> running(threads);
|
||||
std::atomic<long long> along(0);
|
||||
atomic_strategy strategy;
|
||||
skip_children_out.clear();
|
||||
|
||||
for (size_t thread = 0; thread < threads; thread++) {
|
||||
args[thread].global_stringpool = global_stringpool;
|
||||
@@ -3028,6 +3056,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
args[thread].compressed = (z != iz);
|
||||
args[thread].shared_nodes_map = shared_nodes_map;
|
||||
args[thread].nodepos = nodepos;
|
||||
args[thread].skip_children = &skip_children;
|
||||
args[thread].skip_children_out.clear();
|
||||
|
||||
if (thread_create(&pthreads[thread], NULL, run_thread, &args[thread]) != 0) {
|
||||
perror("pthread_create");
|
||||
@@ -3048,6 +3078,10 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
err = *((int *) retval);
|
||||
}
|
||||
|
||||
for (auto const &zxy : args[thread].skip_children_out) {
|
||||
skip_children_out.insert(zxy);
|
||||
}
|
||||
|
||||
if (args[thread].gamma_out > zoom_gamma) {
|
||||
zoom_gamma = args[thread].gamma_out;
|
||||
again = true;
|
||||
@@ -3106,6 +3140,9 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
}
|
||||
}
|
||||
|
||||
skip_children = std::move(skip_children_out);
|
||||
skip_children_out.clear();
|
||||
|
||||
for (size_t j = 0; j < TEMP_FILES; j++) {
|
||||
// Can be < 0 if there is only one source file, at z0
|
||||
if (geomfd[j] >= 0) {
|
||||
@@ -3149,3 +3186,12 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
}
|
||||
return maxzoom;
|
||||
}
|
||||
|
||||
void atomic_strategy::add_from(struct strategy const &src) {
|
||||
dropped_by_rate += src.dropped_by_rate;
|
||||
dropped_by_gamma += src.dropped_by_gamma;
|
||||
dropped_as_needed += src.dropped_as_needed;
|
||||
coalesced_as_needed += src.coalesced_as_needed;
|
||||
detail_reduced += src.detail_reduced;
|
||||
tiny_polygons += src.tiny_polygons;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ struct atomic_strategy {
|
||||
detail_reduced(0),
|
||||
tiny_polygons(0) {
|
||||
}
|
||||
|
||||
void add_from(struct strategy const &src);
|
||||
};
|
||||
|
||||
struct strategy {
|
||||
@@ -35,9 +37,10 @@ struct strategy {
|
||||
size_t dropped_as_needed = 0;
|
||||
size_t coalesced_as_needed = 0;
|
||||
size_t detail_reduced = 0;
|
||||
size_t tiny_polygons = 0;
|
||||
|
||||
size_t tile_size = 0;
|
||||
size_t feature_count = 0;
|
||||
size_t tiny_polygons = 0;
|
||||
|
||||
strategy(const atomic_strategy &s, size_t ts, size_t fc) {
|
||||
dropped_by_rate = s.dropped_by_rate;
|
||||
|
||||
Reference in New Issue
Block a user