mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
At least when to overzoom, even if not actually doing it yet
This commit is contained in:
@@ -3140,7 +3140,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
} else if (strcmp(opt, "preserve-point-density-threshold") == 0) {
|
} else if (strcmp(opt, "preserve-point-density-threshold") == 0) {
|
||||||
preserve_point_density_threshold = atoll_require(optarg, "Preserve point density threshold");
|
preserve_point_density_threshold = atoll_require(optarg, "Preserve point density threshold");
|
||||||
} else if (strcmp(opt, "extend-zooms-if-still-dropping-maximum") == 0) {
|
} else if (strcmp(opt, "extend-zooms-if-still-dropping-maximum") == 0) {
|
||||||
extend_zooms_max = atoll_require(optarg, "Maximum number by which to extend zooms");
|
extend_zooms_max = atoll_require(optarg, "Maximum number by which to extend zooms");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
|
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ extern char *optarg;
|
|||||||
extern int optind;
|
extern int optind;
|
||||||
|
|
||||||
int detail = 12; // tippecanoe-style: mvt extent == 1 << detail
|
int detail = 12; // tippecanoe-style: mvt extent == 1 << detail
|
||||||
int buffer = 5; // tippecanoe-style: mvt buffer == extent * buffer / 256;
|
int buffer = 5; // tippecanoe-style: mvt buffer == extent * buffer / 256;
|
||||||
|
|
||||||
std::set<std::string> keep;
|
std::set<std::string> keep;
|
||||||
|
|
||||||
|
|||||||
+29
-6
@@ -80,7 +80,7 @@ void aprintf(std::string *buf, const char *format, ...) {
|
|||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle(std::string message, int z, unsigned x, unsigned y, std::map<std::string, layermap_entry> &layermap, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, std::set<std::string> &exclude, std::set<std::string> &include, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, int ifmatched, mvt_tile &outtile, json_object *filter) {
|
void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<std::string, layermap_entry> &layermap, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, std::set<std::string> &exclude, std::set<std::string> &include, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, int ifmatched, mvt_tile &outtile, json_object *filter) {
|
||||||
mvt_tile tile;
|
mvt_tile tile;
|
||||||
int features_added = 0;
|
int features_added = 0;
|
||||||
bool was_compressed;
|
bool was_compressed;
|
||||||
@@ -378,6 +378,7 @@ struct reader {
|
|||||||
long long sorty = 0;
|
long long sorty = 0;
|
||||||
long long y = 0;
|
long long y = 0;
|
||||||
int z_flag = 0;
|
int z_flag = 0;
|
||||||
|
int maxzoom_so_far = 0;
|
||||||
|
|
||||||
std::string data = "";
|
std::string data = "";
|
||||||
|
|
||||||
@@ -530,6 +531,7 @@ struct arg {
|
|||||||
std::set<std::string> *remove_layers = NULL;
|
std::set<std::string> *remove_layers = NULL;
|
||||||
int ifmatched = 0;
|
int ifmatched = 0;
|
||||||
json_object *filter = NULL;
|
json_object *filter = NULL;
|
||||||
|
struct reader *readers = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
void *join_worker(void *v) {
|
void *join_worker(void *v) {
|
||||||
@@ -538,8 +540,19 @@ void *join_worker(void *v) {
|
|||||||
for (auto ai = a->inputs.begin(); ai != a->inputs.end(); ++ai) {
|
for (auto ai = a->inputs.begin(); ai != a->inputs.end(); ++ai) {
|
||||||
mvt_tile tile;
|
mvt_tile tile;
|
||||||
|
|
||||||
|
for (struct reader *r = a->readers; r != NULL; r = r->next) {
|
||||||
|
if (r->maxzoom_so_far < ai->first.z) {
|
||||||
|
// if this reader did not produce any tiles at this zoom level,
|
||||||
|
// and is not ready to produce any tiles at this zoom level,
|
||||||
|
// it is a candidate for overzooming this tile from whatever
|
||||||
|
// zoom level it did produce last.
|
||||||
|
|
||||||
|
printf("overzooming %lld/%lld/%lld from zoom %d\n", ai->first.z, ai->first.x, ai->first.y, r->maxzoom_so_far);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < ai->second.size(); i++) {
|
for (size_t i = 0; i < ai->second.size(); i++) {
|
||||||
handle(ai->second[i], ai->first.z, ai->first.x, ai->first.y, *(a->layermap), *(a->header), *(a->mapping), *(a->exclude), *(a->include), *(a->keep_layers), *(a->remove_layers), a->ifmatched, tile, a->filter);
|
append_tile(ai->second[i], ai->first.z, ai->first.x, ai->first.y, *(a->layermap), *(a->header), *(a->mapping), *(a->exclude), *(a->include), *(a->keep_layers), *(a->remove_layers), a->ifmatched, tile, a->filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
ai->second.clear();
|
ai->second.clear();
|
||||||
@@ -574,7 +587,7 @@ void *join_worker(void *v) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_tasks(std::map<zxy, std::vector<std::string>> &tasks, std::vector<std::map<std::string, layermap_entry>> &layermaps, sqlite3 *outdb, const char *outdir, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, std::set<std::string> &exclude, std::set<std::string> &include, int ifmatched, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, json_object *filter) {
|
void dispatch_tasks(std::map<zxy, std::vector<std::string>> &tasks, std::vector<std::map<std::string, layermap_entry>> &layermaps, sqlite3 *outdb, const char *outdir, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, std::set<std::string> &exclude, std::set<std::string> &include, int ifmatched, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, json_object *filter, struct reader *readers) {
|
||||||
pthread_t pthreads[CPUS];
|
pthread_t pthreads[CPUS];
|
||||||
std::vector<arg> args;
|
std::vector<arg> args;
|
||||||
|
|
||||||
@@ -590,6 +603,7 @@ void handle_tasks(std::map<zxy, std::vector<std::string>> &tasks, std::vector<st
|
|||||||
args[i].remove_layers = &remove_layers;
|
args[i].remove_layers = &remove_layers;
|
||||||
args[i].ifmatched = ifmatched;
|
args[i].ifmatched = ifmatched;
|
||||||
args[i].filter = filter;
|
args[i].filter = filter;
|
||||||
|
args[i].readers = readers;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
@@ -737,9 +751,12 @@ void decode(struct reader *readers, std::map<std::string, layermap_entry> &layer
|
|||||||
int zoom_for_bbox = -1;
|
int zoom_for_bbox = -1;
|
||||||
|
|
||||||
while (readers != NULL && readers->zoom < 32) {
|
while (readers != NULL && readers->zoom < 32) {
|
||||||
|
// pull a reader off the front of the queue,
|
||||||
|
// process whatever tile it has ready to read
|
||||||
reader *r = readers;
|
reader *r = readers;
|
||||||
readers = readers->next;
|
readers = readers->next;
|
||||||
r->next = NULL;
|
r->next = NULL;
|
||||||
|
|
||||||
if (r->zoom != zoom_for_bbox) {
|
if (r->zoom != zoom_for_bbox) {
|
||||||
// Only use highest zoom for bbox calculation
|
// Only use highest zoom for bbox calculation
|
||||||
// to avoid z0 always covering the world
|
// to avoid z0 always covering the world
|
||||||
@@ -749,6 +766,10 @@ void decode(struct reader *readers, std::map<std::string, layermap_entry> &layer
|
|||||||
zoom_for_bbox = r->zoom;
|
zoom_for_bbox = r->zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r->zoom > r->maxzoom_so_far) {
|
||||||
|
r->maxzoom_so_far = r->zoom;
|
||||||
|
}
|
||||||
|
|
||||||
double lat1, lon1, lat2, lon2;
|
double lat1, lon1, lat2, lon2;
|
||||||
tile2lonlat(r->x, r->y, r->zoom, &lon1, &lat1);
|
tile2lonlat(r->x, r->y, r->zoom, &lon1, &lat1);
|
||||||
tile2lonlat(r->x + 1, r->y + 1, r->zoom, &lon2, &lat2);
|
tile2lonlat(r->x + 1, r->y + 1, r->zoom, &lon2, &lat2);
|
||||||
@@ -776,7 +797,7 @@ void decode(struct reader *readers, std::map<std::string, layermap_entry> &layer
|
|||||||
|
|
||||||
if (readers == NULL || readers->zoom != r->zoom || readers->x != r->x || readers->y != r->y) {
|
if (readers == NULL || readers->zoom != r->zoom || readers->x != r->x || readers->y != r->y) {
|
||||||
if (tasks.size() > 100 * CPUS) {
|
if (tasks.size() > 100 * CPUS) {
|
||||||
handle_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter);
|
dispatch_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers);
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -820,8 +841,10 @@ void decode(struct reader *readers, std::map<std::string, layermap_entry> &layer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct reader **rr;
|
// put the reader back onto the queue,
|
||||||
|
// in whatever sequence its next tile calls for
|
||||||
|
|
||||||
|
struct reader **rr;
|
||||||
for (rr = &readers; *rr != NULL; rr = &((*rr)->next)) {
|
for (rr = &readers; *rr != NULL; rr = &((*rr)->next)) {
|
||||||
if (*r < **rr) {
|
if (*r < **rr) {
|
||||||
break;
|
break;
|
||||||
@@ -842,7 +865,7 @@ void decode(struct reader *readers, std::map<std::string, layermap_entry> &layer
|
|||||||
st->minlat2 = min(minlat, st->minlat2);
|
st->minlat2 = min(minlat, st->minlat2);
|
||||||
st->maxlat2 = max(maxlat, st->maxlat2);
|
st->maxlat2 = max(maxlat, st->maxlat2);
|
||||||
|
|
||||||
handle_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter);
|
dispatch_tasks(tasks, layermaps, outdb, outdir, header, mapping, exclude, include, ifmatched, keep_layers, remove_layers, filter, readers);
|
||||||
layermap = merge_layermaps(layermaps);
|
layermap = merge_layermaps(layermaps);
|
||||||
|
|
||||||
struct reader *next;
|
struct reader *next;
|
||||||
|
|||||||
@@ -3238,14 +3238,14 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic<
|
|||||||
z = args[thread].wrote_zoom;
|
z = args[thread].wrote_zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[thread].still_dropping) {
|
if (args[thread].still_dropping) {
|
||||||
if (additional[A_EXTEND_ZOOMS] && z == maxzoom && maxzoom < MAX_ZOOM) {
|
if (additional[A_EXTEND_ZOOMS] && z == maxzoom && maxzoom < MAX_ZOOM) {
|
||||||
maxzoom++;
|
maxzoom++;
|
||||||
} else if (extend_zooms_max > 0 && z == maxzoom && maxzoom < MAX_ZOOM) {
|
} else if (extend_zooms_max > 0 && z == maxzoom && maxzoom < MAX_ZOOM) {
|
||||||
maxzoom++;
|
maxzoom++;
|
||||||
extend_zooms_max--;
|
extend_zooms_max--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size_t) z >= strategies.size()) {
|
if ((size_t) z >= strategies.size()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user