mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-28 11:21:19 +01:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
114e7f2a28 | ||
|
|
f5e1bb46db | ||
|
|
83b4f386c8 | ||
|
|
fee56eaa51 | ||
|
|
0adcd22b95 | ||
|
|
4bdb8edda2 | ||
|
|
bc59c6ba84 | ||
|
|
1a38b43f49 | ||
|
|
c3fa99bc86 | ||
|
|
42c4426e32 |
@@ -1,3 +1,10 @@
|
||||
# 2.60.0
|
||||
|
||||
* Fix bad interaction between --retain-points-multiplier and stopping early when the tile feature limit is reached
|
||||
* Add optional BUILD_INFO string to version
|
||||
* Reorder overzoom logic to clip before dealing with multiplier and filters
|
||||
* When -generate-variable-depth-tile-pyramid is in use, report the actual highest zoom generated as tileset maxzoom
|
||||
|
||||
# 2.59.0
|
||||
|
||||
* Correct `antimeridian_adjusted_bounds` latitude calculation when vertices extend beyond the edge of the Mercator plane
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
PREFIX ?= /usr/local
|
||||
MANDIR ?= $(PREFIX)/share/man/man1/
|
||||
BUILDTYPE ?= Release
|
||||
BUILD_INFO ?=
|
||||
SHELL = /bin/sh
|
||||
|
||||
|
||||
# inherit from env if set
|
||||
CC := $(CC)
|
||||
CXX := $(CXX)
|
||||
CFLAGS := $(CFLAGS) -fPIE
|
||||
CXXFLAGS := $(CXXFLAGS) -std=c++17 -fPIE
|
||||
CFLAGS := $(CFLAGS) -fPIE -DBUILD_INFO=$(BUILD_INFO)
|
||||
CXXFLAGS := $(CXXFLAGS) -std=c++17 -fPIE -DBUILD_INFO=$(BUILD_INFO)
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
WARNING_FLAGS := -Wall -Wshadow -Wsign-compare -Wextra -Wunreachable-code -Wuninitialized -Wshadow
|
||||
RELEASE_FLAGS := -O3 -DNDEBUG
|
||||
|
||||
@@ -1188,37 +1188,6 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
static const std::string retain_points_multiplier_sequence = "tippecanoe:retain_points_multiplier_sequence";
|
||||
|
||||
for (auto feature : layer.features) {
|
||||
bool flush_multiplier_cluster = false;
|
||||
if (demultiply) {
|
||||
for (ssize_t i = feature.tags.size() - 2; i >= 0; i -= 2) {
|
||||
if (layer.keys[feature.tags[i]] == retain_points_multiplier_first) {
|
||||
mvt_value v = layer.values[feature.tags[i + 1]];
|
||||
if (v.type == mvt_bool && v.numeric_value.bool_value) {
|
||||
flush_multiplier_cluster = true;
|
||||
feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2);
|
||||
}
|
||||
} else if (i < (ssize_t) feature.tags.size() && layer.keys[feature.tags[i]] == retain_points_multiplier_sequence) {
|
||||
mvt_value v = layer.values[feature.tags[i + 1]];
|
||||
feature.seq = mvt_value_to_long_long(v);
|
||||
feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
flush_multiplier_cluster = true;
|
||||
}
|
||||
|
||||
if (flush_multiplier_cluster) {
|
||||
if (pending_tile_features.size() > 0) {
|
||||
feature_out(pending_tile_features, *outlayer, keep, attribute_accum, tile_stringpool);
|
||||
pending_tile_features.clear();
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> exclude_attributes;
|
||||
if (filter != NULL && !evaluate(feature, layer, filter, exclude_attributes, nz, unidecode_data)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
drawvec geom;
|
||||
int t = feature.type;
|
||||
|
||||
@@ -1268,6 +1237,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
|
||||
long long b = outtilesize * buffer / 256;
|
||||
if (xmax < -b || ymax < -b || xmin > outtilesize + b || ymin > outtilesize + b) {
|
||||
// quick exclusion by bounding box
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1281,6 +1251,42 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
}
|
||||
}
|
||||
|
||||
if (geom.size() == 0) {
|
||||
// clipped away
|
||||
continue;
|
||||
}
|
||||
|
||||
bool flush_multiplier_cluster = false;
|
||||
if (demultiply) {
|
||||
for (ssize_t i = feature.tags.size() - 2; i >= 0; i -= 2) {
|
||||
if (layer.keys[feature.tags[i]] == retain_points_multiplier_first) {
|
||||
mvt_value v = layer.values[feature.tags[i + 1]];
|
||||
if (v.type == mvt_bool && v.numeric_value.bool_value) {
|
||||
flush_multiplier_cluster = true;
|
||||
feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2);
|
||||
}
|
||||
} else if (i < (ssize_t) feature.tags.size() && layer.keys[feature.tags[i]] == retain_points_multiplier_sequence) {
|
||||
mvt_value v = layer.values[feature.tags[i + 1]];
|
||||
feature.seq = mvt_value_to_long_long(v);
|
||||
feature.tags.erase(feature.tags.begin() + i, feature.tags.begin() + i + 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
flush_multiplier_cluster = true;
|
||||
}
|
||||
|
||||
if (flush_multiplier_cluster) {
|
||||
if (pending_tile_features.size() > 0) {
|
||||
feature_out(pending_tile_features, *outlayer, keep, attribute_accum, tile_stringpool);
|
||||
pending_tile_features.clear();
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> exclude_attributes;
|
||||
if (filter != NULL && !evaluate(feature, layer, filter, exclude_attributes, nz, unidecode_data)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool still_need_simplification_after_reduction = false;
|
||||
if (t == VT_POLYGON && tiny_polygon_size > 0) {
|
||||
bool simplified_away_by_reduction = false;
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "tile.hpp"
|
||||
#include "pool.hpp"
|
||||
#include "projection.hpp"
|
||||
#include "version.hpp"
|
||||
#include "memfile.hpp"
|
||||
#include "main.hpp"
|
||||
#include "geojson.hpp"
|
||||
@@ -3113,11 +3112,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},
|
||||
|
||||
@@ -3610,7 +3607,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
case 'v':
|
||||
fprintf(stderr, "tippecanoe %s\n", VERSION);
|
||||
fprintf(stderr, "tippecanoe %s\n", version_str().c_str());
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'P':
|
||||
|
||||
+12
-1
@@ -654,6 +654,17 @@ static double sixdig(double val) {
|
||||
return std::round(val * 1e6) / 1e6;
|
||||
}
|
||||
|
||||
#define str(x) #x
|
||||
#define xstr(x) str(x)
|
||||
std::string version_str() {
|
||||
std::string s = VERSION;
|
||||
std::string build_info = xstr(BUILD_INFO);
|
||||
if (build_info.size() > 0) {
|
||||
s += " " + build_info;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double minlat2, double minlon2, double maxlat2, double maxlon2, double midlat, double midlon, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector<strategy> const &strategies, int basezoom, double droprate, int retain_points_multiplier) {
|
||||
metadata m;
|
||||
|
||||
@@ -684,7 +695,7 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
|
||||
m.attribution = attribution;
|
||||
}
|
||||
|
||||
m.generator = program + " " + VERSION;
|
||||
m.generator = program + " " + version_str();
|
||||
m.generator_options = commandline;
|
||||
|
||||
m.strategies_json = stringify_strategies(strategies);
|
||||
|
||||
@@ -77,5 +77,6 @@ std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::
|
||||
std::map<std::string, layermap_entry> merge_layermaps(std::vector<std::map<std::string, layermap_entry> > const &maps, bool trunc);
|
||||
|
||||
void add_to_tilestats(std::map<std::string, tilestat> &tilestats, std::string const &layername, serial_val const &val);
|
||||
std::string version_str();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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] ||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"name": "tests/loop/out/-z0_-O200_--cluster-densest-as-needed.json.check.mbtiles",
|
||||
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":201}]",
|
||||
"strategies": "[{\"coalesced_as_needed\":999,\"feature_count_desired\":1000}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"name": "tests/loop/out/-z0_-O200_--drop-densest-as-needed.json.check.mbtiles",
|
||||
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
|
||||
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"name": "tests/loop/out/-z0_-O200_--drop-fraction-as-needed.json.check.mbtiles",
|
||||
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":201}]",
|
||||
"strategies": "[{\"dropped_as_needed\":999,\"feature_count_desired\":1000}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
File diff suppressed because one or more lines are too long
+8958
-7768
File diff suppressed because it is too large
Load Diff
+3
-3
File diff suppressed because one or more lines are too long
@@ -1,14 +1,15 @@
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"antimeridian_adjusted_bounds": "0.000000,85.051129,0.000000,85.051129",
|
||||
"bounds": "-180.000000,85.051129,180.000000,85.051129",
|
||||
"center": "-179.989014,85.051129,14",
|
||||
"center": "0.000000,85.051129,0",
|
||||
"description": "tests/raw-tiles/nothing",
|
||||
"format": "pbf",
|
||||
"generator_options": "./tippecanoe -q -f -e tests/raw-tiles/nothing tests/raw-tiles/nothing.geojson",
|
||||
"json": "{\"vector_layers\":[{\"id\":\"nothing\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":14,\"fields\":{}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"nothing\",\"count\":1,\"geometry\":\"Point\",\"attributeCount\":0,\"attributes\":[]}]}}",
|
||||
"maxzoom": "14",
|
||||
"json": "{\"vector_layers\":[{\"id\":\"nothing\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":0,\"fields\":{}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"nothing\",\"count\":1,\"geometry\":\"Point\",\"attributeCount\":0,\"attributes\":[]}]}}",
|
||||
"maxzoom": "0",
|
||||
"minzoom": "0",
|
||||
"name": "tests/raw-tiles/nothing",
|
||||
"tippecanoe_decisions": "{\"basezoom\":14,\"droprate\":2.5,\"retain_points_multiplier\":1}",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
+4
-3
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;
|
||||
@@ -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++) {
|
||||
@@ -1878,9 +1867,9 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
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 (sf.gap < mingap) {
|
||||
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;
|
||||
@@ -1909,9 +1898,9 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
drop_rest = 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;
|
||||
@@ -2009,10 +1998,42 @@ 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])) {
|
||||
// There are two adjustments that we need to make
|
||||
// when determining if we have hit the feature count
|
||||
// or byte size limit:
|
||||
//
|
||||
// The max_tile_size and max_tile_features are inflated
|
||||
// to account for the number of multiplier clusters features
|
||||
// we are carrying around in addition to their lead features.
|
||||
|
||||
size_t adjusted_max_tile_size = max_tile_size;
|
||||
if (lead_features_count > 0) {
|
||||
adjusted_max_tile_size = adjusted_max_tile_size * (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
|
||||
}
|
||||
size_t adjusted_max_tile_features = max_tile_features;
|
||||
if (lead_features_count > 0) {
|
||||
adjusted_max_tile_features = adjusted_max_tile_features * (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
|
||||
}
|
||||
|
||||
// The number of features in the tile, meanwhile, is inflated
|
||||
// to account for the number of features that we have skipped over
|
||||
// because we were already over the limit, in addition to those
|
||||
// that we have actually added to the layer (as either lead or
|
||||
// multiplier features).
|
||||
|
||||
size_t adjusted_feature_count = lead_features_count + other_multiplier_cluster_features_count;
|
||||
if (kept > 0) {
|
||||
adjusted_feature_count = adjusted_feature_count * (skipped + kept) / kept;
|
||||
}
|
||||
|
||||
if (too_many_bytes || adjusted_feature_count > adjusted_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 || ((adjusted_feature_count > adjusted_max_tile_features) && !prevent[P_FEATURE_LIMIT])) {
|
||||
skipped++;
|
||||
too_many_features = true;
|
||||
} else {
|
||||
kept++;
|
||||
|
||||
@@ -2148,13 +2169,13 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
first_time = false;
|
||||
|
||||
// Adjust tile size limit based on the ratio of multiplier cluster features to lead features
|
||||
size_t scaled_max_tile_size = max_tile_size;
|
||||
size_t adjusted_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;
|
||||
adjusted_max_tile_size = adjusted_max_tile_size * (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
|
||||
}
|
||||
size_t scaled_max_tile_features = max_tile_features;
|
||||
size_t adjusted_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;
|
||||
adjusted_max_tile_features = adjusted_max_tile_features * (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
|
||||
}
|
||||
|
||||
// Operations on the features within each layer:
|
||||
@@ -2401,11 +2422,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
|
||||
mvt_tile tile;
|
||||
size_t totalsize = 0;
|
||||
size_t feature_count = 0;
|
||||
|
||||
for (auto layer_iterator = layers.begin(); layer_iterator != layers.end(); ++layer_iterator) {
|
||||
std::vector<serial_feature> &layer_features = layer_iterator->second.features;
|
||||
totalsize += layer_features.size();
|
||||
feature_count += layer_features.size();
|
||||
|
||||
mvt_layer layer;
|
||||
layer.name = layer_iterator->first;
|
||||
@@ -2496,14 +2517,23 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
continue;
|
||||
}
|
||||
|
||||
if (totalsize > 0 && tile.layers.size() > 0) {
|
||||
if (totalsize > scaled_max_tile_features && !prevent[P_FEATURE_LIMIT]) {
|
||||
if (totalsize > arg->feature_count_out) {
|
||||
arg->feature_count_out = totalsize;
|
||||
// Again, adjust the retabulated feature count to estimate
|
||||
// how many total features there would have been if we hadn't
|
||||
// hit the limit and started dropping early.
|
||||
|
||||
size_t adjusted_feature_count = feature_count;
|
||||
if (kept > 0) {
|
||||
adjusted_feature_count = adjusted_feature_count * (skipped + kept) / kept;
|
||||
}
|
||||
|
||||
if (adjusted_feature_count > 0 && tile.layers.size() > 0) {
|
||||
if (too_many_features || (adjusted_feature_count > adjusted_max_tile_features && !prevent[P_FEATURE_LIMIT])) {
|
||||
if (adjusted_feature_count > arg->feature_count_out) {
|
||||
arg->feature_count_out = adjusted_feature_count;
|
||||
}
|
||||
|
||||
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, feature_count, adjusted_feature_count, adjusted_max_tile_features);
|
||||
}
|
||||
|
||||
if (trying_to_stop_early && line_detail == first_detail) {
|
||||
@@ -2529,7 +2559,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 * adjusted_max_tile_features / adjusted_feature_count * 0.80;
|
||||
unsigned long long m = choose_mingap(gaps, mingap_fraction, mingap);
|
||||
if (m != mingap) {
|
||||
mingap = m;
|
||||
@@ -2543,23 +2573,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 * adjusted_max_tile_features / adjusted_feature_count * 0.75;
|
||||
long long m = choose_minextent(extents, minextent_fraction, minextent);
|
||||
if (m != minextent) {
|
||||
minextent = m;
|
||||
@@ -2573,11 +2588,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++;
|
||||
continue;
|
||||
}
|
||||
} else if (totalsize > layers.size() && (additional[A_DROP_FRACTION_AS_NEEDED] || additional[A_COALESCE_FRACTION_AS_NEEDED] || prevent[P_DYNAMIC_DROP])) {
|
||||
} 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
|
||||
// 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 * 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) {
|
||||
mindrop_sequence = m;
|
||||
@@ -2610,26 +2625,24 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
compressed = pbf;
|
||||
}
|
||||
|
||||
if (trying_to_stop_early && line_detail == first_detail) {
|
||||
// printf("%lld %zu\n", estimated_complexity, compressed.size());
|
||||
// And similarly, adjust the compressed byte size to estimate
|
||||
// what it would have been if we hadn't stopped dropping features early
|
||||
|
||||
size_t adjusted_tile_size = compressed.size();
|
||||
if (kept > 0) {
|
||||
adjusted_tile_size = adjusted_tile_size * (kept + skipped) / kept;
|
||||
}
|
||||
|
||||
if (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
|
||||
|
||||
double kept_adjust = (skipped + kept) / (double) kept;
|
||||
|
||||
if (compressed.size() > arg->tile_size_out) {
|
||||
arg->tile_size_out = compressed.size() * kept_adjust;
|
||||
if (too_many_bytes || (adjusted_tile_size > adjusted_max_tile_size && !prevent[P_KILOBYTE_LIMIT])) {
|
||||
if (adjusted_tile_size > arg->tile_size_out) {
|
||||
arg->tile_size_out = adjusted_tile_size;
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
if (skipped > 0) {
|
||||
fprintf(stderr, "tile %d/%u/%u size is %lld (probably really %lld) with detail %d, >%zu \n", z, tx, ty, (long long) compressed.size(), (long long) (compressed.size() * kept_adjust), line_detail, scaled_max_tile_size);
|
||||
if (adjusted_tile_size == compressed.size()) {
|
||||
fprintf(stderr, "tile %d/%u/%u size is %lld (probably really %zu) with detail %d, >%zu \n", z, tx, ty, (long long) compressed.size(), adjusted_tile_size, line_detail, adjusted_max_tile_size);
|
||||
} else {
|
||||
fprintf(stderr, "tile %d/%u/%u size is %lld with detail %d, >%zu \n", z, tx, ty, (long long) compressed.size(), line_detail, scaled_max_tile_size);
|
||||
fprintf(stderr, "tile %d/%u/%u size is %lld with detail %d, >%zu \n", z, tx, ty, (long long) compressed.size(), line_detail, adjusted_max_tile_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2656,7 +2669,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
|
||||
} 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_size / (kept_adjust * compressed.size()) * 0.80;
|
||||
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) {
|
||||
mingap = m;
|
||||
@@ -2670,23 +2683,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_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;
|
||||
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) {
|
||||
minextent = m;
|
||||
@@ -2700,8 +2698,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++;
|
||||
continue;
|
||||
}
|
||||
} else if (totalsize > layers.size() && (additional[A_DROP_FRACTION_AS_NEEDED] || additional[A_COALESCE_FRACTION_AS_NEEDED] || prevent[P_DYNAMIC_DROP])) {
|
||||
mindrop_sequence_fraction = mindrop_sequence_fraction * scaled_max_tile_size / (kept_adjust * compressed.size()) * 0.75;
|
||||
} 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) {
|
||||
mindrop_sequence = m;
|
||||
@@ -2726,6 +2724,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) {
|
||||
@@ -2846,7 +2849,6 @@ exit(EXIT_IMPOSSIBLE);
|
||||
dc.begin();
|
||||
}
|
||||
|
||||
arg->wrote_zoom = z;
|
||||
long long len;
|
||||
|
||||
struct zxy parent(z - 1, x / 2, y / 2);
|
||||
@@ -2854,7 +2856,8 @@ 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);
|
||||
arg->wrote_zoom = z;
|
||||
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) {
|
||||
@@ -2947,6 +2950,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
std::set<zxy> skip_children;
|
||||
|
||||
int z;
|
||||
int largest_written = -1;
|
||||
|
||||
for (z = iz; z <= maxzoom; z++) {
|
||||
std::atomic<long long> most(0);
|
||||
|
||||
@@ -3031,7 +3036,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 +3069,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 +3152,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;
|
||||
@@ -3173,6 +3171,9 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
if (args[thread].wrote_zoom > z) {
|
||||
z = args[thread].wrote_zoom;
|
||||
}
|
||||
if (args[thread].wrote_zoom > largest_written) {
|
||||
largest_written = args[thread].wrote_zoom;
|
||||
}
|
||||
|
||||
if (args[thread].still_dropping) {
|
||||
extend_zooms = true;
|
||||
@@ -3235,6 +3236,10 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
|
||||
}
|
||||
}
|
||||
|
||||
if (largest_written >= 0 && maxzoom > largest_written) {
|
||||
maxzoom = largest_written;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v2.59.0"
|
||||
#define VERSION "v2.60.0"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user