[android] center was calculated incorrectly for LatLngBounds with zero span (#11650)

This commit is contained in:
Osana Babayan
2018-04-11 10:00:07 -04:00
committed by GitHub
parent a0d0776925
commit 797486bc5f
2 changed files with 24 additions and 4 deletions

View File

@@ -110,6 +110,14 @@ public class LatLngBoundsTest {
latLngSpan);
}
@Test
public void zeroLongitudeSpan() {
latLngBounds = LatLngBounds.from(10, 10, -10, 10);
LatLngSpan latLngSpan = latLngBounds.getSpan();
assertEquals("LatLngSpan should be shortest distance", new LatLngSpan(20, 0),
latLngSpan);
}
@Test
public void nearDateLineCenter1() {
latLngBounds = LatLngBounds.from(10, -175, -10, 165);
@@ -145,6 +153,19 @@ public class LatLngBoundsTest {
assertEquals("Center should match", new LatLng(0, 90), center);
}
@Test
public void centerForBoundsWithSameLongitude() {
latLngBounds = LatLngBounds.from(10, 10, -10, 10);
LatLng center = latLngBounds.getCenter();
assertEquals("Center should match", new LatLng(0, 10), center);
}
@Test
public void centerForBoundsWithSameLatitude() {
latLngBounds = LatLngBounds.from(10, 10, 10, -10);
LatLng center = latLngBounds.getCenter();
assertEquals("Center should match", new LatLng(10, 0), center);
}
@Test
public void center() {