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

[android] LatLngBounds were not build correctly when lon was the same #11647

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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