[android] LatLngBounds were not build correctly when lons were the same (#11647)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user