mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-23 20:35:16 +00:00
Include metadata in tippecanoe-decode. Allow multiple inputs for tests.
This commit is contained in:
parent
6d38eff2a2
commit
7c021035a6
16
Makefile
16
Makefile
@ -66,13 +66,21 @@ indent:
|
||||
TESTS = $(wildcard tests/*/out/*.json)
|
||||
SPACE = $(NULL) $(NULL)
|
||||
|
||||
prep-test:
|
||||
set -x; for i in $(TESTS); do ./tippecanoe -o /tmp/$$$$.mbtiles $$(echo $$i | awk -F/ '{ print $$4 }' | sed 's/\.json$$//' | tr '_' ' ') $$(echo $$i | awk -F/ '{ print $$1 "/" $$2 "/in.json" }'); ./tippecanoe-decode /tmp/$$$$.mbtiles > $$i; rm -f /tmp/$$$$.mbtiles; done
|
||||
|
||||
test: tippecanoe tippecanoe-decode $(addsuffix .check,$(TESTS))
|
||||
|
||||
%.json.check:
|
||||
./tippecanoe -f -o $@.mbtiles $(subst _, ,$(patsubst %.json.check,%,$(word 4,$(subst /, ,$@)))) $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/in.json
|
||||
./tippecanoe -f -o $@.mbtiles $(subst _, ,$(patsubst %.json.check,%,$(word 4,$(subst /, ,$@)))) $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.json)
|
||||
./tippecanoe-decode $@.mbtiles > $@.out
|
||||
cmp $(patsubst %.check,%,$@) $@.out
|
||||
rm $@.out $@.mbtiles
|
||||
|
||||
# Use this target to regenerate the standards that the tests are compared against
|
||||
# after making a change that legitimately changes their output
|
||||
|
||||
prep-test: $(TESTS)
|
||||
|
||||
tests/%.json: Makefile tippecanoe tippecanoe-decode
|
||||
./tippecanoe -f -o $@.mbtiles $(subst _, ,$(patsubst %.json,%,$(word 4,$(subst /, ,$@)))) $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.json)
|
||||
./tippecanoe-decode $@.mbtiles > $@
|
||||
cmp $(patsubst %.check,%,$@) $@
|
||||
rm $@.mbtiles
|
||||
|
30
decode.cc
30
decode.cc
@ -360,6 +360,32 @@ void decode(char *fname, int z, unsigned x, unsigned y) {
|
||||
}
|
||||
|
||||
if (z < 0) {
|
||||
printf("{ \"type\": \"FeatureCollection\", \"properties\": {\n");
|
||||
|
||||
const char *sql2 = "SELECT name, value from metadata order by name;";
|
||||
sqlite3_stmt *stmt2;
|
||||
if (sqlite3_prepare_v2(db, sql2, -1, &stmt2, NULL) != SQLITE_OK) {
|
||||
fprintf(stderr, "%s: select failed: %s\n", fname, sqlite3_errmsg(db));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int within = 0;
|
||||
while (sqlite3_step(stmt2) == SQLITE_ROW) {
|
||||
if (within) {
|
||||
printf(",\n");
|
||||
}
|
||||
within = 1;
|
||||
|
||||
const unsigned char *name = sqlite3_column_text(stmt2, 0);
|
||||
const unsigned char *value = sqlite3_column_text(stmt2, 1);
|
||||
|
||||
printq((char *) name);
|
||||
printf(": ");
|
||||
printq((char *) value);
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt2);
|
||||
|
||||
const char *sql = "SELECT tile_data, zoom_level, tile_column, tile_row from tiles order by zoom_level, tile_column, tile_row;";
|
||||
sqlite3_stmt *stmt;
|
||||
if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) {
|
||||
@ -367,9 +393,9 @@ void decode(char *fname, int z, unsigned x, unsigned y) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("{ \"type\": \"FeatureCollection\", \"features\": [\n");
|
||||
printf("\n}, \"features\": [\n");
|
||||
|
||||
int within = 0;
|
||||
within = 0;
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
if (within) {
|
||||
printf(",\n");
|
||||
|
@ -1,4 +1,15 @@
|
||||
{ "type": "FeatureCollection", "features": [
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"bounds": "-124.213808,29.689480,-70.645734,49.005640",
|
||||
"center": "-78.750000,31.461472,4",
|
||||
"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json.mbtiles",
|
||||
"format": "pbf",
|
||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 4, \"fields\": {} } ] }",
|
||||
"maxzoom": "4",
|
||||
"minzoom": "0",
|
||||
"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-X_-z4.json.mbtiles",
|
||||
"type": "overlay",
|
||||
"version": "1"
|
||||
}, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ -124.013672, 46.316584 ], [ -123.486328, 46.316584 ], [ -122.958984, 46.134170 ], [ -122.695312, 45.644768 ], [ -122.431641, 45.644768 ], [ -121.640625, 45.767523 ], [ -121.113281, 45.644768 ], [ -120.673828, 45.767523 ], [ -120.234375, 45.767523 ], [ -119.619141, 45.951150 ], [ -119.355469, 45.890008 ], [ -119.003906, 46.012224 ], [ -116.982422, 46.012224 ] ] } }
|
||||
|
@ -1,4 +1,15 @@
|
||||
{ "type": "FeatureCollection", "features": [
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"bounds": "-124.213808,29.689480,-70.645734,49.005640",
|
||||
"center": "-82.968750,37.710240,7",
|
||||
"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json.mbtiles",
|
||||
"format": "pbf",
|
||||
"json": "{\"vector_layers\": [ { \"id\": \"countries\", \"description\": \"\", \"minzoom\": 1, \"maxzoom\": 7, \"fields\": {\"adm0_a3\": \"String\", \"adm0_name\": \"String\", \"mapcolor9\": \"Number\", \"mapcolor13\": \"Number\"} } ] }",
|
||||
"maxzoom": "7",
|
||||
"minzoom": "1",
|
||||
"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-lcountries_-P_-Z1_-z7_-b4_-xfeaturecla_-xscalerank_-acrol_-ps.json.mbtiles",
|
||||
"type": "overlay",
|
||||
"version": "1"
|
||||
}, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "countries" }, "features": [
|
||||
{ "type": "Feature", "properties": { "adm0_a3": "USA", "adm0_name": "United States of America", "mapcolor9": 1, "mapcolor13": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ -124.013672, 46.286224 ], [ -123.793945, 46.286224 ], [ -123.486328, 46.286224 ], [ -123.266602, 46.195042 ], [ -122.958984, 46.134170 ], [ -122.783203, 45.951150 ], [ -122.739258, 45.798170 ], [ -122.695312, 45.644768 ], [ -122.431641, 45.614037 ], [ -122.211914, 45.614037 ], [ -121.816406, 45.706179 ], [ -121.596680, 45.736860 ], [ -121.245117, 45.706179 ], [ -121.069336, 45.644768 ], [ -120.849609, 45.675482 ], [ -120.629883, 45.767523 ], [ -120.190430, 45.767523 ], [ -119.794922, 45.859412 ], [ -119.619141, 45.951150 ], [ -119.355469, 45.890008 ], [ -119.003906, 46.012224 ], [ -116.938477, 46.012224 ] ] } }
|
||||
|
@ -1,4 +1,15 @@
|
||||
{ "type": "FeatureCollection", "features": [
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"bounds": "-124.213808,29.689480,-70.645734,49.005640",
|
||||
"center": "-84.375000,36.466030,5",
|
||||
"description": "tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json.mbtiles",
|
||||
"format": "pbf",
|
||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 5, \"fields\": {\"mapcolor9\": \"Number\", \"mapcolor13\": \"Number\"} } ] }",
|
||||
"maxzoom": "5",
|
||||
"minzoom": "0",
|
||||
"name": "tests/ne_110m_admin_1_states_provinces_lines/out/-z5_-ymapcolor13_-ymapcolor9_-pSi_-d8_-D16.json.mbtiles",
|
||||
"type": "overlay",
|
||||
"version": "1"
|
||||
}, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { "mapcolor9": 1, "mapcolor13": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ -74.707031, 41.376809 ], [ -74.882812, 41.442726 ], [ -75.014648, 41.508577 ], [ -75.102539, 41.672912 ], [ -75.058594, 41.771312 ], [ -75.190430, 41.869561 ], [ -75.410156, 42.000325 ], [ -76.772461, 42.032974 ], [ -78.222656, 42.000325 ], [ -79.760742, 42.000325 ], [ -79.760742, 42.261049 ] ] } }
|
||||
|
@ -1,4 +1,15 @@
|
||||
{ "type": "FeatureCollection", "features": [
|
||||
{ "type": "FeatureCollection", "properties": {
|
||||
"bounds": "-1.000000,-1.000000,1.000000,1.000000",
|
||||
"center": "1.000000,-1.000000,4",
|
||||
"description": "tests/nullisland/out/-b0_-z4.json.mbtiles",
|
||||
"format": "pbf",
|
||||
"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 4, \"fields\": {} } ] }",
|
||||
"maxzoom": "4",
|
||||
"minzoom": "0",
|
||||
"name": "tests/nullisland/out/-b0_-z4.json.mbtiles",
|
||||
"type": "overlay",
|
||||
"version": "1"
|
||||
}, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "in" }, "features": [
|
||||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.000000 ], [ -1.054688, 0.000000 ], [ -1.054688, 1.054628 ], [ 0.000000, 1.054628 ], [ 0.000000, 0.000000 ] ] ] } }
|
||||
|
Loading…
x
Reference in New Issue
Block a user