diff options
author | “osana” <osana.babayan@mapbox.com> | 2018-04-10 11:54:15 -0400 |
---|---|---|
committer | “osana” <osana.babayan@mapbox.com> | 2018-04-10 11:54:15 -0400 |
commit | 7ae5c2f4a84ab5e0f14e0729f514bd0b19e79647 (patch) | |
tree | 32357156d59d85a19bcec9c45594e231464f43c0 | |
parent | aa43dfd6c1835570d437a4f7e66abcff4f953839 (diff) | |
download | qtlocation-mapboxgl-upstream/osana-same-lon-bounds.tar.gz |
[android] LatLngBounds were not build correctly when points withupstream/osana-same-lon-bounds
same longitudes were included first.
2 files changed, 22 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java index fb12a76b55..591dd2c144 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java @@ -394,7 +394,7 @@ public class LatLngBounds implements Parcelable { } static boolean containsLongitude(final double eastLon, final double westLon, final double longitude) { - if (eastLon > westLon) { + if (eastLon >= westLon) { return (longitude <= eastLon) && (longitude >= westLon); } diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java index 940fde1257..6b8462e351 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java @@ -197,6 +197,27 @@ public class LatLngBoundsTest { } @Test + public void includesOrderDoesNotMatter() { + LatLngBounds sameLongitudeFirst = new LatLngBounds.Builder() + .include(new LatLng(50, 10)) // southWest + .include(new LatLng(60, 10)) + .include(new LatLng(60, 20)) // northEast + .include(new LatLng(50, 20)) + .include(new LatLng(50, 10)) // southWest again + .build(); + + LatLngBounds sameLatitudeFirst = new LatLngBounds.Builder() + .include(new LatLng(50, 20)) + .include(new LatLng(50, 10)) // southWest + .include(new LatLng(60, 10)) + .include(new LatLng(60, 20)) // northEast + .include(new LatLng(50, 20)) + .build(); + + assertEquals(sameLatitudeFirst, sameLongitudeFirst); + } + + @Test public void includesOverDateline1() { LatLngBounds latLngBounds = new LatLngBounds.Builder() |