Set base zoom if requested as part of maxzoom guessing (#63)

* Set base zoom if requested as part of maxzoom guessing

* Add a test for guessing the maxzoom of a single point

* Don't guess an excessively large maxzoom when there is only one feature

* Update changelog
This commit is contained in:
Erica Fischer
2023-01-26 15:27:06 -08:00
committed by GitHub
parent 54b47a6757
commit 3cb6e4dd5e
7 changed files with 2295 additions and 5 deletions
+5
View File
@@ -1,3 +1,8 @@
## 2.19.0
* Don't guess an excessively large maxzoom when there is only one feature
* Set the base zoom for -Bg as part of the --smallest-maximum-zoom-guess logic
## 2.18.0 ## 2.18.0
* Fix crash when using tile-join to join an empty pmtiles tileset * Fix crash when using tile-join to join an empty pmtiles tileset
+1 -1
View File
@@ -336,7 +336,7 @@ Parallel processing will also be automatic if the input file is in FlatGeobuf fo
* `-z` _zoom_ or `--maximum-zoom=`_zoom_: Maxzoom: the highest zoom level for which tiles are generated (default 14) * `-z` _zoom_ or `--maximum-zoom=`_zoom_: Maxzoom: the highest zoom level for which tiles are generated (default 14)
* `-zg` or `--maximum-zoom=g`: Guess what is probably a reasonable maxzoom based on the spacing of features. * `-zg` or `--maximum-zoom=g`: Guess what is probably a reasonable maxzoom based on the spacing of features.
* `--smallest-maximum-zoom-guess=`_zoom_: Guess what is probably a reasonable maxzoom based on the spacing of features, but using the specified _zoom_ if a lower maxzoom is guessed. * `--smallest-maximum-zoom-guess=`_zoom_: Guess what is probably a reasonable maxzoom based on the spacing of features, but using the specified _zoom_ if a lower maxzoom is guessed. If `-Bg` is also set, the base zoom will be set to the guessed maxzoom, with all the points carried forward into additional zooms through the one specified.
* `-Z` _zoom_ or `--minimum-zoom=`_zoom_: Minzoom: the lowest zoom level for which tiles are generated (default 0) * `-Z` _zoom_ or `--minimum-zoom=`_zoom_: Minzoom: the lowest zoom level for which tiles are generated (default 0)
* `-ae` or `--extend-zooms-if-still-dropping`: Increase the maxzoom if features are still being dropped at that zoom level. * `-ae` or `--extend-zooms-if-still-dropping`: Increase the maxzoom if features are still being dropped at that zoom level.
The detail and simplification options that ordinarily apply only to the maximum zoom level will apply both to the originally The detail and simplification options that ordinarily apply only to the maximum zoom level will apply both to the originally
+15 -3
View File
@@ -2095,7 +2095,12 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
exit(EXIT_NODATA); exit(EXIT_NODATA);
} }
if (count > 0) { if (count == 0 && dist_count == 0) {
maxzoom = minimum_maxzoom;
if (droprate < 0) {
droprate = 1;
}
} else if (count > 0) {
double stddev = sqrt(m2 / count); double stddev = sqrt(m2 / count);
// Geometric mean is appropriate because distances between features // Geometric mean is appropriate because distances between features
@@ -2206,6 +2211,13 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
} }
} }
if (basezoom == -2 && basezoom_marker_width == 1) { // -Bg, not -Bg###
basezoom = maxzoom;
if (!quiet) {
fprintf(stderr, "Using base zoom of -z%d\n", basezoom);
}
}
if (maxzoom < minimum_maxzoom) { if (maxzoom < minimum_maxzoom) {
if (!quiet) { if (!quiet) {
fprintf(stderr, "Using minimum maxzoom of -z%d\n", minimum_maxzoom); fprintf(stderr, "Using minimum maxzoom of -z%d\n", minimum_maxzoom);
@@ -2222,7 +2234,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
fix_dropping = true; fix_dropping = true;
if (basezoom == -1) { if (basezoom == -1) { // basezoom unspecified
basezoom = maxzoom; basezoom = maxzoom;
} }
} }
@@ -3434,7 +3446,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "%s: Reducing minimum detail to match low detail %d\n", argv[0], min_detail); fprintf(stderr, "%s: Reducing minimum detail to match low detail %d\n", argv[0], min_detail);
} }
if (basezoom == -1) { if (basezoom == -1) { // basezoom unspecified
if (!guess_maxzoom) { if (!guess_maxzoom) {
basezoom = maxzoom; basezoom = maxzoom;
} }
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-122,37]}}
@@ -0,0 +1,37 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-122.000000,37.000000,-122.000000,37.000000",
"center": "-122.000000,37.000000,3",
"description": "tests/onefeature-point/out/--smallest-maximum-zoom-guess_3.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/onefeature-point/out/--smallest-maximum-zoom-guess_3.json.check.mbtiles --smallest-maximum-zoom-guess 3 tests/onefeature-point/in.json",
"json": "{\"vector_layers\":[{\"id\":\"in\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":3,\"fields\":{}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"in\",\"count\":1,\"geometry\":\"Point\",\"attributeCount\":0,\"attributes\":[]}]}}",
"maxzoom": "3",
"minzoom": "0",
"name": "tests/onefeature-point/out/--smallest-maximum-zoom-guess_3.json.check.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.080078, 37.020098 ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.036133, 37.020098 ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 0, "y": 1 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.014160, 37.002553 ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 3, "x": 1, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.003174, 37.002553 ] } }
] }
] }
] }
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP #ifndef VERSION_HPP
#define VERSION_HPP #define VERSION_HPP
#define VERSION "v2.18.0" #define VERSION "v2.19.0"
#endif #endif