mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-29 03:41:18 +01:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f8c7b8268 | ||
|
|
5d01a067aa | ||
|
|
355cc31d5b | ||
|
|
9d00c92ff2 | ||
|
|
a3d9301dfe | ||
|
|
285d1931af | ||
|
|
260d404466 | ||
|
|
752204fc94 | ||
|
|
0ce1271b06 | ||
|
|
ebcc8bf799 | ||
|
|
16c71ff756 | ||
|
|
b9b48f42c9 |
@@ -1,12 +1,3 @@
|
||||
# 2.78.0
|
||||
|
||||
* Fix potential infinite loops in as-needed dropping and coalescing. When the threshold cannot be increased,
|
||||
it is now an error, rather than falling back to trying to lower the detail.
|
||||
|
||||
# 2.77.0
|
||||
|
||||
* Add --deduplicate-by-id option to tippecanoe-overzoom
|
||||
|
||||
# 2.76.0
|
||||
|
||||
* Add missing case for accumulating the mean of attributes that are inconsistently present
|
||||
|
||||
@@ -443,16 +443,6 @@ overzoom-test: tippecanoe-overzoom
|
||||
./tippecanoe-overzoom -o tests/pbf/squirrels-13-2413-3077-clip.pbf --clip-polygon-file tests/pbf/squirrels-clip.json tests/pbf/squirrels-13-2413-3077.pbf 13/2413/3077 13/2413/3077
|
||||
cmp tests/pbf/squirrels-13-2413-3077-clip.pbf /dev/null # clipped away
|
||||
rm tests/pbf/squirrels-13-2413-3077-clip.pbf
|
||||
# Deduplication by feature ID
|
||||
./tippecanoe -z0 -f -e tests/pbf/1.json.dir -l layer tests/pbf/1.json
|
||||
./tippecanoe -z0 -f -e tests/pbf/2.json.dir -l layer tests/pbf/2.json
|
||||
./tippecanoe-overzoom -o tests/pbf/merged-nodedup.pbf -t 0/0/0 tests/pbf/1.json.dir/0/0/0.pbf 0/0/0 tests/pbf/2.json.dir/0/0/0.pbf 0/0/0
|
||||
./tippecanoe-decode tests/pbf/merged-nodedup.pbf 0 0 0 > tests/pbf/merged-nodedup.pbf.json.check
|
||||
cmp tests/pbf/merged-nodedup.pbf.json.check tests/pbf/merged-nodedup.pbf.json
|
||||
./tippecanoe-overzoom --deduplicate-by-id -o tests/pbf/merged-dedup.pbf -t 0/0/0 tests/pbf/1.json.dir/0/0/0.pbf 0/0/0 tests/pbf/2.json.dir/0/0/0.pbf 0/0/0
|
||||
./tippecanoe-decode tests/pbf/merged-dedup.pbf 0 0 0 > tests/pbf/merged-dedup.pbf.json.check
|
||||
cmp tests/pbf/merged-dedup.pbf.json.check tests/pbf/merged-dedup.pbf.json
|
||||
rm -r tests/pbf/1.json.dir tests/pbf/2.json.dir tests/pbf/merged-nodedup.pbf tests/pbf/merged-nodedup.pbf.json.check tests/pbf/merged-dedup.pbf.json.check
|
||||
|
||||
join-test: tippecanoe tippecanoe-decode tile-join
|
||||
./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}'
|
||||
|
||||
@@ -1269,8 +1269,7 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
|
||||
double tiny_polygon_size,
|
||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||
std::string const &accumulate_numeric, size_t feature_limit,
|
||||
std::vector<clipbbox> const &clipbboxes,
|
||||
bool deduplicate_by_id) {
|
||||
std::vector<clipbbox> const &clipbboxes) {
|
||||
std::vector<source_tile> decoded;
|
||||
|
||||
for (auto const &t : tiles) {
|
||||
@@ -1296,7 +1295,7 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
|
||||
decoded.push_back(out);
|
||||
}
|
||||
|
||||
return overzoom(decoded, nz, nx, ny, detail_or_unspecified, buffer, keep, exclude, exclude_prefix, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, feature_limit, clipbboxes, deduplicate_by_id);
|
||||
return overzoom(decoded, nz, nx, ny, detail_or_unspecified, buffer, keep, exclude, exclude_prefix, do_compress, next_overzoomed_tiles, demultiply, filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, feature_limit, clipbboxes);
|
||||
}
|
||||
|
||||
// like a minimal serial_feature, but with mvt_feature-style attributes
|
||||
@@ -1500,8 +1499,7 @@ static bool feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
|
||||
std::unordered_map<std::string, attribute_op> const &attribute_accum,
|
||||
std::string const &accumulate_numeric,
|
||||
key_pool &key_pool, int buffer, bool include_nonaggregate,
|
||||
std::vector<clipbbox> const &clipbboxes, int nz, int nx, int ny,
|
||||
std::set<unsigned long long> *deduplicate_ids) {
|
||||
std::vector<clipbbox> const &clipbboxes, int nz, int nx, int ny) {
|
||||
// Add geometry to output feature
|
||||
|
||||
drawvec geom = features[0].geom;
|
||||
@@ -1584,14 +1582,6 @@ static bool feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
|
||||
|
||||
// ID and attributes, if it didn't get clipped away
|
||||
|
||||
if (features[0].has_id && deduplicate_ids != NULL) {
|
||||
if (deduplicate_ids->find(features[0].id) != deduplicate_ids->end()) {
|
||||
outfeature.geometry.clear();
|
||||
} else {
|
||||
deduplicate_ids->insert(features[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
if (outfeature.geometry.size() > 0) {
|
||||
if (features[0].has_id) {
|
||||
outfeature.has_id = true;
|
||||
@@ -1684,7 +1674,7 @@ static bool feature_out(std::vector<tile_feature> const &features, mvt_layer &ou
|
||||
}
|
||||
}
|
||||
|
||||
outlayer.features.push_back(std::move(outfeature));
|
||||
outlayer.features.push_back(std::make_shared<mvt_feature>(outfeature));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1695,6 +1685,9 @@ static struct preservecmp {
|
||||
bool operator()(const mvt_feature &a, const mvt_feature &b) {
|
||||
return a.seq < b.seq;
|
||||
}
|
||||
bool operator()(const std::shared_ptr<mvt_feature> &a, const std::shared_ptr<mvt_feature> &b) {
|
||||
return a->seq < b->seq;
|
||||
}
|
||||
} preservecmp;
|
||||
|
||||
struct index_event {
|
||||
@@ -1820,49 +1813,10 @@ mvt_tile assign_to_bins(mvt_tile &features,
|
||||
std::set<std::string> exclude,
|
||||
std::vector<std::string> exclude_prefix,
|
||||
int buffer, std::vector<clipbbox> const &clipbboxes) {
|
||||
std::vector<index_event> events;
|
||||
key_pool key_pool;
|
||||
|
||||
if (bins.size() == 0) {
|
||||
return mvt_tile();
|
||||
}
|
||||
|
||||
// Index bins
|
||||
for (size_t i = 0; i < bins.size(); i++) {
|
||||
for (size_t j = 0; j < bins[i].features.size(); j++) {
|
||||
long long xmin, ymin, xmax, ymax;
|
||||
unsigned long long start, end;
|
||||
|
||||
get_bbox(bins[i].features[j].geometry, &xmin, &ymin, &xmax, &ymax, z, x, y, bins[i].detail());
|
||||
get_quadkey_bounds(xmin, ymin, xmax, ymax, &start, &end);
|
||||
events.emplace_back(start, index_event::ENTER, i, j, xmin, ymin, xmax, ymax);
|
||||
events.emplace_back(end, index_event::EXIT, i, j, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
std::map<unsigned long long, std::pair<size_t, size_t>> fid_to_feature;
|
||||
|
||||
// Index points
|
||||
for (size_t i = 0; i < features.layers.size(); i++) {
|
||||
for (size_t j = 0; j < features.layers[i].features.size(); j++) {
|
||||
long long xmin, ymin, xmax, ymax;
|
||||
unsigned long long start, end;
|
||||
|
||||
if (features.layers[i].features[j].geometry.size() > 0) {
|
||||
if (features.layers[i].features[j].has_id) {
|
||||
fid_to_feature.emplace(features.layers[i].features[j].id, std::make_pair(i, j));
|
||||
}
|
||||
|
||||
get_bbox(features.layers[i].features[j].geometry, &xmin, &ymin, &xmax, &ymax, z, x, y, features.layers[i].detail());
|
||||
get_quadkey_bounds(xmin, ymin, xmax, ymax, &start, &end);
|
||||
events.emplace_back(start, index_event::CHECK, i, j, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(events.begin(), events.end());
|
||||
std::set<active_bin> active;
|
||||
|
||||
mvt_layer outlayer;
|
||||
outlayer.extent = bins[0].extent;
|
||||
outlayer.version = 2;
|
||||
@@ -1870,40 +1824,43 @@ mvt_tile assign_to_bins(mvt_tile &features,
|
||||
|
||||
std::vector<std::vector<tile_feature>> outfeatures;
|
||||
|
||||
for (auto &e : events) {
|
||||
if (e.kind == index_event::ENTER) {
|
||||
active_bin a(e.layer, e.feature);
|
||||
a.xmin = e.xmin;
|
||||
a.ymin = e.ymin;
|
||||
a.xmax = e.xmax;
|
||||
a.ymax = e.ymax;
|
||||
|
||||
const mvt_feature &bin = bins[e.layer].features[e.feature];
|
||||
|
||||
{
|
||||
tile_feature outfeature;
|
||||
for (auto const &g : bin.geometry) {
|
||||
outfeature.geom.emplace_back(g.op, g.x, g.y);
|
||||
if (bin_by_id_list.size() > 0) {
|
||||
std::map<unsigned long long, std::pair<size_t, size_t>> fid_to_feature;
|
||||
for (size_t i = 0; i < features.layers.size(); i++) {
|
||||
for (size_t j = 0; j < features.layers[i].features.size(); j++) {
|
||||
if (features.layers[i].features[j]->geometry.size() > 0) {
|
||||
if (features.layers[i].features[j]->has_id) {
|
||||
fid_to_feature.emplace(features.layers[i].features[j]->id, std::make_pair(i, j));
|
||||
}
|
||||
}
|
||||
outfeature.t = bin.type;
|
||||
outfeature.has_id = bin.has_id;
|
||||
outfeature.id = bin.id;
|
||||
outfeature.tags = bin.tags;
|
||||
outfeature.layer = &bins[e.layer];
|
||||
outfeature.seq = e.feature;
|
||||
|
||||
a.outfeature = outfeatures.size();
|
||||
outfeatures.push_back({std::move(outfeature)});
|
||||
}
|
||||
}
|
||||
|
||||
if (bin_by_id_list.size() > 0) {
|
||||
for (size_t k = 0; k < bin.tags.size(); k += 2) {
|
||||
if (bins[e.layer].keys[bin.tags[k]] == bin_by_id_list) {
|
||||
std::vector<size_t> ids = parse_ids_string(bins[e.layer].values[bin.tags[k + 1]]);
|
||||
for (auto &binlayer : bins) {
|
||||
size_t seq = 0;
|
||||
for (auto &bin : binlayer.features) {
|
||||
{
|
||||
tile_feature outfeature;
|
||||
for (auto const &g : bin->geometry) {
|
||||
outfeature.geom.emplace_back(g.op, g.x, g.y);
|
||||
}
|
||||
outfeature.t = bin->type;
|
||||
outfeature.has_id = bin->has_id;
|
||||
outfeature.id = bin->id;
|
||||
outfeature.tags = bin->tags;
|
||||
outfeature.layer = &binlayer;
|
||||
outfeature.seq = seq++;
|
||||
|
||||
outfeatures.push_back({std::move(outfeature)});
|
||||
}
|
||||
|
||||
for (size_t k = 0; k < bin->tags.size(); k += 2) {
|
||||
if (binlayer.keys[bin->tags[k]] == bin_by_id_list) {
|
||||
std::vector<size_t> ids = parse_ids_string(binlayer.values[bin->tags[k + 1]]);
|
||||
for (auto &id : ids) {
|
||||
auto f = fid_to_feature.find(id);
|
||||
if (f != fid_to_feature.end()) {
|
||||
mvt_feature &feature = features.layers[f->second.first].features[f->second.second];
|
||||
mvt_feature &feature = *features.layers[f->second.first].features[f->second.second];
|
||||
if (feature.geometry.size() > 0) {
|
||||
tile_feature outfeature;
|
||||
for (auto const &g : feature.geometry) {
|
||||
@@ -1914,8 +1871,8 @@ mvt_tile assign_to_bins(mvt_tile &features,
|
||||
outfeature.has_id = feature.has_id;
|
||||
outfeature.id = feature.id;
|
||||
outfeature.tags = feature.tags;
|
||||
outfeature.layer = &features.layers[e.layer];
|
||||
outfeature.seq = e.feature;
|
||||
outfeature.layer = &features.layers[f->second.first];
|
||||
outfeature.seq = f->second.second;
|
||||
outfeatures.back().push_back(std::move(outfeature));
|
||||
}
|
||||
}
|
||||
@@ -1924,67 +1881,128 @@ mvt_tile assign_to_bins(mvt_tile &features,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::vector<index_event> events;
|
||||
|
||||
active.insert(std::move(a));
|
||||
} else if (e.kind == index_event::CHECK) {
|
||||
if (bin_by_id_list.size() > 0) {
|
||||
continue; // only bin by id, not geometrically
|
||||
// Index bins
|
||||
for (size_t i = 0; i < bins.size(); i++) {
|
||||
for (size_t j = 0; j < bins[i].features.size(); j++) {
|
||||
long long xmin, ymin, xmax, ymax;
|
||||
unsigned long long start, end;
|
||||
|
||||
get_bbox(bins[i].features[j]->geometry, &xmin, &ymin, &xmax, &ymax, z, x, y, bins[i].detail());
|
||||
get_quadkey_bounds(xmin, ymin, xmax, ymax, &start, &end);
|
||||
events.emplace_back(start, index_event::ENTER, i, j, xmin, ymin, xmax, ymax);
|
||||
events.emplace_back(end, index_event::EXIT, i, j, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
auto const &feature = features.layers[e.layer].features[e.feature];
|
||||
// Index points
|
||||
for (size_t i = 0; i < features.layers.size(); i++) {
|
||||
for (size_t j = 0; j < features.layers[i].features.size(); j++) {
|
||||
long long xmin, ymin, xmax, ymax;
|
||||
unsigned long long start, end;
|
||||
|
||||
if (feature.geometry.size() == 0) {
|
||||
// already assigned by ID
|
||||
continue;
|
||||
if (features.layers[i].features[j]->geometry.size() > 0) {
|
||||
get_bbox(features.layers[i].features[j]->geometry, &xmin, &ymin, &xmax, &ymax, z, x, y, features.layers[i].detail());
|
||||
get_quadkey_bounds(xmin, ymin, xmax, ymax, &start, &end);
|
||||
events.emplace_back(start, index_event::CHECK, i, j, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we can't find a real match,
|
||||
// assign points to the most nearby bin
|
||||
ssize_t which_outfeature = outfeatures.size() - 1;
|
||||
std::sort(events.begin(), events.end());
|
||||
std::set<active_bin> active;
|
||||
|
||||
for (auto const &a : active) {
|
||||
auto const &bin = bins[a.layer].features[a.feature];
|
||||
for (auto &e : events) {
|
||||
if (e.kind == index_event::ENTER) {
|
||||
active_bin a(e.layer, e.feature);
|
||||
a.xmin = e.xmin;
|
||||
a.ymin = e.ymin;
|
||||
a.xmax = e.xmax;
|
||||
a.ymax = e.ymax;
|
||||
|
||||
if (bbox_intersects(e.xmin, e.ymin, e.xmax, e.ymax,
|
||||
a.xmin, a.ymin, a.xmax, a.ymax)) {
|
||||
if (pnpoly_mp(bin.geometry, feature.geometry[0].x, feature.geometry[0].y)) {
|
||||
which_outfeature = a.outfeature;
|
||||
break;
|
||||
const mvt_feature &bin = *bins[e.layer].features[e.feature];
|
||||
|
||||
{
|
||||
tile_feature outfeature;
|
||||
for (auto const &g : bin.geometry) {
|
||||
outfeature.geom.emplace_back(g.op, g.x, g.y);
|
||||
}
|
||||
outfeature.t = bin.type;
|
||||
outfeature.has_id = bin.has_id;
|
||||
outfeature.id = bin.id;
|
||||
outfeature.tags = bin.tags;
|
||||
outfeature.layer = &bins[e.layer];
|
||||
outfeature.seq = e.feature;
|
||||
|
||||
a.outfeature = outfeatures.size();
|
||||
outfeatures.push_back({std::move(outfeature)});
|
||||
}
|
||||
|
||||
active.insert(std::move(a));
|
||||
} else if (e.kind == index_event::CHECK) {
|
||||
if (bin_by_id_list.size() > 0) {
|
||||
continue; // only bin by id, not geometrically
|
||||
}
|
||||
|
||||
auto const &feature = *features.layers[e.layer].features[e.feature];
|
||||
|
||||
if (feature.geometry.size() == 0) {
|
||||
// already assigned by ID
|
||||
continue;
|
||||
}
|
||||
|
||||
// if we can't find a real match,
|
||||
// assign points to the most nearby bin
|
||||
ssize_t which_outfeature = outfeatures.size() - 1;
|
||||
|
||||
for (auto const &a : active) {
|
||||
auto const &bin = *bins[a.layer].features[a.feature];
|
||||
|
||||
if (bbox_intersects(e.xmin, e.ymin, e.xmax, e.ymax,
|
||||
a.xmin, a.ymin, a.xmax, a.ymax)) {
|
||||
if (pnpoly_mp(bin.geometry, feature.geometry[0].x, feature.geometry[0].y)) {
|
||||
which_outfeature = a.outfeature;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (which_outfeature >= 0) {
|
||||
tile_feature outfeature;
|
||||
for (auto const &g : feature.geometry) {
|
||||
outfeature.geom.emplace_back(g.op, g.x, g.y);
|
||||
if (which_outfeature >= 0) {
|
||||
tile_feature outfeature;
|
||||
for (auto const &g : feature.geometry) {
|
||||
outfeature.geom.emplace_back(g.op, g.x, g.y);
|
||||
}
|
||||
outfeature.t = feature.type;
|
||||
outfeature.has_id = feature.has_id;
|
||||
outfeature.id = feature.id;
|
||||
outfeature.tags = feature.tags;
|
||||
outfeature.layer = &features.layers[e.layer];
|
||||
outfeature.seq = e.feature;
|
||||
outfeatures[which_outfeature].push_back(std::move(outfeature));
|
||||
}
|
||||
} else /* EXIT */ {
|
||||
auto const &found = active.find({e.layer, e.feature});
|
||||
if (found != active.end()) {
|
||||
active.erase(found);
|
||||
} else {
|
||||
fprintf(stderr, "event mismatch: can't happen\n");
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
outfeature.t = feature.type;
|
||||
outfeature.has_id = feature.has_id;
|
||||
outfeature.id = feature.id;
|
||||
outfeature.tags = feature.tags;
|
||||
outfeature.layer = &features.layers[e.layer];
|
||||
outfeature.seq = e.feature;
|
||||
outfeatures[which_outfeature].push_back(std::move(outfeature));
|
||||
}
|
||||
} else /* EXIT */ {
|
||||
auto const &found = active.find({e.layer, e.feature});
|
||||
if (found != active.end()) {
|
||||
active.erase(found);
|
||||
} else {
|
||||
fprintf(stderr, "event mismatch: can't happen\n");
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
key_pool key_pool;
|
||||
for (size_t i = 0; i < outfeatures.size(); i++) {
|
||||
if (outfeatures[i].size() > 1) {
|
||||
if (feature_out(outfeatures[i], outlayer,
|
||||
keep, exclude, exclude_prefix, attribute_accum,
|
||||
accumulate_numeric, key_pool, buffer, true,
|
||||
clipbboxes, z, x, y, NULL)) {
|
||||
mvt_feature &nfeature = outlayer.features.back();
|
||||
clipbboxes, z, x, y)) {
|
||||
mvt_feature &nfeature = *outlayer.features.back();
|
||||
mvt_value val;
|
||||
val.type = mvt_uint;
|
||||
val.numeric_value.uint_value = outfeatures[i].size() - 1;
|
||||
@@ -2020,14 +2038,10 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
double tiny_polygon_size,
|
||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||
std::string const &accumulate_numeric, size_t feature_limit,
|
||||
std::vector<clipbbox> const &clipbboxes,
|
||||
bool deduplicate_by_id) {
|
||||
std::vector<clipbbox> const &clipbboxes) {
|
||||
mvt_tile outtile;
|
||||
key_pool key_pool;
|
||||
|
||||
// map from layer name to ids used in that layer
|
||||
std::map<std::string, std::set<unsigned long long>> deduplicate_ids;
|
||||
|
||||
for (auto const &tile : tiles) {
|
||||
for (auto const &layer : tile.tile.layers) {
|
||||
mvt_layer *outlayer = NULL;
|
||||
@@ -2054,23 +2068,14 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
outlayer = &outtile.layers.back();
|
||||
}
|
||||
|
||||
std::set<unsigned long long> *deduplicate_by_id_set = NULL;
|
||||
if (deduplicate_by_id) {
|
||||
auto layer_deduplicate_ids = deduplicate_ids.find(layer.name);
|
||||
if (layer_deduplicate_ids == deduplicate_ids.end()) {
|
||||
deduplicate_ids.emplace(layer.name, std::set<unsigned long long>());
|
||||
layer_deduplicate_ids = deduplicate_ids.find(layer.name);
|
||||
}
|
||||
deduplicate_by_id_set = &layer_deduplicate_ids->second;
|
||||
}
|
||||
|
||||
std::vector<tile_feature> pending_tile_features;
|
||||
double accum_area = 0;
|
||||
|
||||
static const std::string retain_points_multiplier_first = "tippecanoe:retain_points_multiplier_first";
|
||||
static const std::string retain_points_multiplier_sequence = "tippecanoe:retain_points_multiplier_sequence";
|
||||
|
||||
for (auto feature : layer.features) {
|
||||
for (auto feature_ref : layer.features) {
|
||||
auto feature = *feature_ref; // this needs to be a copy, because tile-join still needs the original unmutated
|
||||
drawvec geom;
|
||||
int t = feature.type;
|
||||
|
||||
@@ -2185,7 +2190,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
|
||||
if (flush_multiplier_cluster) {
|
||||
if (pending_tile_features.size() > 0) {
|
||||
feature_out(pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, accumulate_numeric, key_pool, -1, bins.size() == 0, std::vector<clipbbox>(), nz, nx, ny, deduplicate_by_id_set);
|
||||
feature_out(pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, accumulate_numeric, key_pool, -1, bins.size() == 0, std::vector<clipbbox>(), nz, nx, ny);
|
||||
if (outlayer->features.size() >= feature_limit) {
|
||||
break;
|
||||
}
|
||||
@@ -2245,7 +2250,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
}
|
||||
|
||||
if (pending_tile_features.size() > 0) {
|
||||
feature_out(pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, accumulate_numeric, key_pool, -1, bins.size() == 0, std::vector<clipbbox>(), nz, nx, ny, deduplicate_by_id_set);
|
||||
feature_out(pending_tile_features, *outlayer, keep, exclude, exclude_prefix, attribute_accum, accumulate_numeric, key_pool, -1, bins.size() == 0, std::vector<clipbbox>(), nz, nx, ny);
|
||||
pending_tile_features.clear();
|
||||
if (outlayer->features.size() >= feature_limit) {
|
||||
break;
|
||||
@@ -2285,7 +2290,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
detail_or_unspecified, buffer, keep, exclude, exclude_prefix, false, NULL,
|
||||
demultiply, filter, preserve_input_order, attribute_accum, unidecode_data,
|
||||
simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric,
|
||||
1, clipbboxes, deduplicate_by_id);
|
||||
1, clipbboxes);
|
||||
if (child.size() > 0) {
|
||||
next_overzoomed_tiles->emplace_back(nx * 2 + x, ny * 2 + y);
|
||||
}
|
||||
@@ -2469,26 +2474,3 @@ drawvec fix_polygon(const drawvec &geom, bool use_winding, bool reverse_winding)
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool line_is_too_small(drawvec const &geometry, int z, int detail) {
|
||||
if (geometry.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
long long x = 0, y = 0;
|
||||
for (auto &g : geometry) {
|
||||
if (g.op == VT_MOVETO) {
|
||||
x = std::llround((double) g.x / (1LL << (32 - detail - z)));
|
||||
y = std::llround((double) g.y / (1LL << (32 - detail - z)));
|
||||
} else {
|
||||
long long xx = std::llround((double) g.x / (1LL << (32 - detail - z)));
|
||||
long long yy = std::llround((double) g.y / (1LL << (32 - detail - z)));
|
||||
|
||||
if (xx != x || yy != y) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
-3
@@ -60,11 +60,11 @@ void do_stats(mvt_tile &tile, size_t size, bool compressed, int z, unsigned x, u
|
||||
|
||||
size_t points = 0, lines = 0, polygons = 0;
|
||||
for (size_t j = 0; j < tile.layers[i].features.size(); j++) {
|
||||
if (tile.layers[i].features[j].type == mvt_point) {
|
||||
if (tile.layers[i].features[j]->type == mvt_point) {
|
||||
points++;
|
||||
} else if (tile.layers[i].features[j].type == mvt_linestring) {
|
||||
} else if (tile.layers[i].features[j]->type == mvt_linestring) {
|
||||
lines++;
|
||||
} else if (tile.layers[i].features[j].type == mvt_polygon) {
|
||||
} else if (tile.layers[i].features[j]->type == mvt_polygon) {
|
||||
polygons++;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -944,12 +944,10 @@ drawvec polygon_to_anchor(const drawvec &geom) {
|
||||
return drawvec();
|
||||
}
|
||||
|
||||
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, unsigned long long label_point) {
|
||||
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, unsigned wx, unsigned wy) {
|
||||
drawvec out;
|
||||
|
||||
// anchor point in world coordinates
|
||||
unsigned wx, wy;
|
||||
decode_index(label_point, &wx, &wy);
|
||||
// wx,wy is anchor point in world coordinates
|
||||
|
||||
// upper left of tile in world coordinates
|
||||
long long tx1 = 0, ty1 = 0;
|
||||
|
||||
+3
-6
@@ -89,7 +89,7 @@ void check_polygon(drawvec &geom);
|
||||
double get_area(const drawvec &geom, size_t i, size_t j);
|
||||
double get_mp_area(drawvec &geom);
|
||||
drawvec polygon_to_anchor(const drawvec &geom);
|
||||
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, unsigned long long label_point);
|
||||
drawvec checkerboard_anchors(drawvec const &geom, int tx, int ty, int z, unsigned label_x, unsigned label_y);
|
||||
|
||||
drawvec simple_clip_poly(drawvec &geom, int z, int buffer, drawvec &shared_nodes, bool prevent_simplify_shared_nodes);
|
||||
drawvec simple_clip_poly(drawvec &geom, long long x1, long long y1, long long x2, long long y2, bool prevent_simplify_shared_nodes);
|
||||
@@ -147,8 +147,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
double tiny_polygon_size,
|
||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||
std::string const &accumulate_numeric, size_t feature_limit,
|
||||
std::vector<clipbbox> const &clipbboxes,
|
||||
bool deduplicate_by_id);
|
||||
std::vector<clipbbox> const &clipbboxes);
|
||||
|
||||
std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int ny,
|
||||
int detail, int buffer,
|
||||
@@ -163,8 +162,7 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
|
||||
double tiny_polygon_size,
|
||||
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
|
||||
std::string const &accumulate_numeric, size_t feature_limit,
|
||||
std::vector<clipbbox> const &clipbboxes,
|
||||
bool deduplicate_by_id);
|
||||
std::vector<clipbbox> const &clipbboxes);
|
||||
|
||||
draw center_of_mass_mp(const drawvec &dv);
|
||||
|
||||
@@ -172,6 +170,5 @@ void get_quadkey_bounds(long long xmin, long long ymin, long long xmax, long lon
|
||||
unsigned long long *start, unsigned long long *end);
|
||||
|
||||
clipbbox parse_clip_poly(std::string arg);
|
||||
bool line_is_too_small(drawvec const &geometry, int z, int detail);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -94,11 +94,13 @@ unsigned int drop_denser = 0;
|
||||
std::map<std::string, serial_val> set_attributes;
|
||||
unsigned long long preserve_point_density_threshold = 0;
|
||||
unsigned long long preserve_multiplier_density_threshold = 0;
|
||||
std::vector<int> preserve_multiplier_density_bits_by_zoom;
|
||||
long long extend_zooms_max = 0;
|
||||
int retain_points_multiplier = 1;
|
||||
std::vector<std::string> unidecode_data;
|
||||
size_t maximum_string_attribute_length = 0;
|
||||
std::string accumulate_numeric;
|
||||
std::string use_h3_index;
|
||||
|
||||
std::vector<order_field> order_by;
|
||||
bool order_reverse;
|
||||
@@ -2498,6 +2500,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
long long ip;
|
||||
for (ip = 0; ip < indices; ip++) {
|
||||
unsigned xx, yy;
|
||||
// XXX this will behave oddly if the index is actually H3
|
||||
decode_index(map[ip].ix, &xx, &yy);
|
||||
|
||||
long long nprogress = 100 * ip / indices;
|
||||
@@ -3087,6 +3090,7 @@ int main(int argc, char **argv) {
|
||||
{"cluster-maxzoom", required_argument, 0, 'k'},
|
||||
{"preserve-point-density-threshold", required_argument, 0, '~'},
|
||||
{"preserve-multiplier-density-threshold", required_argument, 0, '~'},
|
||||
{"preserve-multiplier-density-bits-by-zoom", required_argument, 0, '~'},
|
||||
|
||||
{"Dropping or merging a fraction of features to keep under tile size limits", 0, 0, 0},
|
||||
{"drop-densest-as-needed", no_argument, &additional[A_DROP_DENSEST_AS_NEEDED], 1},
|
||||
@@ -3129,6 +3133,7 @@ int main(int argc, char **argv) {
|
||||
{"coalesce", no_argument, &additional[A_COALESCE], 1},
|
||||
{"reverse", no_argument, &additional[A_REVERSE], 1},
|
||||
{"hilbert", no_argument, &additional[A_HILBERT], 1},
|
||||
{"use-h3-index", required_argument, 0, '~'},
|
||||
{"order-by", required_argument, 0, '~'},
|
||||
{"order-descending-by", required_argument, 0, '~'},
|
||||
{"order-smallest-first", no_argument, 0, '~'},
|
||||
@@ -3270,6 +3275,8 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "%s: --extra-detail can be at most 30\n", argv[0]);
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
} else if (strcmp(opt, "use-h3-index") == 0) {
|
||||
use_h3_index = optarg;
|
||||
} else if (strcmp(opt, "order-by") == 0) {
|
||||
order_by.push_back(order_field(optarg, false));
|
||||
} else if (strcmp(opt, "order-descending-by") == 0) {
|
||||
@@ -3301,6 +3308,21 @@ int main(int argc, char **argv) {
|
||||
preserve_point_density_threshold = atoll_require(optarg, "Preserve point density threshold");
|
||||
} else if (strcmp(opt, "preserve-multiplier-density-threshold") == 0) {
|
||||
preserve_multiplier_density_threshold = atoll_require(optarg, "Preserve multiplier density threshold");
|
||||
} else if (strcmp(opt, "preserve-multiplier-density-bits-by-zoom") == 0) {
|
||||
const char *cp = optarg;
|
||||
while (*cp != '\0') {
|
||||
if (!isdigit(*cp)) {
|
||||
fprintf(stderr, "%s: unexpected multiplier density bits by zoom %s\n", argv[0], cp);
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
preserve_multiplier_density_bits_by_zoom.push_back(atoi(cp));
|
||||
while (isdigit(*cp)) {
|
||||
cp++;
|
||||
}
|
||||
if (*cp == ',') {
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(opt, "extend-zooms-if-still-dropping-maximum") == 0) {
|
||||
extend_zooms_max = atoll_require(optarg, "Maximum number by which to extend zooms");
|
||||
} else if (strcmp(opt, "retain-points-multiplier") == 0) {
|
||||
|
||||
@@ -53,7 +53,9 @@ extern long long extend_zooms_max;
|
||||
extern int retain_points_multiplier;
|
||||
extern size_t maximum_string_attribute_length;
|
||||
extern std::string accumulate_numeric;
|
||||
extern std::string use_h3_index;
|
||||
extern unsigned long long preserve_multiplier_density_threshold;
|
||||
extern std::vector<int> preserve_multiplier_density_bits_by_zoom;
|
||||
|
||||
struct order_field {
|
||||
std::string name;
|
||||
|
||||
@@ -278,7 +278,7 @@ bool mvt_tile::decode(const std::string &message, bool &was_compressed) {
|
||||
}
|
||||
}
|
||||
|
||||
layer.features.push_back(std::move(feature));
|
||||
layer.features.push_back(std::make_shared<mvt_feature>(feature));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -407,16 +407,16 @@ std::string mvt_tile::encode() {
|
||||
std::string feature_string;
|
||||
protozero::pbf_writer feature_writer(feature_string);
|
||||
|
||||
feature_writer.add_enum(3, layers[i].features[f].type);
|
||||
feature_writer.add_enum(3, layers[i].features[f]->type);
|
||||
|
||||
std::vector<unsigned> sorted_tags = layers[i].features[f].tags;
|
||||
std::vector<unsigned> sorted_tags = layers[i].features[f]->tags;
|
||||
for (size_t v = 1; v < sorted_tags.size(); v += 2) {
|
||||
sorted_tags[v] = mapping[sorted_tags[v]];
|
||||
}
|
||||
feature_writer.add_packed_uint32(2, std::begin(sorted_tags), std::end(sorted_tags));
|
||||
|
||||
if (layers[i].features[f].has_id) {
|
||||
feature_writer.add_uint64(1, layers[i].features[f].id);
|
||||
if (layers[i].features[f]->has_id) {
|
||||
feature_writer.add_uint64(1, layers[i].features[f]->id);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> geometry;
|
||||
@@ -426,7 +426,7 @@ std::string mvt_tile::encode() {
|
||||
int cmd = -1;
|
||||
int length = 0;
|
||||
|
||||
std::vector<mvt_geometry> &geom = layers[i].features[f].geometry;
|
||||
std::vector<mvt_geometry> &geom = layers[i].features[f]->geometry;
|
||||
|
||||
for (size_t g = 0; g < geom.size(); g++) {
|
||||
int op = geom[g].op;
|
||||
|
||||
@@ -204,7 +204,7 @@ struct std::hash<mvt_value> {
|
||||
struct mvt_layer {
|
||||
int version = 0;
|
||||
std::string name = "";
|
||||
std::vector<mvt_feature> features{};
|
||||
std::vector<std::shared_ptr<mvt_feature>> features{};
|
||||
std::vector<std::string> keys{};
|
||||
std::vector<mvt_value> values{};
|
||||
long long extent = 0;
|
||||
|
||||
+1
-8
@@ -19,7 +19,6 @@ int detail = 12; // tippecanoe-style: mvt extent == 1 << detail
|
||||
int buffer = 5; // tippecanoe-style: mvt buffer == extent * buffer / 256;
|
||||
bool demultiply = false;
|
||||
bool do_compress = true;
|
||||
bool deduplicate_by_id = false;
|
||||
|
||||
std::string filter;
|
||||
bool preserve_input_order = false;
|
||||
@@ -95,7 +94,6 @@ int main(int argc, char **argv) {
|
||||
{"clip-bounding-box", required_argument, 0, 'k' & 0x1F},
|
||||
{"clip-polygon", required_argument, 0, 'l' & 0x1F},
|
||||
{"clip-polygon-file", required_argument, 0, 'm' & 0x1F},
|
||||
{"deduplicate-by-id", no_argument, 0, 'i' & 0x1F},
|
||||
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
@@ -215,11 +213,6 @@ int main(int argc, char **argv) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'i' & 0x1F: {
|
||||
deduplicate_by_id = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unrecognized flag -%c\n", i);
|
||||
usage(argv);
|
||||
@@ -361,7 +354,7 @@ int main(int argc, char **argv) {
|
||||
its.push_back(std::move(t));
|
||||
}
|
||||
|
||||
out = overzoom(its, nz, nx, ny, detail, buffer, keep, exclude, exclude_prefix, do_compress, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, SIZE_MAX, clipbboxes, deduplicate_by_id);
|
||||
out = overzoom(its, nz, nx, ny, detail, buffer, keep, exclude, exclude_prefix, do_compress, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins, bin_by_id_list, accumulate_numeric, SIZE_MAX, clipbboxes);
|
||||
}
|
||||
|
||||
FILE *f = fopen(outfile, "wb");
|
||||
|
||||
+6
-6
@@ -119,17 +119,17 @@ std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::
|
||||
}
|
||||
|
||||
for (auto const &feature : layer.features) {
|
||||
if (feature.type == mvt_point) {
|
||||
if (feature->type == mvt_point) {
|
||||
ts->second.points++;
|
||||
} else if (feature.type == mvt_linestring) {
|
||||
} else if (feature->type == mvt_linestring) {
|
||||
ts->second.lines++;
|
||||
} else if (feature.type == mvt_polygon) {
|
||||
} else if (feature->type == mvt_polygon) {
|
||||
ts->second.polygons++;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i + 1 < feature.tags.size(); i += 2) {
|
||||
const std::string &key = layer.keys[feature.tags[i]];
|
||||
const mvt_value &val = layer.values[feature.tags[i + 1]];
|
||||
for (size_t i = 0; i + 1 < feature->tags.size(); i += 2) {
|
||||
const std::string &key = layer.keys[feature->tags[i]];
|
||||
const mvt_value &val = layer.values[feature->tags[i + 1]];
|
||||
|
||||
// Nulls can be excluded here because this is the postfilter
|
||||
// and it is nearly time to create the vector representation
|
||||
|
||||
+1
-1
@@ -398,7 +398,7 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
|
||||
}
|
||||
}
|
||||
|
||||
l->second.features.push_back(feature);
|
||||
l->second.features.push_back(std::make_shared<mvt_feature>(feature));
|
||||
}
|
||||
|
||||
json_free(j);
|
||||
|
||||
+31
-6
@@ -186,7 +186,7 @@ std::string serialize_feature(serial_feature *sf, long long wx, long long wy) {
|
||||
|
||||
long long layer = 0;
|
||||
layer |= sf->layer << FLAG_LAYER;
|
||||
layer |= (sf->label_point != 0) << FLAG_LABEL_POINT;
|
||||
layer |= ((sf->label_x | sf->label_y) != 0) << FLAG_LABEL_POINT;
|
||||
layer |= (sf->index != 0) << FLAG_INDEX;
|
||||
layer |= (sf->extent != 0) << FLAG_EXTENT;
|
||||
layer |= sf->has_id << FLAG_ID;
|
||||
@@ -211,10 +211,13 @@ std::string serialize_feature(serial_feature *sf, long long wx, long long wy) {
|
||||
|
||||
if (sf->index != 0) {
|
||||
serialize_ulong_long(s, sf->index);
|
||||
serialize_uint(s, sf->wx);
|
||||
serialize_uint(s, sf->wy);
|
||||
serialize_ulong_long(s, sf->gap);
|
||||
}
|
||||
if (sf->label_point != 0) {
|
||||
serialize_ulong_long(s, sf->label_point);
|
||||
if ((sf->label_x | sf->label_y) != 0) {
|
||||
serialize_uint(s, sf->label_x);
|
||||
serialize_uint(s, sf->label_y);
|
||||
}
|
||||
if (sf->extent != 0) {
|
||||
serialize_long_long(s, sf->extent);
|
||||
@@ -261,17 +264,21 @@ serial_feature deserialize_feature(std::string const &geoms, unsigned z, unsigne
|
||||
|
||||
sf.index = 0;
|
||||
sf.gap = 0;
|
||||
sf.label_point = 0;
|
||||
sf.label_x = 0;
|
||||
sf.label_y = 0;
|
||||
sf.extent = 0;
|
||||
|
||||
sf.geometry = decode_geometry(&cp, z, tx, ty, sf.bbox, initial_x[sf.segment], initial_y[sf.segment]);
|
||||
|
||||
if (sf.layer & (1 << FLAG_INDEX)) {
|
||||
deserialize_ulong_long(&cp, &sf.index);
|
||||
deserialize_uint(&cp, &sf.wx);
|
||||
deserialize_uint(&cp, &sf.wy);
|
||||
deserialize_ulong_long(&cp, &sf.gap);
|
||||
}
|
||||
if (sf.layer & (1 << FLAG_LABEL_POINT)) {
|
||||
deserialize_ulong_long(&cp, &sf.label_point);
|
||||
deserialize_uint(&cp, &sf.label_x);
|
||||
deserialize_uint(&cp, &sf.label_y);
|
||||
}
|
||||
if (sf.layer & (1 << FLAG_EXTENT)) {
|
||||
deserialize_long_long(&cp, &sf.extent);
|
||||
@@ -714,6 +721,19 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
|
||||
}
|
||||
|
||||
bbox_index = encode_index(midx, midy);
|
||||
|
||||
if (use_h3_index.size() > 0) {
|
||||
for (size_t i = 0; i < sf.full_keys.size(); i++) {
|
||||
if (*(sf.full_keys[i]) == use_h3_index) {
|
||||
unsigned long long h3_index = atoll(sf.full_values[i].s.c_str());
|
||||
// the top 52 bits of the feature index are the H3 index;
|
||||
// the bottom 12 bits are retained from what otherwise would have been the index.
|
||||
bbox_index = ((h3_index & ((1LL << 52) - 1)) << 12) | (bbox_index & ((1 << 12) - 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (additional[A_CALCULATE_INDEX]) {
|
||||
sf.full_keys.push_back(key_pool.pool("tippecanoe:index"));
|
||||
|
||||
@@ -728,7 +748,8 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
|
||||
if (dv.size() > 0) {
|
||||
dv[0].x = SHIFT_LEFT(dv[0].x) & ((1LL << 32) - 1);
|
||||
dv[0].y = SHIFT_LEFT(dv[0].y) & ((1LL << 32) - 1);
|
||||
sf.label_point = encode_index(dv[0].x, dv[0].y);
|
||||
sf.label_x = dv[0].x;
|
||||
sf.label_y = dv[0].y;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,8 +769,12 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
|
||||
preserve_multiplier_density_threshold > 0 ||
|
||||
cluster_distance != 0) {
|
||||
sf.index = bbox_index;
|
||||
sf.wx = midx;
|
||||
sf.wy = midy;
|
||||
} else {
|
||||
sf.index = 0;
|
||||
sf.wx = 0;
|
||||
sf.wy = 0;
|
||||
}
|
||||
|
||||
if (sst->layermap->count(layername) == 0) {
|
||||
|
||||
+6
-1
@@ -58,6 +58,10 @@ struct serial_val {
|
||||
s = milo::dtoa_milo(val);
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
return s;
|
||||
}
|
||||
|
||||
double to_double() const {
|
||||
return atof(s.c_str());
|
||||
}
|
||||
@@ -118,8 +122,9 @@ struct serial_feature {
|
||||
|
||||
drawvec geometry = drawvec();
|
||||
unsigned long long index = 0;
|
||||
unsigned wx = 0, wy = 0;
|
||||
unsigned long long gap = 0; // filled in during z0. square of planar distance
|
||||
unsigned long long label_point = 0;
|
||||
unsigned label_x = 0, label_y = 0;
|
||||
long long extent = 0;
|
||||
|
||||
// These fields are not directly serialized, but are used
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+8320
File diff suppressed because one or more lines are too long
+105
-521
File diff suppressed because one or more lines are too long
+96
-516
File diff suppressed because one or more lines are too long
@@ -1,3 +0,0 @@
|
||||
{"type":"Feature","properties":{"what":"no id"},"geometry":{"type":"Point","coordinates":[0,0]}}
|
||||
{"type":"Feature","id":12345,"properties":{"what":"will survive"},"geometry":{"type":"Point","coordinates":[0,0]}}
|
||||
{"type":"Feature","id":12346,"properties":{"what":"will win over the duplicate"},"geometry":{"type":"Point","coordinates":[0,0]}}
|
||||
@@ -1,3 +0,0 @@
|
||||
{"type":"Feature","properties":{"what":"no id again"},"geometry":{"type":"Point","coordinates":[0,0]}}
|
||||
{"type":"Feature","id":12346,"properties":{"what":"will be lost as a duplicate"},"geometry":{"type":"Point","coordinates":[0,0]}}
|
||||
{"type":"Feature","id":12347,"properties":{"what":"will be added"},"geometry":{"type":"Point","coordinates":[0,0]}}
|
||||
@@ -1,13 +0,0 @@
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "layer", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "what": "no id" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12345, "properties": { "what": "will survive" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12346, "properties": { "what": "will win over the duplicate" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "what": "no id again" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12347, "properties": { "what": "will be added" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
] }
|
||||
] }
|
||||
@@ -1,15 +0,0 @@
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "layer", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "what": "no id" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12345, "properties": { "what": "will survive" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12346, "properties": { "what": "will win over the duplicate" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "what": "no id again" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12346, "properties": { "what": "will be lost as a duplicate" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12347, "properties": { "what": "will be added" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
] }
|
||||
] }
|
||||
+7
-7
@@ -243,9 +243,9 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
// scaling up is safe while scaling down requires geometry cleaning.
|
||||
|
||||
for (size_t i = 0; i < outlayer.features.size(); i++) {
|
||||
for (size_t j = 0; j < outlayer.features[i].geometry.size(); j++) {
|
||||
outlayer.features[i].geometry[j].x = outlayer.features[i].geometry[j].x * layer.extent / outlayer.extent;
|
||||
outlayer.features[i].geometry[j].y = outlayer.features[i].geometry[j].y * layer.extent / outlayer.extent;
|
||||
for (size_t j = 0; j < outlayer.features[i]->geometry.size(); j++) {
|
||||
outlayer.features[i]->geometry[j].x = outlayer.features[i]->geometry[j].x * layer.extent / outlayer.extent;
|
||||
outlayer.features[i]->geometry[j].y = outlayer.features[i]->geometry[j].y * layer.extent / outlayer.extent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
join_keys.resize(layer.features.size());
|
||||
|
||||
for (size_t f = 0; f < layer.features.size(); f++) {
|
||||
mvt_feature &feat = layer.features[f];
|
||||
mvt_feature &feat = *layer.features[f];
|
||||
join_keys[f].type = mvt_no_such_key;
|
||||
|
||||
for (size_t t = 0; t + 1 < feat.tags.size(); t += 2) {
|
||||
@@ -289,7 +289,7 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
bool features_added_to_layer = false;
|
||||
|
||||
for (size_t f = 0; f < layer.features.size(); f++) {
|
||||
mvt_feature &feat = layer.features[f];
|
||||
mvt_feature &feat = *layer.features[f];
|
||||
|
||||
std::set<std::string> exclude_attributes;
|
||||
if (filter != NULL && !evaluate(feat, layer, filter, exclude_attributes, z, unidecode_data)) {
|
||||
@@ -520,7 +520,7 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
|
||||
features_added++;
|
||||
features_added_to_layer = true;
|
||||
outlayer.features.push_back(outfeature);
|
||||
outlayer.features.push_back(std::make_shared<mvt_feature>(outfeature));
|
||||
|
||||
if (z < tilestats->second.minzoom) {
|
||||
tilestats->second.minzoom = z;
|
||||
@@ -982,7 +982,7 @@ struct tileset_reader {
|
||||
false, &next_overzoomed_tiles, false, NULL, false,
|
||||
std::unordered_map<std::string, attribute_op>(), unidecode_data, 0, 0,
|
||||
std::vector<mvt_layer>(), "", "", SIZE_MAX,
|
||||
std::vector<clipbbox>(), false);
|
||||
std::vector<clipbbox>());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ struct ordercmp {
|
||||
static std::vector<std::vector<std::shared_ptr<serial_feature>>> assemble_multiplier_clusters(std::vector<std::shared_ptr<serial_feature>> const &features) {
|
||||
std::vector<std::vector<std::shared_ptr<serial_feature>>> clusters;
|
||||
|
||||
if (retain_points_multiplier == 1) {
|
||||
if (!(retain_points_multiplier > 1 || preserve_multiplier_density_threshold != 0 || preserve_multiplier_density_bits_by_zoom.size() > 0)) {
|
||||
for (auto const &feature : features) {
|
||||
std::vector<std::shared_ptr<serial_feature>> cluster;
|
||||
cluster.push_back(std::move(feature));
|
||||
@@ -676,9 +676,7 @@ static void *simplification_worker(void *v) {
|
||||
|
||||
for (size_t i = a->task; i < (*features).size(); i += a->tasks) {
|
||||
double area = 0;
|
||||
if (a->trying_to_stop_early) {
|
||||
area = get_mp_area((*features)[i]->geometry);
|
||||
} else {
|
||||
if (!a->trying_to_stop_early) {
|
||||
area = simplify_feature(&*((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos, *(a->shared_nodes_bloom));
|
||||
}
|
||||
|
||||
@@ -703,13 +701,8 @@ static void *simplification_worker(void *v) {
|
||||
}
|
||||
|
||||
if (geom.size() < 3) {
|
||||
if (area > 0 && !additional[A_GRID_LOW_ZOOMS]) {
|
||||
if (area > 0) {
|
||||
// area is in world coordinates, calculated before scaling down
|
||||
//
|
||||
// Don't revive if we are gridding low zooms, because
|
||||
// the expectation there is that only the features that
|
||||
// happen to span integer divisions of the tile grid
|
||||
// will survive
|
||||
geom = revive_polygon(before, area, z, out_detail);
|
||||
} else {
|
||||
geom.clear();
|
||||
@@ -719,19 +712,15 @@ static void *simplification_worker(void *v) {
|
||||
}
|
||||
}
|
||||
|
||||
if (t == VT_POLYGON && additional[A_GENERATE_POLYGON_LABEL_POINTS]) {
|
||||
t = (*features)[i]->t = VT_POINT;
|
||||
geom = checkerboard_anchors(from_tile_scale(geom, z, out_detail), (*features)[i]->tx, (*features)[i]->ty, z, (*features)[i]->label_x, (*features)[i]->label_y);
|
||||
to_tile_scale(geom, z, out_detail);
|
||||
}
|
||||
|
||||
if ((*features)[i]->index == 0) {
|
||||
(*features)[i]->index = i;
|
||||
}
|
||||
#if 0
|
||||
if (geom.size() == 0 && !additional[A_GRID_LOW_ZOOMS]) {
|
||||
fprintf(stderr, "simplified away to nothing\n");
|
||||
for (auto const &g : geom) {
|
||||
fprintf(stderr, "(%d)%lld,%lld ", g.op, g.x, g.y);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
(*features)[i]->geometry = std::move(geom);
|
||||
}
|
||||
|
||||
@@ -780,7 +769,7 @@ static unsigned long long choose_mingap(std::vector<unsigned long long> &gaps, d
|
||||
std::stable_sort(gaps.begin(), gaps.end());
|
||||
|
||||
size_t ix = (gaps.size() - 1) * (1 - f);
|
||||
while (ix + 1 < gaps.size() && gaps[ix] <= existing_gap) {
|
||||
while (ix + 1 < gaps.size() && gaps[ix] == existing_gap) {
|
||||
ix++;
|
||||
}
|
||||
|
||||
@@ -820,7 +809,7 @@ static long long choose_minextent(std::vector<long long> &extents, double f, lon
|
||||
std::stable_sort(extents.begin(), extents.end());
|
||||
|
||||
size_t ix = (extents.size() - 1) * (1 - f);
|
||||
while (ix + 1 < extents.size() && extents[ix] <= existing_extent) {
|
||||
while (ix + 1 < extents.size() && extents[ix] == existing_extent) {
|
||||
ix++;
|
||||
}
|
||||
|
||||
@@ -835,7 +824,7 @@ static unsigned long long choose_mindrop_sequence(std::vector<unsigned long long
|
||||
std::stable_sort(drop_sequences.begin(), drop_sequences.end());
|
||||
|
||||
size_t ix = (drop_sequences.size() - 1) * (1 - f);
|
||||
while (ix + 1 < drop_sequences.size() && drop_sequences[ix] <= existing_drop_sequence) {
|
||||
while (ix + 1 < drop_sequences.size() && drop_sequences[ix] == existing_drop_sequence) {
|
||||
ix++;
|
||||
}
|
||||
|
||||
@@ -1070,6 +1059,7 @@ static bool skip_next_feature(decompressor *geoms, std::atomic<long long> *geomp
|
||||
|
||||
struct next_feature_state {
|
||||
unsigned long long previndex = 0;
|
||||
unsigned prevx = 0, prevy = 0;
|
||||
unsigned long long prev_not_dropped_index = 0;
|
||||
};
|
||||
|
||||
@@ -1139,9 +1129,11 @@ static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *
|
||||
long long ox = (1LL << (32 - z)) * tx;
|
||||
long long oy = (1LL << (32 - z)) * ty;
|
||||
|
||||
unsigned wx1, wy1;
|
||||
decode_index(next_feature_state.previndex, &wx1, &wy1);
|
||||
unsigned wx1 = next_feature_state.prevx;
|
||||
unsigned wy1 = next_feature_state.prevy;
|
||||
|
||||
// find the furthest distance of a vertex in this feature
|
||||
// from the representative point of the previous feature
|
||||
for (auto const &g : sf.geometry) {
|
||||
long long dx = (long long) wx1 - (g.x + ox);
|
||||
long long dy = (long long) wy1 - (g.y + oy);
|
||||
@@ -1154,6 +1146,8 @@ static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *
|
||||
}
|
||||
}
|
||||
next_feature_state.previndex = sf.index;
|
||||
next_feature_state.prevx = sf.wx;
|
||||
next_feature_state.prevy = sf.wy;
|
||||
|
||||
if (clip_to_tile(sf, z, buffer)) {
|
||||
continue;
|
||||
@@ -1261,6 +1255,11 @@ static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *
|
||||
} else if (preserve_multiplier_density_threshold > 0 &&
|
||||
sf.index - next_feature_state.prev_not_dropped_index > ((1LL << (32 - z)) / preserve_multiplier_density_threshold) * ((1LL << (32 - z)) / preserve_multiplier_density_threshold)) {
|
||||
sf.dropped = FEATURE_ADDED_FOR_MULTIPLIER_DENSITY;
|
||||
} else if (preserve_multiplier_density_bits_by_zoom.size() > 0 &&
|
||||
(size_t) z < preserve_multiplier_density_bits_by_zoom.size() &&
|
||||
(sf.index >> (64 - preserve_multiplier_density_bits_by_zoom[z])) !=
|
||||
(next_feature_state.prev_not_dropped_index >> (64 - preserve_multiplier_density_bits_by_zoom[z]))) {
|
||||
sf.dropped = FEATURE_ADDED_FOR_MULTIPLIER_DENSITY;
|
||||
} else {
|
||||
sf.dropped = FEATURE_DROPPED;
|
||||
}
|
||||
@@ -1371,7 +1370,7 @@ void *run_prefilter(void *v) {
|
||||
}
|
||||
|
||||
decode_meta(sf, tmp_layer, tmp_feature);
|
||||
tmp_layer.features.push_back(tmp_feature);
|
||||
tmp_layer.features.push_back(std::make_shared<mvt_feature>(tmp_feature));
|
||||
|
||||
layer_to_geojson(tmp_layer, 0, 0, 0, false, true, false, true, sf.index, sf.seq, sf.extent, true, state, 0, std::set<std::string>());
|
||||
}
|
||||
@@ -1562,6 +1561,26 @@ bool find_feature_to_accumulate_onto(std::vector<std::shared_ptr<serial_feature>
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool line_is_too_small(drawvec const &geometry, int z, int detail) {
|
||||
if (geometry.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
long long x = std::round((double) geometry[0].x / (1LL << (32 - detail - z)));
|
||||
long long y = std::round((double) geometry[0].y / (1LL << (32 - detail - z)));
|
||||
|
||||
for (auto &g : geometry) {
|
||||
long long xx = std::round((double) g.x / (1LL << (32 - detail - z)));
|
||||
long long yy = std::round((double) g.y / (1LL << (32 - detail - z)));
|
||||
|
||||
if (xx != x || yy != y) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keep only a sample of 100K extents for feature dropping,
|
||||
// to avoid spending lots of memory on a complete list when there are
|
||||
// hundreds of millions of features.
|
||||
@@ -2081,25 +2100,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
if (line_is_too_small(sf.geometry, z, line_detail)) {
|
||||
continue;
|
||||
}
|
||||
if (sf.t == VT_POLYGON && get_mp_area(sf.geometry) <= 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Make label anchors early in tiling, even though it requires simplifying early,
|
||||
// so that if there is no label anchor for this feature in this tile,
|
||||
// we find out now rather than after we have already decided that there
|
||||
// are too_many_bytes.
|
||||
if (sf.t == VT_POLYGON && additional[A_GENERATE_POLYGON_LABEL_POINTS]) {
|
||||
drawvec ngeom = simplify_lines(sf.geometry, z, tx, ty, line_detail, !(prevent[P_CLIPPING] || prevent[P_DUPLICATION]), sf.simplification, sf.t == VT_POLYGON ? 4 : 0, shared_nodes, NULL, 0, "");
|
||||
if (ngeom.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
sf.geometry = checkerboard_anchors(ngeom, tx, ty, z, sf.label_point);
|
||||
if (sf.geometry.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
sf.t = VT_POINT;
|
||||
}
|
||||
|
||||
unsigned long long sfindex = sf.index;
|
||||
@@ -2153,7 +2153,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
sf.dropped = FEATURE_KEPT;
|
||||
}
|
||||
|
||||
if (sf.dropped == FEATURE_KEPT && retain_points_multiplier > 1) {
|
||||
if (sf.dropped == FEATURE_KEPT && (retain_points_multiplier > 1 || preserve_multiplier_density_threshold != 0 || preserve_multiplier_density_bits_by_zoom.size() > 0)) {
|
||||
sf.full_keys.push_back(key_pool.pool("tippecanoe:retain_points_multiplier_first"));
|
||||
sf.full_values.emplace_back(mvt_bool, "true");
|
||||
}
|
||||
@@ -2204,7 +2204,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
// have been assembled globally, although that also means that simplification
|
||||
// may not be very effective for reducing memory usage.
|
||||
|
||||
fprintf(stderr, "simplifying through\n");
|
||||
for (; simplified_geometry_through < features.size(); simplified_geometry_through++) {
|
||||
simplify_feature(&*features[simplified_geometry_through], shared_nodes, shared_nodes_map, nodepos, shared_nodes_bloom);
|
||||
|
||||
@@ -2304,7 +2303,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
std::string const &layername = kv.first;
|
||||
std::vector<std::shared_ptr<serial_feature>> &features = kv.second.features;
|
||||
|
||||
if (retain_points_multiplier > 1) {
|
||||
if ((retain_points_multiplier > 1 || preserve_multiplier_density_threshold != 0 || preserve_multiplier_density_bits_by_zoom.size() > 0)) {
|
||||
// mapping from input sequence to current sequence within this tile
|
||||
std::vector<std::pair<size_t, size_t>> feature_sequences;
|
||||
|
||||
@@ -2587,7 +2586,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
add_tilestats(layer.name, z, layermaps, tiling_seg, layer_unmaps, "tippecanoe_feature_density", sv);
|
||||
}
|
||||
|
||||
layer.features.push_back(std::move(feature));
|
||||
layer.features.push_back(std::make_shared<mvt_feature>(feature));
|
||||
layer_features[x] = std::make_shared<serial_feature>();
|
||||
}
|
||||
|
||||
@@ -2665,9 +2664,9 @@ 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 = std::min(1.0, mingap_fraction * adjusted_max_tile_features / adjusted_feature_count * 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) {
|
||||
if (m != mingap) {
|
||||
mingap = m;
|
||||
if (mingap > arg->mingap_out) {
|
||||
arg->mingap_out = mingap;
|
||||
@@ -2678,14 +2677,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature gap threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
minextent_fraction = std::min(1.0, minextent_fraction * adjusted_max_tile_features / adjusted_feature_count * 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) {
|
||||
if (m != minextent) {
|
||||
minextent = m;
|
||||
if (minextent > arg->minextent_out) {
|
||||
arg->minextent_out = minextent;
|
||||
@@ -2696,17 +2692,14 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature extent threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} 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 = std::min(1.0, mindrop_sequence_fraction * adjusted_max_tile_features / adjusted_feature_count * 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) {
|
||||
if (m != mindrop_sequence) {
|
||||
mindrop_sequence = m;
|
||||
if (mindrop_sequence > arg->mindrop_sequence_out) {
|
||||
if (!prevent[P_DYNAMIC_DROP]) {
|
||||
@@ -2719,9 +2712,6 @@ 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 {
|
||||
fprintf(stderr, "Can't increase feature fraction threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Try using --drop-fraction-as-needed or --drop-densest-as-needed.\n");
|
||||
@@ -2783,11 +2773,10 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
fprintf(stderr, "Going to try gamma of %0.3f to make it fit\n", gamma);
|
||||
}
|
||||
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 = std::min(1.0, mingap_fraction * adjusted_max_tile_size / adjusted_tile_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) {
|
||||
if (m != mingap) {
|
||||
mingap = m;
|
||||
if (mingap > arg->mingap_out) {
|
||||
arg->mingap_out = mingap;
|
||||
@@ -2798,14 +2787,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature gap threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
minextent_fraction = std::min(1.0, minextent_fraction * adjusted_max_tile_size / adjusted_tile_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) {
|
||||
if (m != minextent) {
|
||||
minextent = m;
|
||||
if (minextent > arg->minextent_out) {
|
||||
arg->minextent_out = minextent;
|
||||
@@ -2816,14 +2802,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature extent threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} 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 = std::min(1.0, mindrop_sequence_fraction * adjusted_max_tile_size / adjusted_tile_size * 0.75);
|
||||
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) {
|
||||
if (m != mindrop_sequence) {
|
||||
mindrop_sequence = m;
|
||||
if (mindrop_sequence > arg->mindrop_sequence_out) {
|
||||
if (!prevent[P_DYNAMIC_DROP]) {
|
||||
@@ -2836,9 +2819,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature fraction threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else {
|
||||
detail_reduced++;
|
||||
@@ -2850,7 +2830,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
|
||||
if (skipped > 0 || too_many_bytes || too_many_features) {
|
||||
fprintf(stderr, "Can't happen: writing tile even though we skipped\n");
|
||||
fprintf(stderr, "Can't happen: writing tile even though we skipped (%zu %d %d)\n", skipped, too_many_bytes, too_many_features);
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,12 +152,3 @@ TEST_CASE("mvt_geometry bbox") {
|
||||
REQUIRE(start == 0x1c84fc0000000000);
|
||||
REQUIRE(end == 0x1c84ffffffffffff);
|
||||
}
|
||||
|
||||
TEST_CASE("line_is_too_small") {
|
||||
drawvec dv;
|
||||
dv.emplace_back(VT_MOVETO, 4243099709, 2683872952);
|
||||
dv.emplace_back(VT_LINETO, 4243102487, 2683873977);
|
||||
dv.emplace_back(VT_MOVETO, -51867587, 2683872952);
|
||||
dv.emplace_back(VT_LINETO, -51864809, 2683873977);
|
||||
REQUIRE(line_is_too_small(dv, 0, 10));
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v2.78.0"
|
||||
#define VERSION "v2.76.0"
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ void write_coords(json_writer &state, lonlat const &ll, double scale) {
|
||||
|
||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool write_dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state, double scale, std::set<std::string> const &include_attr) {
|
||||
for (size_t f = 0; f < layer.features.size(); f++) {
|
||||
mvt_feature const &feat = layer.features[f];
|
||||
mvt_feature const &feat = *layer.features[f];
|
||||
|
||||
state.json_write_hash();
|
||||
state.json_write_string("type");
|
||||
|
||||
Reference in New Issue
Block a user