mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-07 02:45:41 +02:00
Pmtiles tests pass now too
This commit is contained in:
@@ -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
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user