[core] Fly across the meridian or antemeridian, whichever is shorter

ref mapbox/mapbox-gl-js#1853
This commit is contained in:
Minh Nguyễn
2015-12-18 22:02:50 -08:00
committed by Minh Nguyễn
parent a68589b6c7
commit 225a17d775

View File

@@ -344,6 +344,16 @@ void Transform::flyTo(const CameraOptions &options) {
return;
}
// If a path crossing the antemeridian would be shorter, extend the final
// coordinate so that interpolating between the two endpoints will cross it.
if (std::abs(startLatLng.longitude) + std::abs(latLng.longitude) > 180) {
if (startLatLng.longitude > 0 && latLng.longitude < 0) {
latLng.longitude += 360;
} else if (startLatLng.longitude < 0 && latLng.longitude > 0) {
latLng.longitude -= 360;
}
}
const PrecisionPoint startPoint = {
state.lngX(startLatLng.longitude),
state.latY(startLatLng.latitude),