diff --git a/CHANGELOG.md b/CHANGELOG.md index 91c17c3b..108fa820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.34.1 + +* Don't run shell filters if the current zoom is below the minzoom +* Fix -Z and -z for tile directories in tile-join and tippecanoe-decode +* Return a successful error status for --help and --version + ## 1.34.0 * Record the command line options in the tileset metadata diff --git a/Makefile b/Makefile index b96a5c62..ae542a1f 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,14 @@ raw-tiles-test: ./tippecanoe -q -f -e tests/raw-tiles/raw-tiles -r1 -pC tests/raw-tiles/hackspots.geojson ./tippecanoe-decode -x generator tests/raw-tiles/raw-tiles > tests/raw-tiles/raw-tiles.json.check cmp tests/raw-tiles/raw-tiles.json.check tests/raw-tiles/raw-tiles.json - rm -rf tests/raw-tiles/raw-tiles tests/raw-tiles/compare.json.check + # Test that -z and -Z work in tippecanoe-decode + ./tippecanoe-decode -x generator -Z6 -z7 tests/raw-tiles/raw-tiles > tests/raw-tiles/raw-tiles-z67.json.check + cmp tests/raw-tiles/raw-tiles-z67.json.check tests/raw-tiles/raw-tiles-z67.json + # Test that -z and -Z work in tile-join + ./tile-join -q -f -Z6 -z7 -e tests/raw-tiles/raw-tiles-z67 tests/raw-tiles/raw-tiles + ./tippecanoe-decode -x generator tests/raw-tiles/raw-tiles-z67 > tests/raw-tiles/raw-tiles-z67-join.json.check + cmp tests/raw-tiles/raw-tiles-z67-join.json.check tests/raw-tiles/raw-tiles-z67-join.json + rm -rf tests/raw-tiles/raw-tiles tests/raw-tiles/raw-tiles-z67 tests/raw-tiles/raw-tiles.json.check raw-tiles-z67.json.check tests/raw-tiles/raw-tiles-z67-join.json.check # Test that metadata.json is created even if all features are clipped away ./tippecanoe -q -f -e tests/raw-tiles/nothing tests/raw-tiles/nothing.geojson ./tippecanoe-decode -x generator tests/raw-tiles/nothing > tests/raw-tiles/nothing.json.check diff --git a/README.md b/README.md index 5755f44a..ca38c461 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ $ brew install tippecanoe On Ubuntu it will usually be easiest to build from the source repository: ```sh -$ git clone git@github.com:mapbox/tippecanoe.git +$ git clone https://github.com/mapbox/tippecanoe.git $ cd tippecanoe $ make -j $ make install diff --git a/decode.cpp b/decode.cpp index 86e58fbd..e75248c1 100644 --- a/decode.cpp +++ b/decode.cpp @@ -268,7 +268,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set co isdir = true; db = dirmeta2tmp(fname); - tiles = enumerate_dirtiles(fname); + tiles = enumerate_dirtiles(fname, minzoom, maxzoom); } else { if (sqlite3_open(fname, &db) != SQLITE_OK) { fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db)); diff --git a/dirtiles.cpp b/dirtiles.cpp index b946e07c..a5418a12 100644 --- a/dirtiles.cpp +++ b/dirtiles.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include "jsonpull/jsonpull.h" @@ -84,7 +85,7 @@ void check_dir(const char *dir, char **argv, bool force, bool forcetable) { return; } - std::vector tiles = enumerate_dirtiles(dir); + std::vector tiles = enumerate_dirtiles(dir, INT_MIN, INT_MAX); for (size_t i = 0; i < tiles.size(); i++) { std::string fn = std::string(dir) + "/" + tiles[i].path(); @@ -101,14 +102,14 @@ void check_dir(const char *dir, char **argv, bool force, bool forcetable) { } } -std::vector enumerate_dirtiles(const char *fname) { +std::vector enumerate_dirtiles(const char *fname, int minzoom, int maxzoom) { std::vector tiles; DIR *d1 = opendir(fname); if (d1 != NULL) { struct dirent *dp; while ((dp = readdir(d1)) != NULL) { - if (numeric(dp->d_name)) { + if (numeric(dp->d_name) && atoi(dp->d_name) >= minzoom && atoi(dp->d_name) <= maxzoom) { std::string z = std::string(fname) + "/" + dp->d_name; int tz = atoi(dp->d_name); diff --git a/dirtiles.hpp b/dirtiles.hpp index 52b7f47b..6855f9aa 100644 --- a/dirtiles.hpp +++ b/dirtiles.hpp @@ -42,7 +42,7 @@ struct zxy { } }; -std::vector enumerate_dirtiles(const char *fname); +std::vector enumerate_dirtiles(const char *fname, int minzoom, int maxzoom); sqlite3 *dirmeta2tmp(const char *fname); std::string dir_read_tile(std::string pbfPath, struct zxy tile); diff --git a/main.cpp b/main.cpp index a15d8758..8d7cb9a0 100644 --- a/main.cpp +++ b/main.cpp @@ -2626,7 +2626,7 @@ int main(int argc, char **argv) { {"check-polygons", no_argument, &additional[A_DEBUG_POLYGON], 1}, {"no-polygon-splitting", no_argument, &prevent[P_POLYGON_SPLIT], 1}, {"prefer-radix-sort", no_argument, &additional[A_PREFER_RADIX_SORT], 1}, - {"help", no_argument, 0, '?'}, + {"help", no_argument, 0, 'H'}, {0, 0, 0, 0}, }; @@ -2963,7 +2963,7 @@ int main(int argc, char **argv) { case 'v': fprintf(stderr, "tippecanoe %s\n", VERSION); - exit(EXIT_FAILURE); + exit(EXIT_SUCCESS); case 'P': read_parallel = 1; @@ -3006,7 +3006,7 @@ int main(int argc, char **argv) { break; default: { - if (i != '?') { + if (i != 'H' && i != '?') { fprintf(stderr, "Unknown option -%c\n", i); } int width = 7 + strlen(argv[0]); @@ -3036,7 +3036,11 @@ int main(int argc, char **argv) { width = 8; } fprintf(stderr, "\n"); - exit(EXIT_FAILURE); + if (i == 'H') { + exit(EXIT_SUCCESS); + } else { + exit(EXIT_FAILURE); + } } } } diff --git a/man/tippecanoe.1 b/man/tippecanoe.1 index c6865f60..af528c0a 100644 --- a/man/tippecanoe.1 +++ b/man/tippecanoe.1 @@ -40,7 +40,7 @@ On Ubuntu it will usually be easiest to build from the source repository: .PP .RS .nf -$ git clone git@github.com:mapbox/tippecanoe.git +$ git clone https://github.com/mapbox/tippecanoe.git $ cd tippecanoe $ make \-j $ make install @@ -781,6 +781,14 @@ the filename or name specified using \fB\fC\-\-layer\fR, like this: } .fi .RE +.PP +If your source GeoJSON only has \fB\fCminzoom\fR, \fB\fCmaxzoom\fR and/or \fB\fClayer\fR within \fB\fCproperties\fR you can use ndjson\-cli \[la]https://github.com/mbostock/ndjson-cli/blob/master/README.md\[ra] to move them into the required \fB\fCtippecanoe\fR object by piping the GeoJSON like this: +.PP +.RS +.nf +ndjson\-map 'd.tippecanoe = { minzoom: d.properties.minzoom, maxzoom: d.properties.maxzoom, layer: d.properties.layer }, delete d.properties.minzoom, delete d.properties.maxzoom, delete d.properties.layer, d' +.fi +.RE .SH Geometric simplifications .PP At every zoom level, line and polygon features are subjected to Douglas\-Peucker diff --git a/serial.cpp b/serial.cpp index 98ac1ef0..149de01c 100644 --- a/serial.cpp +++ b/serial.cpp @@ -633,7 +633,6 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) { sf.full_values.erase(sf.full_values.begin() + i); continue; } - } if (!sst->filters) { diff --git a/tests/raw-tiles/raw-tiles-z67-join.json b/tests/raw-tiles/raw-tiles-z67-join.json new file mode 100644 index 00000000..ad8b596c --- /dev/null +++ b/tests/raw-tiles/raw-tiles-z67-join.json @@ -0,0 +1,37 @@ +{ "type": "FeatureCollection", "properties": { +"bounds": "-123.750000,45.089036,-120.937500,47.040182", +"center": "-122.662354,45.514045,7", +"description": "tests/raw-tiles/raw-tiles", +"format": "pbf", +"generator_options": "./tippecanoe -q -f -e tests/raw-tiles/raw-tiles -r1 -pC tests/raw-tiles/hackspots.geojson; ./tile-join -q -f -Z6 -z7 -e tests/raw-tiles/raw-tiles-z67 tests/raw-tiles/raw-tiles", +"json": "{\"vector_layers\": [ { \"id\": \"hackspots\", \"description\": \"\", \"minzoom\": 6, \"maxzoom\": 7, \"fields\": {\"Address\": \"String\", \"Name\": \"String\", \"Notes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"hackspots\",\"count\": 8,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"Address\",\"count\": 4,\"type\": \"string\",\"values\": [\"1507 N Rosa Parks Way Portland, OR 97217\",\"201 SE 12th Ave, Portland, OR 97214\",\"4637 N Albina Ave Portland, OR 97217\",\"915 SE Hawthorne Blvd. Portland, OR 97214\"]},{\"attribute\": \"Name\",\"count\": 4,\"type\": \"string\",\"values\": [\"Albina Press\",\"Arbor Lodge\",\"Lucky Labrador Brew Pub\",\"Three Friends Coffeehouse\"]},{\"attribute\": \"Notes\",\"count\": 3,\"type\": \"string\",\"values\": [\"\",\"Dog friendly\",\"usually busy, outlets on side wall only\"]}]}]}}", +"maxzoom": "7", +"minzoom": "6", +"name": "tests/raw-tiles/raw-tiles", +"type": "overlay", +"version": "2" +}, "features": [ +{ "type": "FeatureCollection", "properties": { "zoom": 6, "x": 10, "y": 22 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "hackspots", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "Name": "Arbor Lodge", "Address": "1507 N Rosa Parks Way Portland, OR 97217", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.682953, 45.570794 ] } } +, +{ "type": "Feature", "properties": { "Name": "Albina Press", "Address": "4637 N Albina Ave Portland, OR 97217", "Notes": "usually busy, outlets on side wall only" }, "geometry": { "type": "Point", "coordinates": [ -122.676086, 45.557333 ] } } +, +{ "type": "Feature", "properties": { "Name": "Three Friends Coffeehouse", "Address": "201 SE 12th Ave, Portland, OR 97214", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.655487, 45.521744 ] } } +, +{ "type": "Feature", "properties": { "Name": "Lucky Labrador Brew Pub", "Address": "915 SE Hawthorne Blvd. Portland, OR 97214", "Notes": "Dog friendly" }, "geometry": { "type": "Point", "coordinates": [ -122.656860, 45.513084 ] } } +] } +] } +, +{ "type": "FeatureCollection", "properties": { "zoom": 7, "x": 20, "y": 45 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "hackspots", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "Name": "Arbor Lodge", "Address": "1507 N Rosa Parks Way Portland, OR 97217", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.682953, 45.570313 ] } } +, +{ "type": "Feature", "properties": { "Name": "Albina Press", "Address": "4637 N Albina Ave Portland, OR 97217", "Notes": "usually busy, outlets on side wall only" }, "geometry": { "type": "Point", "coordinates": [ -122.675400, 45.556853 ] } } +, +{ "type": "Feature", "properties": { "Name": "Three Friends Coffeehouse", "Address": "201 SE 12th Ave, Portland, OR 97214", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.655487, 45.521263 ] } } +, +{ "type": "Feature", "properties": { "Name": "Lucky Labrador Brew Pub", "Address": "915 SE Hawthorne Blvd. Portland, OR 97214", "Notes": "Dog friendly" }, "geometry": { "type": "Point", "coordinates": [ -122.656860, 45.512602 ] } } +] } +] } +] } diff --git a/tests/raw-tiles/raw-tiles-z67.json b/tests/raw-tiles/raw-tiles-z67.json new file mode 100644 index 00000000..b16760b4 --- /dev/null +++ b/tests/raw-tiles/raw-tiles-z67.json @@ -0,0 +1,37 @@ +{ "type": "FeatureCollection", "properties": { +"bounds": "-122.682427,45.512331,-122.654961,45.569975", +"center": "-122.662354,45.514045,14", +"description": "tests/raw-tiles/raw-tiles", +"format": "pbf", +"generator_options": "./tippecanoe -q -f -e tests/raw-tiles/raw-tiles -r1 -pC tests/raw-tiles/hackspots.geojson", +"json": "{\"vector_layers\": [ { \"id\": \"hackspots\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 14, \"fields\": {\"Address\": \"String\", \"Name\": \"String\", \"Notes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"hackspots\",\"count\": 4,\"geometry\": \"Point\",\"attributeCount\": 3,\"attributes\": [{\"attribute\": \"Address\",\"count\": 4,\"type\": \"string\",\"values\": [\"1507 N Rosa Parks Way Portland, OR 97217\",\"201 SE 12th Ave, Portland, OR 97214\",\"4637 N Albina Ave Portland, OR 97217\",\"915 SE Hawthorne Blvd. Portland, OR 97214\"]},{\"attribute\": \"Name\",\"count\": 4,\"type\": \"string\",\"values\": [\"Albina Press\",\"Arbor Lodge\",\"Lucky Labrador Brew Pub\",\"Three Friends Coffeehouse\"]},{\"attribute\": \"Notes\",\"count\": 3,\"type\": \"string\",\"values\": [\"\",\"Dog friendly\",\"usually busy, outlets on side wall only\"]}]}]}}", +"maxzoom": "14", +"minzoom": "0", +"name": "tests/raw-tiles/raw-tiles", +"type": "overlay", +"version": "2" +}, "features": [ +{ "type": "FeatureCollection", "properties": { "zoom": 6, "x": 10, "y": 22, "compressed": false }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "hackspots", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "Name": "Arbor Lodge", "Address": "1507 N Rosa Parks Way Portland, OR 97217", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.682953, 45.570794 ] } } +, +{ "type": "Feature", "properties": { "Name": "Albina Press", "Address": "4637 N Albina Ave Portland, OR 97217", "Notes": "usually busy, outlets on side wall only" }, "geometry": { "type": "Point", "coordinates": [ -122.676086, 45.557333 ] } } +, +{ "type": "Feature", "properties": { "Name": "Three Friends Coffeehouse", "Address": "201 SE 12th Ave, Portland, OR 97214", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.655487, 45.521744 ] } } +, +{ "type": "Feature", "properties": { "Name": "Lucky Labrador Brew Pub", "Address": "915 SE Hawthorne Blvd. Portland, OR 97214", "Notes": "Dog friendly" }, "geometry": { "type": "Point", "coordinates": [ -122.656860, 45.513084 ] } } +] } +] } +, +{ "type": "FeatureCollection", "properties": { "zoom": 7, "x": 20, "y": 45, "compressed": false }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "hackspots", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "Name": "Arbor Lodge", "Address": "1507 N Rosa Parks Way Portland, OR 97217", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.682953, 45.570313 ] } } +, +{ "type": "Feature", "properties": { "Name": "Albina Press", "Address": "4637 N Albina Ave Portland, OR 97217", "Notes": "usually busy, outlets on side wall only" }, "geometry": { "type": "Point", "coordinates": [ -122.675400, 45.556853 ] } } +, +{ "type": "Feature", "properties": { "Name": "Three Friends Coffeehouse", "Address": "201 SE 12th Ave, Portland, OR 97214", "Notes": "" }, "geometry": { "type": "Point", "coordinates": [ -122.655487, 45.521263 ] } } +, +{ "type": "Feature", "properties": { "Name": "Lucky Labrador Brew Pub", "Address": "915 SE Hawthorne Blvd. Portland, OR 97214", "Notes": "Dog friendly" }, "geometry": { "type": "Point", "coordinates": [ -122.656860, 45.512602 ] } } +] } +] } +] } diff --git a/tile-join.cpp b/tile-join.cpp index 25e313c4..25e63ef7 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -410,7 +410,7 @@ struct reader *begin_reading(char *fname) { r->stmt = NULL; r->next = NULL; - r->dirtiles = enumerate_dirtiles(fname); + r->dirtiles = enumerate_dirtiles(fname, minzoom, maxzoom); r->dirbase = fname; if (r->dirtiles.size() == 0) { diff --git a/tile.cpp b/tile.cpp index 72672f74..6e76c504 100644 --- a/tile.cpp +++ b/tile.cpp @@ -1786,6 +1786,11 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta FILE *prefilter_read_fp = NULL; json_pull *prefilter_jp = NULL; + if (z < minzoom) { + prefilter = NULL; + postfilter = NULL; + } + if (prefilter != NULL) { setup_filter(prefilter, &prefilter_write, &prefilter_read, &prefilter_pid, z, tx, ty); prefilter_fp = fdopen(prefilter_write, "w"); diff --git a/version.hpp b/version.hpp index 8df8062f..799d28ad 100644 --- a/version.hpp +++ b/version.hpp @@ -1,6 +1,6 @@ #ifndef VERSION_HPP #define VERSION_HPP -#define VERSION "v1.34.0" +#define VERSION "v1.34.1" #endif