diff --git a/CHANGELOG.md b/CHANGELOG.md index 00cf0ba..2f1f232 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tests/join-population/joined-i.mbtiles.json b/tests/join-population/joined-i.mbtiles.json index e32ec68..6aa8bae 100644 --- a/tests/join-population/joined-i.mbtiles.json +++ b/tests/join-population/joined-i.mbtiles.json @@ -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", diff --git a/tests/join-population/joined.mbtiles.json b/tests/join-population/joined.mbtiles.json index 0e45d02..8aa68e2 100644 --- a/tests/join-population/joined.mbtiles.json +++ b/tests/join-population/joined.mbtiles.json @@ -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", diff --git a/tests/join-population/just-macarthur.mbtiles.json b/tests/join-population/just-macarthur.mbtiles.json index faeed2b..a902f12 100644 --- a/tests/join-population/just-macarthur.mbtiles.json +++ b/tests/join-population/just-macarthur.mbtiles.json @@ -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", diff --git a/tests/join-population/merged.mbtiles.json b/tests/join-population/merged.mbtiles.json index 1cb3323..ea26226 100644 --- a/tests/join-population/merged.mbtiles.json +++ b/tests/join-population/merged.mbtiles.json @@ -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", diff --git a/tests/join-population/no-macarthur.mbtiles.json b/tests/join-population/no-macarthur.mbtiles.json index 5dcb5e8..fa5a04c 100644 --- a/tests/join-population/no-macarthur.mbtiles.json +++ b/tests/join-population/no-macarthur.mbtiles.json @@ -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", diff --git a/tests/join-population/windows.mbtiles.json b/tests/join-population/windows.mbtiles.json index 825bae6..acdd7e9 100644 --- a/tests/join-population/windows.mbtiles.json +++ b/tests/join-population/windows.mbtiles.json @@ -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", diff --git a/tile-join.cpp b/tile-join.cpp index 3677337..f06107c 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -475,11 +475,34 @@ void decode(struct reader *readers, char *map, std::map> 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>(tile, std::vector())); @@ -520,6 +543,11 @@ void decode(struct reader *readers, char *map, std::mapminlon = 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::mapdb, "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); } diff --git a/version.hpp b/version.hpp index c70088e..babfe73 100644 --- a/version.hpp +++ b/version.hpp @@ -1 +1 @@ -#define VERSION "tippecanoe v1.17.7\n" +#define VERSION "tippecanoe v1.18.0\n"