Calculate the tileset bounding box in tile-join from the tile boundaries

This commit is contained in:
Eric Fischer 2017-05-11 12:36:35 -07:00
parent 30d54ff50d
commit fb6551c59e
9 changed files with 46 additions and 13 deletions

View File

@ -1,3 +1,8 @@
## 1.18.0
* Fix compression of tiles in tile-join
* Calculate the tileset bounding box in tile-join from the tile boundaries
## 1.17.7
* Enforce polygon winding and closure rules in tippecanoe-decode

View File

@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-122.334735,37.877356,-122.281639,37.898925",
"bounds": "-122.343750,37.857507,-122.255859,37.926868",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",

View File

@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-122.334735,37.877356,-122.281639,37.898925",
"bounds": "-122.343750,37.857507,-122.255859,37.926868",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",

View File

@ -1,6 +1,6 @@
{ "type": "FeatureCollection", "properties": {
"attribution": "macarthur attribution",
"bounds": "-122.334735,37.695438,-122.104097,37.898925",
"bounds": "-122.343750,37.695438,-122.104097,37.926868",
"center": "-122.299805,37.892187,12",
"description": "macarthur description",
"format": "pbf",

View File

@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-122.334735,37.695438,-122.104097,37.898925",
"bounds": "-122.343750,37.695438,-122.104097,37.926868",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",

View File

@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-122.334735,37.695438,-122.104097,37.898925",
"bounds": "-122.343750,37.695438,-122.104097,37.926868",
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",

View File

@ -1,5 +1,5 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-122.294563,37.695438,-122.104097,37.833010",
"bounds": "-122.343750,37.439974,-121.992188,37.996163",
"center": "-122.167969,37.833010,10",
"description": "tests/join-population/macarthur.mbtiles",
"format": "pbf",

View File

@ -475,11 +475,34 @@ void decode(struct reader *readers, char *map, std::map<std::string, layermap_en
std::map<zxy, std::vector<std::string>> tasks;
double minlat = INT_MAX;
double minlon = INT_MAX;
double maxlat = INT_MIN;
double maxlon = INT_MIN;
int zoom_for_bbox = -1;
while (readers != NULL && readers->zoom < 32) {
reader *r = readers;
readers = readers->next;
r->next = NULL;
if (r->zoom != zoom_for_bbox) {
// Only use highest zoom for bbox calculation
// to avoid z0 always covering the world
minlat = minlon = INT_MAX;
maxlat = maxlon = INT_MIN;
zoom_for_bbox = r->zoom;
}
double lat1, lon1, lat2, lon2;
tile2lonlat(r->x, r->y, r->zoom, &lon1, &lat1);
tile2lonlat(r->x + 1, r->y + 1, r->zoom, &lon2, &lat2);
minlat = min(lat2, minlat);
minlon = min(lon1, minlon);
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>()));
@ -520,6 +543,11 @@ void decode(struct reader *readers, char *map, std::map<std::string, layermap_en
*rr = r;
}
st->minlon = min(minlon, st->minlon);
st->maxlon = max(maxlon, st->maxlon);
st->minlat = min(minlat, st->minlat);
st->maxlat = max(maxlat, st->maxlat);
handle_tasks(tasks, layermaps, outdb, header, mapping, exclude, ifmatched, keep_layers, remove_layers);
layermap = merge_layermaps(layermaps);
@ -574,12 +602,12 @@ 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 = 'bounds'", -1, &r->stmt, NULL) == SQLITE_OK) {
if (sqlite3_step(r->stmt) == SQLITE_ROW) {
const unsigned char *s = sqlite3_column_text(r->stmt, 0);
double minlon, minlat, maxlon, maxlat;
sscanf((char *) s, "%lf,%lf,%lf,%lf", &minlon, &minlat, &maxlon, &maxlat);
st->minlon = min(minlon, st->minlon);
st->maxlon = max(maxlon, st->maxlon);
st->minlat = min(minlat, st->minlat);
st->maxlat = max(maxlat, st->maxlat);
if (sscanf((char *) s, "%lf,%lf,%lf,%lf", &minlon, &minlat, &maxlon, &maxlat) == 4) {
st->minlon = min(minlon, st->minlon);
st->maxlon = max(maxlon, st->maxlon);
st->minlat = min(minlat, st->minlat);
st->maxlat = max(maxlat, st->maxlat);
}
}
sqlite3_finalize(r->stmt);
}

View File

@ -1 +1 @@
#define VERSION "tippecanoe v1.17.7\n"
#define VERSION "tippecanoe v1.18.0\n"