[android] LatLngBounds were not build correctly when lons were the same (#11647)

This commit is contained in:
Osana Babayan
2018-04-10 12:41:59 -04:00
committed by GitHub
parent aa43dfd6c1
commit 4191c4bbcb
2 changed files with 22 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -196,6 +196,27 @@ public class LatLngBoundsTest {
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() {