mirror of
https://github.com/felt/tippecanoe.git
synced 2026-11-28 03:11:18 +01:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03647fb4a5 | ||
|
|
a52d15a0b1 | ||
|
|
9037920faf | ||
|
|
82e8d96ea6 | ||
|
|
a84864e795 | ||
|
|
1ba93dc302 |
+2
-8
@@ -1,13 +1,7 @@
|
||||
# 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.
|
||||
* Cleaning of complex polygon geometries now happens in stages
|
||||
to avoid performance problems when there are very large numbers
|
||||
of vertices.
|
||||
* Label point generation happens earlier in tiling, to avoid doing slow
|
||||
operations on polygons that will not be retained anyway.
|
||||
* 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
|
||||
|
||||
|
||||
@@ -446,11 +446,11 @@ overzoom-test: tippecanoe-overzoom
|
||||
# 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 -b0 -o tests/pbf/merged-nodedup.pbf -t 1/1/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 1 1 0 > tests/pbf/merged-nodedup.pbf.json.check
|
||||
./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 -b0 --deduplicate-by-id -o tests/pbf/merged-dedup.pbf -t 1/1/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 1 1 0 > tests/pbf/merged-dedup.pbf.json.check
|
||||
./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
|
||||
|
||||
|
||||
@@ -571,7 +571,8 @@ drawvec remove_noop(drawvec geom, int type, int shift) {
|
||||
}
|
||||
|
||||
if (geom[i + 1].op == VT_CLOSEPATH) {
|
||||
// followed by closepath: only possible after close_poly()
|
||||
// followed by closepath: not possible
|
||||
fprintf(stderr, "Shouldn't happen\n");
|
||||
i++; // also remove unused closepath
|
||||
continue;
|
||||
}
|
||||
@@ -2145,9 +2146,6 @@ 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
|
||||
if (deduplicate_by_id && feature.has_id) {
|
||||
deduplicate_by_id_set->insert(feature.id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2163,9 +2161,6 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
|
||||
if (geom.size() == 0) {
|
||||
// clipped away
|
||||
if (deduplicate_by_id && feature.has_id) {
|
||||
deduplicate_by_id_set->insert(feature.id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2200,10 +2195,6 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
|
||||
std::set<std::string> exclude_attributes;
|
||||
if (filter != NULL && !evaluate(feature, layer, filter, exclude_attributes, nz, unidecode_data)) {
|
||||
// filtered away
|
||||
if (deduplicate_by_id && feature.has_id) {
|
||||
deduplicate_by_id_set->insert(feature.id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2241,14 +2232,6 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
||||
geom = close_poly(geom);
|
||||
}
|
||||
|
||||
if (geom.size() == 0) {
|
||||
// simplified away
|
||||
if (deduplicate_by_id && feature.has_id) {
|
||||
deduplicate_by_id_set->insert(feature.id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
tile_feature tf;
|
||||
tf.geom = std::move(geom);
|
||||
tf.t = t;
|
||||
@@ -2509,65 +2492,3 @@ bool line_is_too_small(drawvec const &geometry, int z, int detail) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void coalesce_polygon(drawvec &geom, bool scale_up) {
|
||||
// wagyu should be able to straightforwardly handle
|
||||
// anything under a few hundred thousand vertices
|
||||
if (geom.size() < 100000) {
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, scale_up);
|
||||
return;
|
||||
}
|
||||
|
||||
// These geometries were assembled in geometric order,
|
||||
// so sub-batches of them should hopefully union into
|
||||
// reasonable sets.
|
||||
//
|
||||
// Find the first outer ring after halfway point.
|
||||
|
||||
for (size_t i = geom.size() / 2; i < geom.size(); i++) {
|
||||
if (geom[i].op == VT_MOVETO) {
|
||||
size_t j;
|
||||
for (j = i + 1; j < geom.size(); j++) {
|
||||
if (geom[j].op != VT_LINETO) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (get_area(geom, i, j) > 0) {
|
||||
// If we have an outer ring, split there
|
||||
// and coalesce the two halves
|
||||
|
||||
// Copy second half to new vector
|
||||
std::vector<draw> geom2;
|
||||
geom2.resize(geom.size() - i);
|
||||
for (size_t k = i; k < geom.size(); k++) {
|
||||
geom2[k - i] = geom[k];
|
||||
}
|
||||
|
||||
// Resize vector to include only first half
|
||||
geom.resize(i);
|
||||
|
||||
// Clean each half individually
|
||||
coalesce_polygon(geom, scale_up);
|
||||
coalesce_polygon(geom2, scale_up);
|
||||
|
||||
// Copy second half back with first
|
||||
size_t brk = geom.size();
|
||||
geom.resize(brk + geom2.size());
|
||||
for (size_t k = 0; k < geom2.size(); k++) {
|
||||
geom[brk + k] = geom2[k];
|
||||
}
|
||||
geom2.clear();
|
||||
|
||||
// Clean the combined geometry
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, scale_up);
|
||||
return;
|
||||
}
|
||||
|
||||
i = j - 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Can't find a breakpoint; take what we can get.
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, scale_up);
|
||||
}
|
||||
|
||||
@@ -172,8 +172,6 @@ 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);
|
||||
void coalesce_polygon(drawvec &geom, bool scale_up);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"maxzoom": "2",
|
||||
"minzoom": "0",
|
||||
"name": "tests/ne_110m_admin_0_countries/out/-z2_--convert-polygons-to-label-points.json.check.mbtiles",
|
||||
"strategies": "[{},{},{\"tiny_polygons\":1}]",
|
||||
"type": "overlay",
|
||||
"version": "2"
|
||||
}, "features": [
|
||||
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
{"type":"Feature","properties":{"what":"no id"},"geometry":{"type":"Point","coordinates":[1,1]}}
|
||||
{"type":"Feature","id":12345,"properties":{"what":"will survive"},"geometry":{"type":"Point","coordinates":[1,1]}}
|
||||
{"type":"Feature","id":12346,"properties":{"what":"will win over the duplicate even though it's in another tile"},"geometry":{"type":"Point","coordinates":[-1,-1]}}
|
||||
{"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]}}
|
||||
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
{"type":"Feature","properties":{"what":"no id again"},"geometry":{"type":"Point","coordinates":[1,1]}}
|
||||
{"type":"Feature","id":12346,"properties":{"what":"will be lost as a duplicate"},"geometry":{"type":"Point","coordinates":[1,1]}}
|
||||
{"type":"Feature","id":12347,"properties":{"what":"will be added"},"geometry":{"type":"Point","coordinates":[1,1]}}
|
||||
{"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,11 +1,13 @@
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 1, "y": 0 }, "features": [
|
||||
{ "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.966797, 0.966751 ] } }
|
||||
{ "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.966797, 0.966751 ] } }
|
||||
{ "type": "Feature", "id": 12345, "properties": { "what": "will survive" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "what": "no id again" }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
|
||||
{ "type": "Feature", "id": 12346, "properties": { "what": "will win over the duplicate" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "id": 12347, "properties": { "what": "will be added" }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
|
||||
{ "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,13 +1,15 @@
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 1, "y": 0 }, "features": [
|
||||
{ "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.966797, 0.966751 ] } }
|
||||
{ "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.966797, 0.966751 ] } }
|
||||
{ "type": "Feature", "id": 12345, "properties": { "what": "will survive" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "what": "no id again" }, "geometry": { "type": "Point", "coordinates": [ 0.966797, 0.966751 ] } }
|
||||
{ "type": "Feature", "id": 12346, "properties": { "what": "will win over the duplicate" }, "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.966797, 0.966751 ] } }
|
||||
{ "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.966797, 0.966751 ] } }
|
||||
{ "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 ] } }
|
||||
] }
|
||||
] }
|
||||
|
||||
@@ -639,7 +639,7 @@ static double simplify_feature(serial_feature *p, drawvec const &shared_nodes, n
|
||||
// unioned exactly
|
||||
//
|
||||
// don't try to scale up because these are still world coordinates
|
||||
coalesce_polygon(geom, false);
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, false);
|
||||
}
|
||||
|
||||
// continues to simplify to line_detail even if we have extra detail
|
||||
@@ -676,7 +676,9 @@ 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) {
|
||||
if (a->trying_to_stop_early) {
|
||||
area = get_mp_area((*features)[i]->geometry);
|
||||
} else {
|
||||
area = simplify_feature(&*((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos, *(a->shared_nodes_bloom));
|
||||
}
|
||||
|
||||
@@ -695,14 +697,19 @@ static void *simplification_worker(void *v) {
|
||||
|
||||
if (!a->trying_to_stop_early) {
|
||||
// we can try scaling up because this is now tile scale
|
||||
coalesce_polygon(geom, true);
|
||||
geom = clean_or_clip_poly(geom, 0, 0, false, true);
|
||||
if (additional[A_DEBUG_POLYGON]) {
|
||||
check_polygon(geom);
|
||||
}
|
||||
|
||||
if (geom.size() < 3) {
|
||||
if (area > 0) {
|
||||
if (area > 0 && !additional[A_GRID_LOW_ZOOMS]) {
|
||||
// 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();
|
||||
@@ -715,6 +722,16 @@ static void *simplification_worker(void *v) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1859,35 +1876,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
extent_previndex = sf.index;
|
||||
}
|
||||
|
||||
// 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.
|
||||
//
|
||||
// label anchors also need to happen before as-needed dropping and coalescing,
|
||||
// so that the geometry type matches for find_feature_to_accumulate_onto.
|
||||
// (or it could happen much later, after all the features are accumulated,
|
||||
// but then it would be too late for too_many_bytes)
|
||||
if (sf.t == VT_POLYGON && additional[A_GENERATE_POLYGON_LABEL_POINTS]) {
|
||||
// exclude features that are invisibly small at this zoom level
|
||||
if (line_is_too_small(sf.geometry, z, line_detail)) {
|
||||
continue;
|
||||
}
|
||||
if (sf.t == VT_POLYGON && get_mp_area(sf.geometry) <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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 drop_sequence = 0;
|
||||
if (additional[A_COALESCE_FRACTION_AS_NEEDED] || additional[A_DROP_FRACTION_AS_NEEDED] || prevent[P_DYNAMIC_DROP]) {
|
||||
drop_sequence = calculate_drop_sequence(sf);
|
||||
@@ -2003,9 +1991,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
} else if (additional[A_COALESCE_DENSEST_AS_NEEDED]) {
|
||||
add_sample_to(gaps, sf.gap, gaps_increment, seq);
|
||||
if (sf.gap < mingap && find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX)) {
|
||||
if (sf.t == VT_POINT || !line_is_too_small(sf.geometry, z, line_detail)) {
|
||||
coalesce_geometry(*features[which_serial_feature], sf);
|
||||
}
|
||||
coalesce_geometry(*features[which_serial_feature], sf);
|
||||
features[which_serial_feature]->coalesced = true;
|
||||
coalesced_area += sf.extent;
|
||||
preserve_attributes(arg->attribute_accum, sf, *features[which_serial_feature], key_pool);
|
||||
@@ -2027,9 +2013,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
} else if (additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
add_sample_to(extents, sf.extent, extents_increment, seq);
|
||||
if (minextent != 0 && sf.extent + coalesced_area <= minextent && find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, minextent)) {
|
||||
if (sf.t == VT_POINT || !line_is_too_small(sf.geometry, z, line_detail)) {
|
||||
coalesce_geometry(*features[which_serial_feature], sf);
|
||||
}
|
||||
coalesce_geometry(*features[which_serial_feature], sf);
|
||||
features[which_serial_feature]->coalesced = true;
|
||||
coalesced_area += sf.extent;
|
||||
preserve_attributes(arg->attribute_accum, sf, *features[which_serial_feature], key_pool);
|
||||
@@ -2049,9 +2033,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
} else if (additional[A_COALESCE_FRACTION_AS_NEEDED]) {
|
||||
add_sample_to(drop_sequences, drop_sequence, drop_sequences_increment, seq);
|
||||
if (mindrop_sequence != 0 && drop_sequence <= mindrop_sequence && find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX)) {
|
||||
if (sf.t == VT_POINT || !line_is_too_small(sf.geometry, z, line_detail)) {
|
||||
coalesce_geometry(*features[which_serial_feature], sf);
|
||||
}
|
||||
coalesce_geometry(*features[which_serial_feature], sf);
|
||||
features[which_serial_feature]->coalesced = true;
|
||||
preserve_attributes(arg->attribute_accum, sf, *features[which_serial_feature], key_pool);
|
||||
strategy.coalesced_as_needed++;
|
||||
@@ -2099,6 +2081,25 @@ 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;
|
||||
@@ -2203,6 +2204,7 @@ 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);
|
||||
|
||||
@@ -2210,7 +2212,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
drawvec to_clean = features[simplified_geometry_through]->geometry;
|
||||
|
||||
// don't scale up because this is still world coordinates
|
||||
coalesce_polygon(to_clean, false);
|
||||
to_clean = clean_or_clip_poly(to_clean, 0, 0, false, false);
|
||||
features[simplified_geometry_through]->geometry = std::move(to_clean);
|
||||
}
|
||||
}
|
||||
@@ -2479,7 +2481,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
if (layer_features[x]->t == VT_POLYGON) {
|
||||
if (layer_features[x]->coalesced) {
|
||||
// we can try scaling up because this is tile coordinates
|
||||
coalesce_polygon(layer_features[x]->geometry, true);
|
||||
layer_features[x]->geometry = clean_or_clip_poly(layer_features[x]->geometry, 0, 0, false, true);
|
||||
}
|
||||
|
||||
layer_features[x]->geometry = close_poly(layer_features[x]->geometry);
|
||||
@@ -2510,7 +2512,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
// this is maxzoom; ok to stop early still because they said to limit abruptly
|
||||
layer_features.resize(limit_tile_feature_count_at_maxzoom);
|
||||
too_many_features = false; // don't try to drop; we have already truncated
|
||||
too_many_bytes = false; // don't try to drop; we have already truncated
|
||||
skipped = 0; // doesn't matter that we skipped features; we have truncated
|
||||
}
|
||||
} else if (limit_tile_feature_count != 0) {
|
||||
@@ -2518,7 +2519,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
can_stop_early = false;
|
||||
layer_features.resize(limit_tile_feature_count);
|
||||
too_many_features = false; // don't try to drop; we have already truncated
|
||||
too_many_bytes = false; // don't try to drop; we have already truncated
|
||||
skipped = 0; // doesn't matter that we skipped features; we have truncated
|
||||
}
|
||||
}
|
||||
@@ -2665,13 +2665,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 * adjusted_max_tile_features / adjusted_feature_count * 0.80;
|
||||
if (mingap_fraction > 0.80) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Need to drop features, but calculated that we should keep %.1f%% of features\n", mingap_fraction * 100.0);
|
||||
}
|
||||
mingap_fraction = 0.80;
|
||||
}
|
||||
mingap_fraction = std::min(1.0, 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;
|
||||
@@ -2689,13 +2683,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
minextent_fraction = minextent_fraction * adjusted_max_tile_features / adjusted_feature_count * 0.75;
|
||||
if (minextent_fraction > 0.80) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Need to drop features, but calculated that we should keep %.1f%% of features\n", minextent_fraction * 100.0);
|
||||
}
|
||||
minextent_fraction = 0.80;
|
||||
}
|
||||
minextent_fraction = std::min(1.0, 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;
|
||||
@@ -2709,20 +2697,14 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature area threshold further\n");
|
||||
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 = mindrop_sequence_fraction * adjusted_max_tile_features / adjusted_feature_count * 0.95;
|
||||
if (mindrop_sequence_fraction > 0.80) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Need to drop features, but calculated that we should keep %.1f%% of features\n", mindrop_sequence_fraction * 100.0);
|
||||
}
|
||||
mindrop_sequence_fraction = 0.80;
|
||||
}
|
||||
mindrop_sequence_fraction = std::min(1.0, 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;
|
||||
@@ -2738,7 +2720,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 {
|
||||
fprintf(stderr, "Can't increase feature count threshold further\n");
|
||||
fprintf(stderr, "Can't increase feature fraction threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else {
|
||||
@@ -2772,7 +2754,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
if (adjusted_tile_size != compressed.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, adjusted_max_tile_size);
|
||||
@@ -2801,14 +2783,9 @@ 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 = mingap_fraction * adjusted_max_tile_size / adjusted_tile_size * 0.80;
|
||||
if (mingap_fraction > 0.80) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Need to drop features, but calculated that we should keep %.1f%% of features\n", mingap_fraction * 100.0);
|
||||
}
|
||||
mingap_fraction = 0.80;
|
||||
}
|
||||
mingap_fraction = std::min(1.0, 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;
|
||||
@@ -2826,13 +2803,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
|
||||
minextent_fraction = minextent_fraction * adjusted_max_tile_size / adjusted_tile_size * 0.75;
|
||||
if (minextent_fraction > 0.80) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Need to drop features, but calculated that we should keep %.1f%% of features\n", minextent_fraction * 100.0);
|
||||
}
|
||||
minextent_fraction = 0.80;
|
||||
}
|
||||
minextent_fraction = std::min(1.0, 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;
|
||||
@@ -2846,17 +2817,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature area threshold further\n");
|
||||
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 = mindrop_sequence_fraction * adjusted_max_tile_size / adjusted_tile_size * 0.75;
|
||||
if (mindrop_sequence_fraction > 0.80) {
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "Need to drop features, but calculated that we should keep %.1f%% of features\n", mindrop_sequence_fraction * 100.0);
|
||||
}
|
||||
mindrop_sequence_fraction = 0.80;
|
||||
}
|
||||
mindrop_sequence_fraction = std::min(1.0, 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;
|
||||
@@ -2872,7 +2837,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
line_detail++;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Can't increase feature count threshold further\n");
|
||||
fprintf(stderr, "Can't increase feature fraction threshold further\n");
|
||||
exit(EXIT_INCOMPLETE);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user