Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] LatLngBounds: latNorth should be greater or equal than latS…
Browse files Browse the repository at this point in the history
…outh
  • Loading branch information
“osana” committed Feb 27, 2018
1 parent 3177947 commit 45fba76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public LatLng[] toLatLngs() {
* 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],
Expand Down Expand Up @@ -257,6 +259,10 @@ public static LatLngBounds from(
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,11 @@ public void testConstructorChecksWestLongitudeInfinity() {
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);
}
}

0 comments on commit 45fba76

Please sign in to comment.