Pmtiles tests pass now too

This commit is contained in:
Erica Fischer
2022-12-27 14:18:59 -08:00
parent 1cb467a382
commit fa37859adb
10 changed files with 21 additions and 13 deletions
+4 -4
View File
@@ -177,19 +177,19 @@ pmtiles-test:
# From raw-tiles-test:
./tippecanoe -q -f -o tests/raw-tiles/raw-tiles.pmtiles -r1 -pC tests/raw-tiles/hackspots.geojson
./tippecanoe-decode -x generator tests/raw-tiles/raw-tiles.pmtiles > tests/raw-tiles/raw-tiles.json.check
./tippecanoe-decode -x generator tests/raw-tiles/raw-tiles.pmtiles | sed 's/\.pmtiles//g' | sed 's/ -o / -e /g' > tests/raw-tiles/raw-tiles.json.check
cmp tests/raw-tiles/raw-tiles.json.check tests/raw-tiles/raw-tiles.json
# Test that -z and -Z work in tippecanoe-decode
./tippecanoe-decode -x generator -Z6 -z7 tests/raw-tiles/raw-tiles.pmtiles > tests/raw-tiles/raw-tiles-z67.json.check
./tippecanoe-decode -x generator -Z6 -z7 tests/raw-tiles/raw-tiles.pmtiles | sed 's/\.pmtiles//g' | sed 's/ -o / -e /g' > 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 -o tests/raw-tiles/raw-tiles-z67.pmtiles tests/raw-tiles/raw-tiles.pmtiles
./tippecanoe-decode -x generator tests/raw-tiles/raw-tiles-z67.pmtiles > tests/raw-tiles/raw-tiles-z67-join.json.check
./tippecanoe-decode -x generator tests/raw-tiles/raw-tiles-z67.pmtiles | sed 's/\.pmtiles//g' | sed 's/ -o / -e /g' > 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.pmtiles tests/raw-tiles/raw-tiles-z67.pmtiles 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 -o tests/raw-tiles/nothing.pmtiles tests/raw-tiles/nothing.geojson
./tippecanoe-decode -x generator tests/raw-tiles/nothing.pmtiles > tests/raw-tiles/nothing.json.check
./tippecanoe-decode -x generator tests/raw-tiles/nothing.pmtiles | sed 's/\.pmtiles//g' | sed 's/ -o / -e /g' > tests/raw-tiles/nothing.json.check
cmp tests/raw-tiles/nothing.json.check tests/raw-tiles/nothing.json
rm -r tests/raw-tiles/nothing.pmtiles tests/raw-tiles/nothing.json.check
+4 -2
View File
@@ -275,6 +275,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
char *pmtiles_map;
std::vector<pmtiles::entry_zxy> entries;
bool is_pmtiles = false;
if (stat(fname, &st) == 0 && (st.st_mode & S_IFDIR) != 0) {
isdir = true;
@@ -294,6 +295,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
}
db = pmtilesmeta2tmp(fname, pmtiles_map);
entries = pmtiles_entries_zxy(pmtiles_map, minzoom, maxzoom);
is_pmtiles = true;
} else {
if (sqlite3_open(fname, &db) != SQLITE_OK) {
fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db));
@@ -399,7 +401,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
handle(s, tiles[i].z, tiles[i].x, tiles[i].y, to_decode, pipeline, stats, state, coordinate_mode);
}
} else if (entries.size() > 0) {
} else if (is_pmtiles) {
within = 0;
for (auto const &entry : entries) {
@@ -484,7 +486,7 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
} else {
int handled = 0;
while (z >= 0 && !handled) {
if (entries.size() > 0) {
if (is_pmtiles) {
uint64_t tile_offset;
uint32_t tile_length;
std::tie(tile_offset, tile_length) = pmtiles_get_tile(pmtiles_map, z, x, y);
+6
View File
@@ -421,17 +421,22 @@ sqlite3 *pmtilesmeta2tmp(const char *fname, const char *pmtiles_map) {
bool has_json = false;
std::string buf;
json_writer state(&buf);
state.nospace = true;
state.json_write_hash();
for (size_t i = 0; i < o->value.object.length; i++) {
const char *key = o->value.object.keys[i]->value.string.string;
if (strcmp(key, "vector_layers") == 0 && o->value.object.values[i]->type == JSON_ARRAY) {
has_json = true;
state.nospace = true;
state.json_write_string("vector_layers");
state.nospace = true;
state.json_write_json(json_stringify(o->value.object.values[i]));
} else if (strcmp(key, "tilestats") == 0 && o->value.object.values[i]->type == JSON_HASH) {
has_json = true;
state.nospace = true;
state.json_write_string("tilestats");
state.nospace = true;
state.json_write_json(json_stringify(o->value.object.values[i]));
} else if (strcmp(key, "strategies") == 0 && o->value.object.values[i]->type == JSON_ARRAY) {
sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('strategies', %Q);", json_stringify(o->value.object.values[i]));
@@ -452,6 +457,7 @@ sqlite3 *pmtilesmeta2tmp(const char *fname, const char *pmtiles_map) {
}
json_end(jp);
state.nospace = true;
state.json_end_hash();
if (has_json) {
+1 -1
View File
@@ -4,7 +4,7 @@
"description": "tests/pmtiles/hackspots.pmtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -o tests/pmtiles/hackspots.pmtiles -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\"]}]}]} }",
"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/pmtiles/hackspots.pmtiles",
+1 -1
View File
@@ -4,7 +4,7 @@
"description": "tests/pmtiles/hackspots.pmtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -o tests/pmtiles/hackspots.pmtiles -r1 -pC tests/raw-tiles/hackspots.geojson; ./tile-join -q -f -pC -o tests/pmtiles/joined.mbtiles tests/pmtiles/hackspots.pmtiles",
"json": "{\"vector_layers\": [ { \"id\": \"hackspots\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 14, \"fields\": {\"Address\": \"String\", \"Name\": \"String\", \"Notes\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"hackspots\",\"count\": 62,\"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\"]}]}]}}",
"json": "{\"vector_layers\":[{\"id\":\"hackspots\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":14,\"fields\":{\"Address\":\"String\",\"Name\":\"String\",\"Notes\":\"String\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"hackspots\",\"count\":62,\"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/pmtiles/hackspots.pmtiles",
+1 -1
View File
@@ -4,7 +4,7 @@
"description": "tests/pmtiles/hackspots.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -o tests/pmtiles/hackspots.mbtiles -r1 -pC tests/raw-tiles/hackspots.geojson; ./tile-join -q -f -pC -o tests/pmtiles/joined.pmtiles tests/pmtiles/hackspots.mbtiles",
"json": "{ \"vector_layers\": [{\"id\":\"hackspots\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":14,\"fields\":{\"Address\":\"String\",\"Name\":\"String\",\"Notes\":\"String\"}}], \"tilestats\": {\"layerCount\":1,\"layers\":[{\"layer\":\"hackspots\",\"count\":62,\"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\"]}]}]} }",
"json": "{\"vector_layers\":[{\"id\":\"hackspots\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":14,\"fields\":{\"Address\":\"String\",\"Name\":\"String\",\"Notes\":\"String\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"hackspots\",\"count\":62,\"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/pmtiles/hackspots.mbtiles",
+1 -1
View File
@@ -4,7 +4,7 @@
"description": "tests/raw-tiles/nothing",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -e tests/raw-tiles/nothing tests/raw-tiles/nothing.geojson",
"json": "{\"vector_layers\": [{\"id\":\"nothing\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":14,\"fields\":{}}],\"tilestats\": {\"layerCount\":1,\"layers\":[{\"layer\":\"nothing\",\"count\":1,\"geometry\":\"Point\",\"attributeCount\":0,\"attributes\":[]}]}}",
"json": "{\"vector_layers\":[{\"id\":\"nothing\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":14,\"fields\":{}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"nothing\",\"count\":1,\"geometry\":\"Point\",\"attributeCount\":0,\"attributes\":[]}]}}",
"maxzoom": "14",
"minzoom": "0",
"name": "tests/raw-tiles/nothing",
+1 -1
View File
@@ -4,7 +4,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\"]}]}]}}",
"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",
+1 -1
View File
@@ -4,7 +4,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",
"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\"]}]}]}}",
"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",
+1 -1
View File
@@ -4,7 +4,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",
"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\"]}]}]}}",
"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",