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

Commit

Permalink
[android] LatLngBounds were not build correctly when lons were the sa…
Browse files Browse the repository at this point in the history
…me (#11647)
  • Loading branch information
osana committed Apr 10, 2018
1 parent aa43dfd commit 4191c4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private boolean containsLongitude(final double longitude) {
}

static boolean containsLongitude(final double eastLon, final double westLon, final double longitude) {
if (eastLon > westLon) {
if (eastLon >= westLon) {
return (longitude <= eastLon)
&& (longitude >= westLon);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,27 @@ public void includes() {
assertEquals("LatLngBounds should match", latLngBounds1, latLngBounds2);
}

@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() {

Expand Down

0 comments on commit 4191c4b

Please sign in to comment.