mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
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:
+28
@@ -402,6 +402,34 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||
sf.bbox[2] = LLONG_MIN;
|
||||
sf.bbox[3] = LLONG_MIN;
|
||||
|
||||
for (size_t i = 0; i < sf.geometry.size(); i++) {
|
||||
if (sf.geometry[i].op == VT_MOVETO || sf.geometry[i].op == VT_LINETO) {
|
||||
if (sf.geometry[i].y > 0 && sf.geometry[i].y < 0xFFFFFFFF) {
|
||||
// standard -180 to 180 world plane
|
||||
|
||||
long long x = sf.geometry[i].x & 0xFFFFFFFF;
|
||||
long long y = sf.geometry[i].y & 0xFFFFFFFF;
|
||||
|
||||
r->file_bbox1[0] = std::min(r->file_bbox1[0], x);
|
||||
r->file_bbox1[1] = std::min(r->file_bbox1[1], y);
|
||||
r->file_bbox1[2] = std::max(r->file_bbox1[2], x);
|
||||
r->file_bbox1[3] = std::max(r->file_bbox1[3], y);
|
||||
|
||||
// printf("%llx,%llx %llx,%llx %llx,%llx ", x, y, r->file_bbox1[0], r->file_bbox1[1], r->file_bbox1[2], r->file_bbox1[3]);
|
||||
|
||||
// shift the western hemisphere 360 degrees to the east
|
||||
if (x < 0x80000000) { // prime meridian
|
||||
x += 0x100000000;
|
||||
}
|
||||
|
||||
r->file_bbox2[0] = std::min(r->file_bbox2[0], x);
|
||||
r->file_bbox2[1] = std::min(r->file_bbox2[1], y);
|
||||
r->file_bbox2[2] = std::max(r->file_bbox2[2], x);
|
||||
r->file_bbox2[3] = std::max(r->file_bbox2[3], y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to remind myself that the geometry in this function is in SCALED COORDINATES
|
||||
drawvec scaled_geometry = sf.geometry;
|
||||
sf.geometry.clear();
|
||||
|
||||
Reference in New Issue
Block a user