mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-01 07:13:56 +01:00
Nearby: Increase max radius from 100km to 300km
This commit is contained in:
parent
42a9c7d9bc
commit
7825a9945e
3 changed files with 14 additions and 6 deletions
|
|
@ -359,7 +359,7 @@ class OkHttpJsonApiClient @Inject constructor(
|
||||||
"\${LONG}",
|
"\${LONG}",
|
||||||
String.format(Locale.ROOT, "%.4f", queryParams.center.longitude)
|
String.format(Locale.ROOT, "%.4f", queryParams.center.longitude)
|
||||||
)
|
)
|
||||||
.replace("\${RAD}", String.format(Locale.ROOT, "%.2f", queryParams.radius))
|
.replace("\${RAD}", String.format(Locale.ROOT, "%.2f", queryParams.radiusInKm))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -425,7 +425,7 @@ class OkHttpJsonApiClient @Inject constructor(
|
||||||
).replace(
|
).replace(
|
||||||
"\${LONG}", String.format(locale, "%.4f", queryParams.center.longitude)
|
"\${LONG}", String.format(locale, "%.4f", queryParams.center.longitude)
|
||||||
)
|
)
|
||||||
.replace("\${RAD}", String.format(locale, "%.2f", queryParams.radius))
|
.replace("\${RAD}", String.format(locale, "%.2f", queryParams.radiusInKm))
|
||||||
}
|
}
|
||||||
|
|
||||||
is NearbyQueryParams.Rectangular -> {
|
is NearbyQueryParams.Rectangular -> {
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,9 @@ public class NearbyPlaces {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int minRadius = 0, maxRadius = Math.round(Math.min(100f, Math.min(longGap, latGap))) * 100;
|
// minRadius, targetRadius and maxRadius are radii in decameters
|
||||||
|
// unlike other
|
||||||
|
int minRadius = 0, maxRadius = Math.round(Math.min(300f, Math.min(longGap, latGap))) * 100;
|
||||||
int targetRadius = maxRadius / 2;
|
int targetRadius = maxRadius / 2;
|
||||||
while (minRadius < maxRadius) {
|
while (minRadius < maxRadius) {
|
||||||
targetRadius = minRadius + (maxRadius - minRadius + 1) / 2;
|
targetRadius = minRadius + (maxRadius - minRadius + 1) / 2;
|
||||||
|
|
@ -156,8 +158,14 @@ public class NearbyPlaces {
|
||||||
if (itemCount >= lowerLimit && itemCount < upperLimit) {
|
if (itemCount >= lowerLimit && itemCount < upperLimit) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (targetRadius > maxRadius / 2 && itemCount < lowerLimit / 5) {
|
if (targetRadius > maxRadius / 2 && itemCount < lowerLimit / 5) { // fast forward
|
||||||
minRadius = targetRadius + (maxRadius - targetRadius + 1) / 2;
|
minRadius = targetRadius;
|
||||||
|
targetRadius = minRadius + (maxRadius - minRadius + 1) / 2;
|
||||||
|
minRadius = targetRadius;
|
||||||
|
if (itemCount < lowerLimit / 10 && minRadius < maxRadius) { // fast forward again
|
||||||
|
targetRadius = minRadius + (maxRadius - minRadius + 1) / 2;
|
||||||
|
minRadius = targetRadius;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (itemCount < upperLimit) {
|
if (itemCount < upperLimit) {
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,5 @@ sealed class NearbyQueryParams {
|
||||||
class Rectangular(val screenTopRight: LatLng, val screenBottomLeft: LatLng) :
|
class Rectangular(val screenTopRight: LatLng, val screenBottomLeft: LatLng) :
|
||||||
NearbyQueryParams()
|
NearbyQueryParams()
|
||||||
|
|
||||||
class Radial(val center: LatLng, val radius: Float) : NearbyQueryParams()
|
class Radial(val center: LatLng, val radiusInKm: Float) : NearbyQueryParams()
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue