mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-21 12:05:05 +00:00
Merge pull request #735 from mapbox/raw-tiles-zoom-enumerate
Fix -Z and -z for tile directories in tile-join and tippecanoe-decode
This commit is contained in:
commit
b147ff22b1
@ -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
|
||||
|
9
Makefile
9
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
|
||||
|
@ -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
|
||||
|
@ -268,7 +268,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> 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));
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sqlite3.h>
|
||||
#include "jsonpull/jsonpull.h"
|
||||
@ -84,7 +85,7 @@ void check_dir(const char *dir, char **argv, bool force, bool forcetable) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<zxy> tiles = enumerate_dirtiles(dir);
|
||||
std::vector<zxy> 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<zxy> enumerate_dirtiles(const char *fname) {
|
||||
std::vector<zxy> enumerate_dirtiles(const char *fname, int minzoom, int maxzoom) {
|
||||
std::vector<zxy> 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);
|
||||
|
||||
|
@ -42,7 +42,7 @@ struct zxy {
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<zxy> enumerate_dirtiles(const char *fname);
|
||||
std::vector<zxy> 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);
|
||||
|
||||
|
12
main.cpp
12
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
37
tests/raw-tiles/raw-tiles-z67-join.json
Normal file
37
tests/raw-tiles/raw-tiles-z67-join.json
Normal file
@ -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 ] } }
|
||||
] }
|
||||
] }
|
||||
] }
|
37
tests/raw-tiles/raw-tiles-z67.json
Normal file
37
tests/raw-tiles/raw-tiles-z67.json
Normal file
@ -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 ] } }
|
||||
] }
|
||||
] }
|
||||
] }
|
@ -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) {
|
||||
|
5
tile.cpp
5
tile.cpp
@ -1786,6 +1786,11 @@ long long write_tile(FILE *geoms, std::atomic<long long> *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");
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_HPP
|
||||
#define VERSION_HPP
|
||||
|
||||
#define VERSION "v1.34.0"
|
||||
#define VERSION "v1.34.1"
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user