Nominatim

This commit is contained in:
Dimitris
2026-03-30 09:58:13 +02:00
parent bd8a497fbe
commit 9def7a5c64
@@ -38,12 +38,16 @@ abstract class NavigationRepository {
} }
fun searchPlaces(search: String, location: Location): String { fun searchPlaces(search: String, location: Location): String {
val box = calculateSquareRadius(location.latitude, location.longitude, 800.0) val box = calculateSquareRadius(location.latitude, location.longitude, 50.0)
val viewbox = "&bounded=1&viewbox=${box}" val viewbox = "&bounded=1&viewbox=${box}"
return fetchUrl( var result = fetchUrl(
"${nominatimUrl}search?q=$search&format=jsonv2&addressdetails=true$viewbox", "${nominatimUrl}search?q=$search&format=jsonv2&addressdetails=true$viewbox",
true false
) )
if (result == "[]") {
result = fetchUrl("${nominatimUrl}search?q=$search&format=jsonv2&addressdetails=true", false)
}
return result
} }
fun reverseAddress(location: Location): String { fun reverseAddress(location: Location): String {
@@ -67,7 +71,7 @@ abstract class NavigationRepository {
} }
}) })
} }
Log.d("fetchUrl", url) Log.d("NavigationRepository", url)
val httpURLConnection = URL(url).openConnection() as HttpURLConnection val httpURLConnection = URL(url).openConnection() as HttpURLConnection
httpURLConnection.setRequestProperty( httpURLConnection.setRequestProperty(
"Accept", "Accept",