diff options
author | osana <osana.babayan@mapbox.com> | 2018-12-11 20:46:59 +0100 |
---|---|---|
committer | “osana” <osana.babayan@mapbox.com> | 2018-12-11 19:30:12 -0500 |
commit | 4c451233d03cd910ad354cd837f9c20b0a27a07f (patch) | |
tree | 809830772c67e1fb4f0415fd45e854999625d3c3 /platform/android/MapboxGLAndroidSDK | |
parent | 3810e7b5b8dc7ab824268bb6b99d47b41284f92e (diff) | |
download | qtlocation-mapboxgl-4c451233d03cd910ad354cd837f9c20b0a27a07f.tar.gz |
Don't wrap LatLngBounds (#13540)upstream/osana-lat-lng-donotwrap
* [android] - don't wrap LatLngBounds
* Update GeometryConstants.java
* Update NativeMapTest
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK')
3 files changed, 25 insertions, 13 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java index 1ac08b12e1..6f6e777922 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/GeometryConstants.java @@ -24,12 +24,12 @@ public class GeometryConstants { /** * This constant represents the lowest longitude value available to represent a geolocation. */ - public static final double MIN_LONGITUDE = Double.NEGATIVE_INFINITY; + public static final double MIN_LONGITUDE = -Double.MAX_VALUE; /** * This constant represents the highest longitude value available to represent a geolocation. */ - public static final double MAX_LONGITUDE = Double.POSITIVE_INFINITY; + public static final double MAX_LONGITUDE = Double.MAX_VALUE; /** * This constant represents the lowest latitude value available to represent a geolocation. 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 b66dd46b4c..263780f473 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 @@ -256,6 +256,7 @@ public class LatLngBounds implements Parcelable { * otherwise IllegalArgumentException will be thrown. * latNorth should be greater or equal latSouth, otherwise IllegalArgumentException will be thrown. * <p> + * This method doesn't recalculate most east or most west boundaries. * Note @since 7.0.0 lonEast and lonWest will NOT be wrapped to be in the range of [-180, 180], * see {@link GeometryConstants#MIN_LONGITUDE} and {@link GeometryConstants#MAX_LONGITUDE} * lonEast should be greater or equal lonWest, otherwise IllegalArgumentException will be thrown. @@ -286,6 +287,10 @@ public class LatLngBounds implements Parcelable { throw new IllegalArgumentException("longitude must not be NaN"); } + if (Double.isInfinite(lonEast) || Double.isInfinite(lonWest)) { + throw new IllegalArgumentException("longitude must not be infinite"); + } + if (latNorth > MAX_LATITUDE || latNorth < MIN_LATITUDE || latSouth > MAX_LATITUDE || latSouth < MIN_LATITUDE) { throw new IllegalArgumentException("latitude must be between -90 and 90"); 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 6990c9cab3..6c44c29e3b 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 @@ -257,8 +257,9 @@ public class LatLngBoundsTest { .include(new LatLng(0, -190)) .build(); + LatLngSpan latLngSpan = latLngBounds.getSpan(); assertEquals("LatLngSpan should be the same", - new LatLngSpan(20, 20), latLngBounds.getSpan()); + new LatLngSpan(20, 20), latLngSpan); } @Test @@ -395,14 +396,20 @@ public class LatLngBoundsTest { public void intersectSouthLessThanNorthCheck() { exception.expect(IllegalArgumentException.class); exception.expectMessage("latNorth cannot be less than latSouth"); - LatLngBounds intersectLatLngBounds = LatLngBounds.from(10, 10, 0, 0) .intersect(0, 200, 20, 0); } - @Test + public void intersectEastLessThanWestCheck() { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("lonEast cannot be less than lonWest"); + LatLngBounds intersectLatLngBounds = + LatLngBounds.from(10, -10, 0, 0) + .intersect(0, 200, 20, 0); + } + public void intersectEastDoesNotWrapCheck() { LatLngBounds latLngBounds1 = LatLngBounds.from(10, 210, 0, 0); @@ -749,10 +756,10 @@ public class LatLngBoundsTest { } @Test - public void testConstructorEastLongitudeInfinityAllowed() { - LatLngBounds latLngBounds = - LatLngBounds.from(0, Double.POSITIVE_INFINITY, -20, -20); - assertEquals(Double.POSITIVE_INFINITY, latLngBounds.getLonEast(), DELTA); + public void testConstructorChecksEastLongitudeInfinity() { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("longitude must not be infinite"); + LatLngBounds.from(0, Double.POSITIVE_INFINITY, -20, -20); } @Test @@ -784,10 +791,10 @@ public class LatLngBoundsTest { } @Test - public void testConstructorWestLongitudeInfinityAllowed() { - LatLngBounds latLngBounds = - LatLngBounds.from(20, 20, 0, Double.NEGATIVE_INFINITY); - assertEquals(Double.NEGATIVE_INFINITY, latLngBounds.getLonWest(), DELTA); + public void testConstructorChecksWestLongitudeInfinity() { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("longitude must not be infinite"); + LatLngBounds.from(20, 20, 0, Double.POSITIVE_INFINITY); } @Test |