diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2018-08-13 12:42:03 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-08-13 16:31:18 +0200 |
commit | 044213dca8e5ee9148b77e37bf4f15ed1589ac2f (patch) | |
tree | f542e18ca6aec39f5062e6a33e4352da64c2eb51 /platform | |
parent | fdc287ec3608850654196e3b3a682ca3c5039676 (diff) | |
download | qtlocation-mapboxgl-044213dca8e5ee9148b77e37bf4f15ed1589ac2f.tar.gz |
[android] - use uncoverted bearing value for latlngbounds calculation
Diffstat (limited to 'platform')
2 files changed, 33 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 276e25bd53..97e2e50525 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -1601,7 +1601,7 @@ public final class MapboxMap { public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds, @NonNull @Size(value = 4) int[] padding) { // we use current camera tilt/bearing value to provide expected transformations as #11993 - return getCameraForLatLngBounds(latLngBounds, padding, transform.getBearing(), transform.getTilt()); + return getCameraForLatLngBounds(latLngBounds, padding, transform.getRawBearing(), transform.getTilt()); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java index 738f1e203f..7aaca370b2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/LatLngBoundsTest.java @@ -7,13 +7,18 @@ import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity; +import com.mapbox.mapboxsdk.testapp.utils.TestConstants; import org.junit.Test; +import static junit.framework.Assert.assertEquals; + /** * Instrumentation test to validate integration of LatLngBounds */ public class LatLngBoundsTest extends BaseActivityTest { + private static final double MAP_BEARING = 50; + @Override protected Class getActivityClass() { return QueryRenderedFeaturesBoxHighlightActivity.class; @@ -31,4 +36,31 @@ public class LatLngBoundsTest extends BaseActivityTest { mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0)); }); } + + @Test + public void testLatLngBoundsBearing() { + // regression test for #12549 + validateTestSetup(); + MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> { + LatLngBounds bounds = new LatLngBounds.Builder() + .include(new LatLng(48.8589506, 2.2773457)) + .include(new LatLng(47.2383171, -1.6309316)) + .build(); + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0)); + mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(MAP_BEARING)); + assertEquals( + "Initial bearing should match for latlngbounds", + mapboxMap.getCameraPosition().bearing, + MAP_BEARING, + TestConstants.BEARING_DELTA + ); + + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0)); + assertEquals("Bearing should match after resetting latlngbounds", + mapboxMap.getCameraPosition().bearing, + MAP_BEARING, + TestConstants.BEARING_DELTA); + }); + } + }
\ No newline at end of file |