diff options
author | “osana” <osana.babayan@mapbox.com> | 2018-02-26 00:34:43 +0100 |
---|---|---|
committer | “osana” <osana.babayan@mapbox.com> | 2018-02-27 09:20:48 -0500 |
commit | 45fba766e182270e37bb7649888bebab3253a6bb (patch) | |
tree | 90884dbc3a0e1a3c9b23fcbf72d403f0746469be | |
parent | 317794746e51ad801c9b53f987fc602acc533cc3 (diff) | |
download | qtlocation-mapboxgl-upstream/osana-lat-check.tar.gz |
[android] LatLngBounds: latNorth should be greater or equal than latSouthupstream/osana-lat-check
2 files changed, 13 insertions, 0 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 cf647224ae..f5c3ecb8c3 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 @@ -228,6 +228,8 @@ public class LatLngBounds implements Parcelable { * This values of latNorth and latSouth should be in the range of [-90, 90], * see {@link GeometryConstants#MIN_LATITUDE} and {@link GeometryConstants#MAX_LATITUDE}, * 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 that lonEast and lonWest will be wrapped to be in the range of [-180, 180], @@ -257,6 +259,10 @@ public class LatLngBounds implements Parcelable { throw new IllegalArgumentException("latitude must be between -90 and 90"); } + if (latNorth < latSouth) { + throw new IllegalArgumentException("LatSouth cannot be less than latNorth"); + } + lonEast = LatLng.wrap(lonEast, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE); lonWest = LatLng.wrap(lonWest, GeometryConstants.MIN_LONGITUDE, GeometryConstants.MAX_LONGITUDE); 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 e6c1fdd0cf..42b0ad0f7b 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 @@ -365,4 +365,11 @@ public class LatLngBoundsTest { exception.expectMessage("longitude must not be infinite"); LatLngBounds.from(20, 20, 0, Double.POSITIVE_INFINITY); } + + @Test + public void testConstructorCheckLatSouthGreaterLatNorth() { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("LatSouth cannot be less than latNorth"); + LatLngBounds.from(0, 20, 20, 0); + } } |