Merge pull request #928 from RSBat/no-data-fix

Fixed issue #927
This commit is contained in:
neslihanturan 2017-10-30 17:27:13 +03:00 committed by GitHub
commit 1f88b6d58a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,7 +46,7 @@ public class NearbyPlaces {
try { try {
// increase the radius gradually to find a satisfactory number of nearby places // increase the radius gradually to find a satisfactory number of nearby places
while (radius < MAX_RADIUS) { while (radius <= MAX_RADIUS) {
places = getFromWikidataQuery(curLatLng, lang, radius); places = getFromWikidataQuery(curLatLng, lang, radius);
Timber.d("%d results at radius: %f", places.size(), radius); Timber.d("%d results at radius: %f", places.size(), radius);
if (places.size() >= MIN_RESULTS) { if (places.size() >= MIN_RESULTS) {
@ -62,6 +62,11 @@ public class NearbyPlaces {
Timber.d("back to initial radius: %f", radius); Timber.d("back to initial radius: %f", radius);
radius = INITIAL_RADIUS; radius = INITIAL_RADIUS;
} }
// make sure we will be able to send at least one request next time
if (radius > MAX_RADIUS) {
radius = MAX_RADIUS;
}
return places; return places;
} }