Compare commits

...
4 Commits
Author SHA1 Message Date
Erica Fischer bc59c6ba84 Fix the feature count estimates, I think 2024-08-16 12:06:24 -07:00
Erica Fischer 1a38b43f49 Adjust the estimated total feature count for the multiplier too 2024-08-16 11:25:59 -07:00
Erica Fischer c3fa99bc86 Be more careful to retry when the feature count is exceeded 2024-08-16 10:39:25 -07:00
Erica Fischer d891ca7289 Fix latitude bboxes for features that extend beyond the mercator plane (#254)
* Fix latitude bboxes for features that extend beyond the mercator plane

* Update some more test expectations

* Update version and changelog
2024-08-08 15:30:52 -07:00
48 changed files with 137 additions and 174 deletions
+4
View File
@@ -1,3 +1,7 @@
# 2.59.0
* Correct `antimeridian_adjusted_bounds` latitude calculation when vertices extend beyond the edge of the Mercator plane
# 2.58.0
* Add --generate-variable-depth-tile-pyramid option
+7 -4
View File
@@ -423,12 +423,15 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
for (size_t i = 0; i < sf.geometry.size(); i++) {
if (sf.geometry[i].op == VT_MOVETO || sf.geometry[i].op == VT_LINETO) {
if (sf.geometry[i].y > 0 && sf.geometry[i].y < 0xFFFFFFFF) {
// standard -180 to 180 world plane
// standard -180 to 180 world plane
//
// mask X, since it wraps around
// pin Y, since it doesn't
long long x = sf.geometry[i].x & 0xFFFFFFFF;
long long y = sf.geometry[i].y & 0xFFFFFFFF;
long long x = sf.geometry[i].x & 0xFFFFFFFF;
long long y = std::max(std::min(sf.geometry[i].y, 0xFFFFFFFFLL), 0LL);
{
r->file_bbox1[0] = std::min(r->file_bbox1[0], x);
r->file_bbox1[1] = std::min(r->file_bbox1[1], y);
r->file_bbox1[2] = std::max(r->file_bbox1[2], x);
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "3.757458,-84.969764,359.744029,85.007238",
"antimeridian_adjusted_bounds": "3.757458,-85.051129,359.744029,85.051129",
"bounds": "-179.320808,-85.051129,177.449262,85.051129",
"center": "-179.320808,-69.033211,14",
"description": "tests/accumulate/out/--set-attribute_thecomma%3aNEWVALUE_--accumulate-attribute_thecomma%3acomma.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "3.757458,-84.969764,359.744029,85.007238",
"antimeridian_adjusted_bounds": "3.757458,-85.051129,359.744029,85.051129",
"bounds": "-179.320808,-85.051129,177.449262,85.051129",
"center": "0.000000,0.000000,0",
"description": "tests/accumulate/out/-z0_--set-attribute_%7b%22num%22%3a5,%22str%22%3a%22abc%22}.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "3.757458,-84.969764,359.744029,85.007238",
"antimeridian_adjusted_bounds": "3.757458,-85.051129,359.744029,85.051129",
"bounds": "-179.320808,-85.051129,177.449262,85.051129",
"center": "0.000000,0.000000,0",
"description": "tests/accumulate/out/-z0_--set-attribute_num%3a5_--set-attribute_str%3aabc.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "3.757458,-84.969764,359.744029,85.007238",
"antimeridian_adjusted_bounds": "3.757458,-85.051129,359.744029,85.051129",
"bounds": "-179.320808,-85.051129,177.449262,85.051129",
"center": "-157.500000,20.489949,3",
"description": "tests/accumulate/out/-z3_--accumulate-attribute_%7b%22thesum%22%3a%22sum%22,%22theproduct%22%3a%22product%22}.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "3.757458,-84.969764,359.744029,85.007238",
"antimeridian_adjusted_bounds": "3.757458,-85.051129,359.744029,85.051129",
"bounds": "-179.320808,-85.051129,177.449262,85.051129",
"center": "112.500000,20.489949,3",
"description": "tests/accumulate/out/-z3_-Ethesum%3asum_-Etheproduct%3aproduct_-Ethemax%3amax_-Ethemin%3amin_-Ethemean%3amean_-Etheconcat%3aconcat_-Ethecomma%3acomma_-r1_-K100.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "3.757458,-84.969764,359.744029,85.007238",
"antimeridian_adjusted_bounds": "3.757458,-85.051129,359.744029,85.051129",
"bounds": "-179.320808,-85.051129,177.449262,85.051129",
"center": "-174.375000,-52.349536,5",
"description": "tests/accumulate/out/-z5_-Ethesum%3asum_-Etheproduct%3aproduct_-Ethemax%3amax_-Ethemin%3amin_-Ethemean%3amean_-Etheconcat%3aconcat_-Ethecomma%3acomma.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023803,-85.040752,359.950215,83.645130",
"antimeridian_adjusted_bounds": "0.023803,-85.051129,359.950215,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "90.000000,42.525564,1",
"description": "tests/coalesce-id/out/-z1_--coalesce_--reorder.json.check.mbtiles",
+1 -1
View File
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-175.220564,-41.299988,179.216647,64.150024",
"antimeridian_adjusted_bounds": "-175.220564,-41.299988,179.216647,85.051129",
"bounds": "-180.000000,-41.299988,180.000000,85.051129",
"center": "0.000000,0.000000,0",
"description": "tests/csv/out-null.mbtiles",
+1 -1
View File
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-175.220564,-41.299988,179.216647,64.150024",
"antimeridian_adjusted_bounds": "-175.220564,-41.299988,179.216647,85.051129",
"bounds": "-180.000000,-41.299988,180.000000,85.051129",
"center": "0.000000,0.000000,0",
"description": "tests/csv/out.mbtiles",
+1 -1
View File
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "180.000000,85.051129,-180.000000,-85.051129",
"antimeridian_adjusted_bounds": "-135.232962,-85.051129,-135.232962,-85.051129",
"bounds": "-135.232962,-85.051129,-135.232962,-85.051129",
"center": "-135.232962,-85.051129,0",
"description": "tests/invalid-polygon/out/-z0.json.check.mbtiles",
+1 -1
View File
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "180.000000,85.051129,-180.000000,-85.051129",
"antimeridian_adjusted_bounds": "0.000000,-85.051129,0.000000,-85.051129",
"bounds": "-180.000000,-85.051129,180.000000,-85.051129",
"center": "0.000000,-85.051129,0",
"format": "pbf",
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "45.000000,33.256630,2",
"description": "tests/ne_110m_admin_0_countries/out/--coalesce_-z2_-Ccat.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "0.000000,0.000000,0",
"description": "tests/ne_110m_admin_0_countries/out/-B10_-z0_--retain-points-multiplier_10_-d8_-yNAME.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-R5%2f17%2f11.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-ae_-zg_-M5000_--drop-densest-as-needed.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-ae_-zg_-M5000_--drop-fraction-as-needed.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-ae_-zg_-M5000_--drop-smallest-as-needed.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-ae_-zg_-M5000_--force-feature-limit.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-110.039063,26.980829,-92.021484,51.998410",
"center": "-92.021484,26.980829,0",
"description": "tests/ne_110m_admin_0_countries/out/-z0_--clip-bounding-box_-110,27,-92,52.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "0.000000,0.000000,0",
"description": "tests/ne_110m_admin_0_countries/out/-z0_--order-largest-first.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "0.000000,0.000000,0",
"description": "tests/ne_110m_admin_0_countries/out/-z0_--order-smallest-first.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "0.000000,0.000000,0",
"description": "tests/ne_110m_admin_0_countries/out/-z0_--tiny-polygon-size_100.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "0.000000,0.000000,0",
"description": "tests/ne_110m_admin_0_countries/out/-z0_--tiny-polygon-size_50_--order-largest-first.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "0.000000,0.000000,0",
"description": "tests/ne_110m_admin_0_countries/out/-z0_--tiny-polygon-size_50_--simplification_50.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "90.000000,42.525564,1",
"description": "tests/ne_110m_admin_0_countries/out/-z1_-yname_--no-simplification-of-shared-nodes.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "45.000000,33.256630,2",
"description": "tests/ne_110m_admin_0_countries/out/-z2_--convert-polygons-to-label-points.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "22.500000,20.489949,3",
"description": "tests/ne_110m_admin_0_countries/out/-z3_-ai.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_--drop-polygons.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_--grid-low-zooms_-D8.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_--no-tiny-polygon-reduction.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_-S4.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_-S4_--simplification-at-maximum-zoom_2.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_-S4_--visvalingam.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "-101.250000,70.266402,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_-pD.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "11.250000,48.378236,4",
"description": "tests/ne_110m_admin_0_countries/out/-z4_-yname_-pc.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-z5_-M5000_--coalesce-densest-as-needed.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-z5_-M5000_--coalesce-fraction-as-needed.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-z5_-M5000_--coalesce-smallest-as-needed.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "16.875000,44.951199,5",
"description": "tests/ne_110m_admin_0_countries/out/-z5_-M5000_--drop-smallest-as-needed.json.check.mbtiles",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "0.023802,-85.040752,359.950216,83.645130",
"antimeridian_adjusted_bounds": "0.023802,-85.051129,359.950216,83.645130",
"bounds": "-180.000000,-85.051129,180.000000,83.645130",
"center": "0.000000,0.000000,0",
"description": "tests/ne_110m_admin_0_countries/out/-zg_-yname.json.check.mbtiles",
+1 -1
View File
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "180.000000,85.051129,-180.000000,-85.051129",
"antimeridian_adjusted_bounds": "0.000000,85.051129,0.000000,85.051129",
"bounds": "-180.000000,85.051129,180.000000,85.051129",
"center": "-179.989014,85.051129,14",
"description": "tests/raw-tiles/nothing",
@@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "-180.000000,12.583700,179.688000,85.027900",
"antimeridian_adjusted_bounds": "-180.000000,12.583700,179.688000,85.051129",
"bounds": "-180.000000,12.583700,180.000000,85.051129",
"center": "0.000000,12.583700,0",
"description": "tests/wraparound2/out/-z0_--detect-longitude-wraparound.json.check.mbtiles",
+47 -23
View File
@@ -1521,7 +1521,7 @@ struct layer_features {
size_t multiplier_cluster_size = 0; // The feature count of the current multiplier cluster
};
bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features &layer, serial_feature &sf, std::vector<std::vector<std::string>> *layer_unmaps, size_t &multiplier_seq, strategy &strategy, bool &drop_rest, std::unordered_map<std::string, attribute_op> const *attribute_accum) {
bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features &layer, serial_feature &sf, std::vector<std::vector<std::string>> *layer_unmaps, size_t &multiplier_seq, strategy &strategy, bool &drop_rest_of_cluster, std::unordered_map<std::string, attribute_op> const *attribute_accum) {
ssize_t which_serial_feature;
if (find_feature_to_accumulate_onto(layer.features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
@@ -1533,7 +1533,7 @@ bool drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer_features
} else {
preserve_attributes(attribute_accum, sf, layer.features[which_serial_feature]);
strategy.dropped_as_needed++;
drop_rest = true;
drop_rest_of_cluster = true;
return true; // dropped
}
}
@@ -1640,6 +1640,9 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
size_t lead_features_count = 0; // of the tile so far
size_t other_multiplier_cluster_features_count = 0; // of the tile so far
bool too_many_features = false;
bool too_many_bytes = false;
std::atomic<bool> within[child_shards];
long long start_geompos[child_shards];
for (size_t i = 0; i < (size_t) child_shards; i++) {
@@ -1741,8 +1744,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
struct multiplier_state multiplier_state;
size_t multiplier_seq = retain_points_multiplier - 1;
bool drop_rest = false; // are we dropping the remainder of a multiplier cluster whose first point was dropped?
bool dropping_by_rate = false; // are we dropping anything by rate in this tile, or keeping it only as part of a multiplier?
bool drop_rest_of_cluster = false; // are we dropping the remainder of a multiplier cluster whose first point was dropped?
bool dropping_by_rate = false; // are we dropping anything by rate in this tile, or keeping it only as part of a multiplier?
unsigned long long next_feature_previndex = 0;
strategy strategy;
@@ -1797,7 +1800,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
if (sf.dropped == FEATURE_KEPT) {
// this is a new multiplier cluster, so stop dropping features
// that were dropped because the previous lead feature was dropped
drop_rest = false;
drop_rest_of_cluster = false;
} else {
can_stop_early = false;
@@ -1811,7 +1814,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
}
if (sf.dropped == FEATURE_DROPPED || drop_rest) {
if (sf.dropped == FEATURE_DROPPED || drop_rest_of_cluster) {
multiplier_seq = (multiplier_seq + 1) % retain_points_multiplier;
if (find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
@@ -1826,13 +1829,13 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
// only the first point of a multiplier cluster can be dropped
// by any of these mechanisms. (but if one is, it drags the whole
// cluster down with it by setting drop_rest).
// cluster down with it by setting drop_rest_of_cluster).
if (sf.dropped == FEATURE_KEPT) {
if (gamma > 0) {
if (manage_gap(sf.index, &previndex, scale, gamma, &gap) && find_feature_to_accumulate_onto(features, sf, which_serial_feature, layer_unmaps, LLONG_MAX, multiplier_seq)) {
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
strategy.dropped_by_gamma++;
drop_rest = true;
drop_rest_of_cluster = true;
can_stop_early = false;
continue;
}
@@ -1860,14 +1863,14 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
strategy.coalesced_as_needed++;
drop_rest = true;
drop_rest_of_cluster = true;
can_stop_early = false;
continue;
}
} else if (additional[A_DROP_DENSEST_AS_NEEDED]) {
add_sample_to(gaps, sf.gap, gaps_increment, seq);
if (sf.gap < mingap) {
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest_of_cluster, arg->attribute_accum)) {
can_stop_early = false;
continue;
}
@@ -1892,7 +1895,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
strategy.coalesced_as_needed++;
drop_rest = true;
drop_rest_of_cluster = true;
continue;
}
} else if (additional[A_COALESCE_DENSEST_AS_NEEDED]) {
@@ -1903,7 +1906,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
coalesced_area += sf.extent;
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
strategy.coalesced_as_needed++;
drop_rest = true;
drop_rest_of_cluster = true;
can_stop_early = false;
continue;
}
@@ -1912,7 +1915,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
// search here is for LLONG_MAX, not minextent, because we are dropping features, not coalescing them,
// so we shouldn't expect to find anything small that we can related this feature to.
if (minextent != 0 && sf.extent + coalesced_area <= minextent) {
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest_of_cluster, arg->attribute_accum)) {
can_stop_early = false;
continue;
}
@@ -1925,7 +1928,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
coalesced_area += sf.extent;
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
strategy.coalesced_as_needed++;
drop_rest = true;
drop_rest_of_cluster = true;
can_stop_early = false;
continue;
}
@@ -1934,7 +1937,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
// search here is for LLONG_MAX, not minextent, because we are dropping features, not coalescing them,
// so we shouldn't expect to find anything small that we can related this feature to.
if (mindrop_sequence != 0 && drop_sequence <= mindrop_sequence) {
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest, arg->attribute_accum)) {
if (drop_feature_unless_it_can_be_added_to_a_multiplier_cluster(layer, sf, layer_unmaps, multiplier_seq, strategy, drop_rest_of_cluster, arg->attribute_accum)) {
can_stop_early = false;
continue;
}
@@ -1946,7 +1949,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
features[which_serial_feature].coalesced = true;
preserve_attributes(arg->attribute_accum, sf, features[which_serial_feature]);
strategy.coalesced_as_needed++;
drop_rest = true;
drop_rest_of_cluster = true;
can_stop_early = false;
continue;
}
@@ -1995,10 +1998,24 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
unsigned long long sfindex = sf.index;
if (sf.geometry.size() > 0) {
if (lead_features_count > max_tile_size || (lead_features_count + other_multiplier_cluster_features_count > max_tile_features && !prevent[P_FEATURE_LIMIT])) {
// Adjust tile size limit based on the ratio of multiplier cluster features to lead features
size_t scaled_max_tile_size = max_tile_size;
if (lead_features_count > 0) {
scaled_max_tile_size *= (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
}
size_t scaled_max_tile_features = max_tile_features;
if (lead_features_count > 0) {
scaled_max_tile_features *= (lead_features_count + other_multiplier_cluster_features_count) / lead_features_count;
}
if (too_many_bytes || lead_features_count > scaled_max_tile_size) {
// Even being maximally conservative, each feature is still going to be
// at least one byte in the output tile, so this can't possibly work.
skipped++;
too_many_bytes = true;
} else if (too_many_features || (lead_features_count + other_multiplier_cluster_features_count > scaled_max_tile_features && !prevent[P_FEATURE_LIMIT])) {
skipped++;
too_many_features = true;
} else {
kept++;
@@ -2483,13 +2500,15 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
if (totalsize > 0 && tile.layers.size() > 0) {
if (totalsize > scaled_max_tile_features && !prevent[P_FEATURE_LIMIT]) {
if (too_many_features || (totalsize > scaled_max_tile_features && !prevent[P_FEATURE_LIMIT])) {
if (totalsize > arg->feature_count_out) {
arg->feature_count_out = totalsize;
}
size_t estimated = totalsize * (skipped + kept) / kept;
if (!quiet) {
fprintf(stderr, "tile %d/%u/%u has %zu features, >%zu \n", z, tx, ty, totalsize, scaled_max_tile_features);
fprintf(stderr, "tile %d/%u/%u has %zu (estimated %zu) features, >%zu \n", z, tx, ty, totalsize, estimated, scaled_max_tile_features);
}
if (trying_to_stop_early && line_detail == first_detail) {
@@ -2515,7 +2534,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
line_detail++; // to keep it the same when the loop decrements it
continue;
} else if (mingap < ULONG_MAX && (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED])) {
mingap_fraction = mingap_fraction * scaled_max_tile_features / totalsize * 0.80;
mingap_fraction = mingap_fraction * scaled_max_tile_features / estimated * 0.80;
unsigned long long m = choose_mingap(gaps, mingap_fraction, mingap);
if (m != mingap) {
mingap = m;
@@ -2530,7 +2549,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
continue;
}
} else if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
minextent_fraction = minextent_fraction * scaled_max_tile_features / totalsize * 0.75;
minextent_fraction = minextent_fraction * scaled_max_tile_features / estimated * 0.75;
long long m = choose_minextent(extents, minextent_fraction, minextent);
if (m != minextent) {
minextent = m;
@@ -2548,7 +2567,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
// The 95% is a guess to avoid too many retries
// and probably actually varies based on how much duplicated metadata there is
mindrop_sequence_fraction = mindrop_sequence_fraction * scaled_max_tile_features / totalsize * 0.95;
mindrop_sequence_fraction = mindrop_sequence_fraction * scaled_max_tile_features / estimated * 0.95;
unsigned long long m = choose_mindrop_sequence(drop_sequences, mindrop_sequence_fraction, mindrop_sequence);
if (m != mindrop_sequence) {
mindrop_sequence = m;
@@ -2585,7 +2604,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
// printf("%lld %zu\n", estimated_complexity, compressed.size());
}
if (compressed.size() > scaled_max_tile_size && !prevent[P_KILOBYTE_LIMIT]) {
if (too_many_bytes || (compressed.size() > scaled_max_tile_size && !prevent[P_KILOBYTE_LIMIT])) {
// Estimate how big it really should have been compressed
// from how many features were kept vs skipped for already being
// over the threshold
@@ -2682,6 +2701,11 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
exit(EXIT_PTHREAD);
}
if (skipped > 0 || too_many_bytes || too_many_features) {
fprintf(stderr, "Can't happen: writing tile even though we skipped\n");
exit(EXIT_IMPOSSIBLE);
}
if (outdb != NULL) {
mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size());
} else if (outdir != NULL) {
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.58.0"
#define VERSION "v2.59.0"
#endif