From d4504da2f5b1f0b4782b9d158b382e5bab3c8331 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 27 Apr 2016 11:36:56 -0700 Subject: [PATCH] Rationalize the highest allowed maxzoom in terms of detail --- geojson.c | 27 ++++++++----- tests/highzoom/out/-z30.json | 78 ++---------------------------------- 2 files changed, 20 insertions(+), 85 deletions(-) diff --git a/geojson.c b/geojson.c index e5c7afa..009ac9a 100644 --- a/geojson.c +++ b/geojson.c @@ -750,7 +750,8 @@ int serialize_geometry(json_object *geometry, json_object *properties, const cha */ int feature_minzoom = 0; if (mb_geometry[t] == VT_LINE) { - for (feature_minzoom = 0; feature_minzoom < 31; feature_minzoom++) { + // Skip z0 check because everything is always in the one z0 tile + for (feature_minzoom = 1; feature_minzoom < 31; feature_minzoom++) { unsigned mask = 1 << (32 - (feature_minzoom + 1)); if (((bbox[0] & mask) != (bbox[2] & mask)) || ((bbox[1] & mask) != (bbox[3] & mask))) { @@ -2774,6 +2775,21 @@ int main(int argc, char **argv) { files_open_at_start = open("/dev/null", O_RDONLY); close(files_open_at_start); + if (full_detail <= 0) { + full_detail = 12; + } + + if (full_detail < min_detail || low_detail < min_detail) { + fprintf(stderr, "%s: Full detail and low detail must be at least minimum detail\n", argv[0]); + exit(EXIT_FAILURE); + } + + // Need two checks: one for geometry representation, the other for + // index traversal when guessing base zoom and drop rate + if (maxzoom > 32 - full_detail) { + maxzoom = 32 - full_detail; + fprintf(stderr, "Highest supported zoom with detail %d is %d\n", full_detail, maxzoom); + } if (maxzoom > MAX_ZOOM) { maxzoom = MAX_ZOOM; fprintf(stderr, "Highest supported zoom is %d\n", maxzoom); @@ -2788,15 +2804,6 @@ int main(int argc, char **argv) { basezoom = maxzoom; } - if (full_detail <= 0) { - full_detail = 12; - } - - if (full_detail < min_detail || low_detail < min_detail) { - fprintf(stderr, "%s: Full detail and low detail must be at least minimum detail\n", argv[0]); - exit(EXIT_FAILURE); - } - geometry_scale = 32 - (full_detail + maxzoom); if (geometry_scale < 0) { geometry_scale = 0; diff --git a/tests/highzoom/out/-z30.json b/tests/highzoom/out/-z30.json index 3c714e3..1790e81 100644 --- a/tests/highzoom/out/-z30.json +++ b/tests/highzoom/out/-z30.json @@ -1,10 +1,10 @@ { "type": "FeatureCollection", "properties": { "bounds": "-122.000000,37.000000,0.000000,51.500000", -"center": "-122.000000,37.000008,24", +"center": "-121.999912,37.000000,20", "description": "tests/highzoom/out/-z30.json.check.mbtiles", "format": "pbf", -"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 24, \"fields\": {\"name\": \"String\"} } ] }", -"maxzoom": "24", +"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 20, \"fields\": {\"name\": \"String\"} } ] }", +"maxzoom": "20", "minzoom": "0", "name": "tests/highzoom/out/-z30.json.check.mbtiles", "type": "overlay", @@ -369,76 +369,4 @@ { "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 51.500000 ] } } ] } ] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 21, "x": 337874, "y": 816274 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "Santa Cruz" }, "geometry": { "type": "Point", "coordinates": [ -122.000084, 37.000085 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 21, "x": 1048575, "y": 697425 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ -0.000172, 51.500087 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 21, "x": 1048576, "y": 697425 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 51.500087 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 22, "x": 675748, "y": 1632549 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "Santa Cruz" }, "geometry": { "type": "Point", "coordinates": [ -122.000084, 37.000016 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 22, "x": 2097151, "y": 1394851 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ -0.000086, 51.500034 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 22, "x": 2097152, "y": 1394851 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 51.500034 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 23, "x": 1351497, "y": 3265098 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "Santa Cruz" }, "geometry": { "type": "Point", "coordinates": [ -122.000041, 37.000016 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 23, "x": 4194303, "y": 2789703 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ -0.000043, 51.500007 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 23, "x": 4194304, "y": 2789703 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 51.500007 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 24, "x": 2702995, "y": 6530196 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "Santa Cruz" }, "geometry": { "type": "Point", "coordinates": [ -122.000020, 37.000016 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 24, "x": 8388607, "y": 5579406 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ -0.000021, 51.500007 ] } } -] } -] } -, -{ "type": "FeatureCollection", "properties": { "zoom": 24, "x": 8388608, "y": 5579406 }, "features": [ -{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [ -{ "type": "Feature", "properties": { "name": "London" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 51.500007 ] } } -] } -] } ] }