Calculate an antimeridian-adjusted bounding box in tileset metadata (#82)

* Calculate a new antimeridian-adjusted bounding box

* Add antimeridian bounding box to pmtiles, dirtiles, and tile-join

* Don't take out-of-bounds latitudes into account in the adjusted bbox

* Update changelog

* Forgot to adjust tests after the last change
This commit is contained in:
Erica Fischer
2023-03-09 20:26:48 -08:00
committed by GitHub
parent 329dd86bfd
commit afc7ca01a2
195 changed files with 297 additions and 13 deletions
+15 -1
View File
@@ -530,6 +530,15 @@ void mbtiles_write_metadata(sqlite3 *db, const metadata &m, bool forcetable) {
}
sqlite3_free(sql);
sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('antimeridian_adjusted_bounds', '%f,%f,%f,%f');", m.minlon2, m.minlat2, m.maxlon2, m.maxlat2);
if (sqlite3_exec(db, sql, NULL, NULL, &err) != SQLITE_OK) {
fprintf(stderr, "set bounds: %s\n", err);
if (!forcetable) {
exit(EXIT_SQLITE);
}
}
sqlite3_free(sql);
sql = sqlite3_mprintf("INSERT INTO metadata (name, value) VALUES ('type', %Q);", m.type.c_str());
if (sqlite3_exec(db, sql, NULL, NULL, &err) != SQLITE_OK) {
fprintf(stderr, "set type: %s\n", err);
@@ -629,7 +638,7 @@ void mbtiles_write_metadata(sqlite3 *db, const metadata &m, bool forcetable) {
}
}
metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double midlat, double midlon, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector<strategy> const &strategies) {
metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double minlat2, double minlon2, double maxlat2, double maxlon2, double midlat, double midlon, const char *attribution, std::map<std::string, layermap_entry> const &layermap, bool vector, const char *description, bool do_tilestats, std::map<std::string, std::string> const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector<strategy> const &strategies) {
metadata m;
m.name = fname;
@@ -646,6 +655,11 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
m.maxlat = maxlat;
m.maxlon = maxlon;
m.minlat2 = minlat2;
m.minlon2 = minlon2;
m.maxlat2 = maxlat2;
m.maxlon2 = maxlon2;
m.center_lat = midlat;
m.center_lon = midlon;
m.center_z = maxzoom;