Merge remote-tracking branch 'refs/remotes/origin/2.7.x-release'

This commit is contained in:
misaochan 2018-03-28 22:25:57 +10:00
commit a927a80265

View file

@ -54,15 +54,17 @@ public class NearbyController {
} }
List<Place> places = nearbyPlaces.getFromWikidataQuery(curLatLng, Locale.getDefault().getLanguage()); List<Place> places = nearbyPlaces.getFromWikidataQuery(curLatLng, Locale.getDefault().getLanguage());
if (places.size() > 0) {
LatLng[] boundaryCoordinates = {places.get(0).location, // south LatLng[] boundaryCoordinates = {places.get(0).location, // south
places.get(0).location, // north places.get(0).location, // north
places.get(0).location, // west places.get(0).location, // west
places.get(0).location};// east, init with a random location places.get(0).location};// east, init with a random location
if (curLatLng != null) { if (curLatLng != null) {
Timber.d("Sorting places by distance..."); Timber.d("Sorting places by distance...");
final Map<Place, Double> distances = new HashMap<>(); final Map<Place, Double> distances = new HashMap<>();
for (Place place: places) { for (Place place : places) {
distances.put(place, computeDistanceBetween(place.location, curLatLng)); distances.put(place, computeDistanceBetween(place.location, curLatLng));
// Find boundaries with basic find max approach // Find boundaries with basic find max approach
if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) { if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) {
@ -90,6 +92,10 @@ public class NearbyController {
nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates; nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates;
return nearbyPlacesInfo; return nearbyPlacesInfo;
} }
else {
return null;
}
}
/** /**
* Loads attractions from location for list view, we need to return Place data type. * Loads attractions from location for list view, we need to return Place data type.