[core] Fix screen coordinates when crossing the antimeridian (#2)
Added missing case. Really fixes #4155 this time.
This commit is contained in:
@@ -52,7 +52,7 @@ Known issues:
|
||||
## iOS master
|
||||
|
||||
- Offline packs can now be downloaded to allow users to view specific regions of the map offline. A new MGLOfflineStorage class provides APIs for managing MGLOfflinePacks. ([#4221](https://github.com/mapbox/mapbox-gl-native/pull/4221))
|
||||
- Fixed screen coordinates for LatLng coordinates accross the antimeridian. ([#4215](https://github.com/mapbox/mapbox-gl-native/issues/4155))
|
||||
- Fixed screen coordinates for LatLng coordinates accross the antimeridian. ([#4155](https://github.com/mapbox/mapbox-gl-native/issues/4155))
|
||||
- Fixed a bounce-back effect when panning the map. ([#4214](https://github.com/mapbox/mapbox-gl-native/pull/4214))
|
||||
- An icon laid out along a line no longer appears if it would extend past the end of the line. Some one-way arrows no longer point the wrong way. ([#3839](https://github.com/mapbox/mapbox-gl-native/pull/3839))
|
||||
- Reduce slanted segments in dashed lines near corners. ([#3914](https://github.com/mapbox/mapbox-gl-native/pull/3914))
|
||||
|
||||
@@ -667,7 +667,7 @@ ScreenCoordinate Transform::latLngToScreenCoordinate(const LatLng& latLng) const
|
||||
// to the center side.
|
||||
double longitude = latLng.longitude;
|
||||
const double centerLng = getLatLng().longitude;
|
||||
if (centerLng - latLng.longitude > util::LONGITUDE_MAX) {
|
||||
if (std::abs(centerLng - latLng.longitude) > std::abs(util::LONGITUDE_MAX)) {
|
||||
if (centerLng > 0 && latLng.longitude < 0) {
|
||||
longitude += util::DEGREES_MAX;
|
||||
} else if (centerLng < 0 && latLng.longitude > 0) {
|
||||
|
||||
@@ -318,4 +318,20 @@ TEST(Transform, Antimeridian) {
|
||||
ScreenCoordinate pixelSFForwards = transform.latLngToScreenCoordinate(coordinateSanFrancisco);
|
||||
ASSERT_DOUBLE_EQ(pixelSFBackwards.x, pixelSFForwards.x);
|
||||
ASSERT_DOUBLE_EQ(pixelSFBackwards.y, pixelSFForwards.y);
|
||||
|
||||
const LatLng coordinateWaikiri{ -16.9310, 179.9787 };
|
||||
transform.setLatLngZoom(coordinateWaikiri, 10);
|
||||
ScreenCoordinate pixelWaikiri = transform.latLngToScreenCoordinate(coordinateWaikiri);
|
||||
ASSERT_DOUBLE_EQ(500.00000000007759, pixelWaikiri.x);
|
||||
ASSERT_DOUBLE_EQ(500, pixelWaikiri.y);
|
||||
|
||||
transform.setLatLng({ coordinateWaikiri.latitude, 180.0213 });
|
||||
ScreenCoordinate pixelWaikiriForwards = transform.latLngToScreenCoordinate(coordinateWaikiri);
|
||||
ASSERT_DOUBLE_EQ(437.95953728819512, pixelWaikiriForwards.x);
|
||||
ASSERT_DOUBLE_EQ(pixelWaikiri.y, pixelWaikiriForwards.y);
|
||||
|
||||
transform.setLatLng({ coordinateWaikiri.latitude, -179.9787 });
|
||||
ScreenCoordinate pixelWaikiriBackwards = transform.latLngToScreenCoordinate(coordinateWaikiri);
|
||||
ASSERT_DOUBLE_EQ(pixelWaikiriForwards.x, pixelWaikiriBackwards.x);
|
||||
ASSERT_DOUBLE_EQ(pixelWaikiriForwards.y, pixelWaikiriBackwards.y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user