Add tile-join options to select zoom levels to copy

This commit is contained in:
Eric Fischer
2017-08-16 13:49:16 -07:00
parent e6fc22187a
commit 4d1ddc5a03
7 changed files with 208 additions and 14 deletions
+27 -13
View File
@@ -35,6 +35,8 @@ int pC = false;
int pg = false;
size_t CPUS;
int quiet = false;
int maxzoom = 32;
int minzoom = 0;
struct stats {
int minzoom;
@@ -693,12 +695,14 @@ void decode(struct reader *readers, char *map, std::map<std::string, layermap_en
maxlat = max(lat1, maxlat);
maxlon = max(lon2, maxlon);
zxy tile = zxy(r->zoom, r->x, r->y);
if (tasks.count(tile) == 0) {
tasks.insert(std::pair<zxy, std::vector<std::string>>(tile, std::vector<std::string>()));
if (r->zoom >= minzoom && r->zoom <= maxzoom) {
zxy tile = zxy(r->zoom, r->x, r->y);
if (tasks.count(tile) == 0) {
tasks.insert(std::pair<zxy, std::vector<std::string>>(tile, std::vector<std::string>()));
}
auto f = tasks.find(tile);
f->second.push_back(r->data);
}
auto f = tasks.find(tile);
f->second.push_back(r->data);
if (readers == NULL || readers->zoom != r->zoom || readers->x != r->x || readers->y != r->y) {
if (tasks.size() > 100 * CPUS) {
@@ -767,15 +771,15 @@ void decode(struct reader *readers, char *map, std::map<std::string, layermap_en
if (sqlite3_prepare_v2(r->db, "SELECT value from metadata where name = 'minzoom'", -1, &r->stmt, NULL) == SQLITE_OK) {
if (sqlite3_step(r->stmt) == SQLITE_ROW) {
int minzoom = sqlite3_column_int(r->stmt, 0);
st->minzoom = min(st->minzoom, minzoom);
int minz = max(sqlite3_column_int(r->stmt, 0), minzoom);
st->minzoom = min(st->minzoom, minz);
}
sqlite3_finalize(r->stmt);
}
if (sqlite3_prepare_v2(r->db, "SELECT value from metadata where name = 'maxzoom'", -1, &r->stmt, NULL) == SQLITE_OK) {
if (sqlite3_step(r->stmt) == SQLITE_ROW) {
int maxzoom = sqlite3_column_int(r->stmt, 0);
st->maxzoom = max(st->maxzoom, maxzoom);
int maxz = min(sqlite3_column_int(r->stmt, 0), maxzoom);
st->maxzoom = max(st->maxzoom, maxz);
}
sqlite3_finalize(r->stmt);
}
@@ -852,14 +856,14 @@ void decode(struct reader *readers, char *map, std::map<std::string, layermap_en
if (j->type == JSON_HASH) {
if ((k = json_hash_get(j, "minzoom")) != NULL) {
const std::string minzoom_tmp = k->string;
int minzoom = std::stoi(minzoom_tmp);
st->minzoom = min(st->minzoom, minzoom);
int minz = max(std::stoi(minzoom_tmp), minzoom);
st->minzoom = min(st->minzoom, minz);
}
if ((k = json_hash_get(j, "maxzoom")) != NULL) {
const std::string maxzoom_tmp = k->string;
int maxzoom = std::stoi(maxzoom_tmp);
st->maxzoom = max(st->maxzoom, maxzoom);
int maxz = min(std::stoi(maxzoom_tmp), maxzoom);
st->maxzoom = max(st->maxzoom, maxz);
}
if ((k = json_hash_get(j, "center")) != NULL) {
@@ -1033,6 +1037,8 @@ int main(int argc, char **argv) {
{"layer", required_argument, 0, 'l'},
{"exclude-layer", required_argument, 0, 'L'},
{"quiet", no_argument, 0, 'q'},
{"maximum-zoom", required_argument, 0, 'z'},
{"minimum-zoom", required_argument, 0, 'Z'},
{"no-tile-size-limit", no_argument, &pk, 1},
{"no-tile-compression", no_argument, &pC, 1},
@@ -1089,6 +1095,14 @@ int main(int argc, char **argv) {
set_description = optarg;
break;
case 'z':
maxzoom = atoi(optarg);
break;
case 'Z':
minzoom = atoi(optarg);
break;
case 'p':
if (strcmp(optarg, "k") == 0) {
pk = true;