Make tile-join and tippecanoe-decode more flexible about directories:

* Accept .mvt as well as .pbf in directories of tiles
* Allow tippecanoe-decode and tile-join of directories with no metadata
This commit is contained in:
Eric Fischer
2019-02-20 12:04:10 -08:00
parent b1ae63ab86
commit 8df0455230
5 changed files with 49 additions and 24 deletions
+5
View File
@@ -1,3 +1,8 @@
## 1.32.11
* Accept .mvt as well as .pbf in directories of tiles
* Allow tippecanoe-decode and tile-join of directories with no metadata
## 1.32.10 ## 1.32.10
* Fix a bug that disallowed a per-feature minzoom of 0 * Fix a bug that disallowed a per-feature minzoom of 0
+14 -5
View File
@@ -59,7 +59,7 @@ static bool pbfname(const char *s) {
s++; s++;
} }
return strcmp(s, ".pbf") == 0; return strcmp(s, ".pbf") == 0 || strcmp(s, ".mvt") == 0;
} }
void check_dir(const char *dir, char **argv, bool force, bool forcetable) { void check_dir(const char *dir, char **argv, bool force, bool forcetable) {
@@ -134,7 +134,12 @@ std::vector<zxy> enumerate_dirtiles(const char *fname) {
while ((dp3 = readdir(d3)) != NULL) { while ((dp3 = readdir(d3)) != NULL) {
if (pbfname(dp3->d_name)) { if (pbfname(dp3->d_name)) {
int ty = atoi(dp3->d_name); int ty = atoi(dp3->d_name);
tiles.push_back(zxy(tz, tx, ty)); zxy tile(tz, tx, ty);
if (strstr(dp3->d_name, ".mvt") != NULL) {
tile.extension = ".mvt";
}
tiles.push_back(tile);
} }
} }
@@ -172,11 +177,13 @@ sqlite3 *dirmeta2tmp(const char *fname) {
FILE *f = fopen(name.c_str(), "r"); FILE *f = fopen(name.c_str(), "r");
if (f == NULL) { if (f == NULL) {
perror(name.c_str()); perror(name.c_str());
exit(EXIT_FAILURE); } else {
}
json_pull *jp = json_begin_file(f); json_pull *jp = json_begin_file(f);
json_object *o = json_read_tree(jp); json_object *o = json_read_tree(jp);
if (o == NULL) {
fprintf(stderr, "%s: metadata parsing error: %s\n", name.c_str(), jp->error);
exit(EXIT_FAILURE);
}
if (o->type != JSON_HASH) { if (o->type != JSON_HASH) {
fprintf(stderr, "%s: bad metadata format\n", name.c_str()); fprintf(stderr, "%s: bad metadata format\n", name.c_str());
@@ -197,5 +204,7 @@ sqlite3 *dirmeta2tmp(const char *fname) {
json_end(jp); json_end(jp);
fclose(f); fclose(f);
}
return db; return db;
} }
+3 -1
View File
@@ -1,5 +1,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <sys/stat.h>
#ifndef DIRTILES_HPP #ifndef DIRTILES_HPP
#define DIRTILES_HPP #define DIRTILES_HPP
@@ -12,6 +13,7 @@ struct zxy {
long long z; long long z;
long long x; long long x;
long long y; long long y;
std::string extension = ".pbf";
zxy(int _z, int _x, int _y) zxy(int _z, int _x, int _y)
: z(_z), x(_x), y(_y) { : z(_z), x(_x), y(_y) {
@@ -36,7 +38,7 @@ struct zxy {
} }
std::string path() { std::string path() {
return std::to_string(z) + "/" + std::to_string(x) + "/" + std::to_string(y) + ".pbf"; return std::to_string(z) + "/" + std::to_string(x) + "/" + std::to_string(y) + extension;
} }
}; };
+9
View File
@@ -1092,6 +1092,15 @@ int main(int argc, char **argv) {
name = set_name; name = set_name;
} }
for (auto &l : layermap) {
if (l.second.minzoom < st.minzoom) {
st.minzoom = l.second.minzoom;
}
if (l.second.maxzoom > st.maxzoom) {
st.maxzoom = l.second.maxzoom;
}
}
mbtiles_write_metadata(outdb, out_dir, name.c_str(), st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.midlat, st.midlon, 0, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, true, description.c_str(), !pg, attribute_descriptions, "tile-join"); mbtiles_write_metadata(outdb, out_dir, name.c_str(), st.minzoom, st.maxzoom, st.minlat, st.minlon, st.maxlat, st.maxlon, st.midlat, st.midlon, 0, attribution.size() != 0 ? attribution.c_str() : NULL, layermap, true, description.c_str(), !pg, attribute_descriptions, "tile-join");
if (outdb != NULL) { if (outdb != NULL) {
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP #ifndef VERSION_HPP
#define VERSION_HPP #define VERSION_HPP
#define VERSION "v1.32.10" #define VERSION "v1.32.11"
#endif #endif