diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyPlaces.java b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyPlaces.java index 50d661ef6..de14a2ef8 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/NearbyPlaces.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/NearbyPlaces.java @@ -46,7 +46,7 @@ public class NearbyPlaces { try { // 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); Timber.d("%d results at radius: %f", places.size(), radius); if (places.size() >= MIN_RESULTS) { @@ -62,6 +62,11 @@ public class NearbyPlaces { Timber.d("back to initial radius: %f", 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; }