diff --git a/src/app/grapheneos/geocoder/GeocodeProviderImpl.kt b/src/app/grapheneos/geocoder/GeocodeProviderImpl.kt index 6197aee..f30b5e1 100644 --- a/src/app/grapheneos/geocoder/GeocodeProviderImpl.kt +++ b/src/app/grapheneos/geocoder/GeocodeProviderImpl.kt @@ -23,8 +23,8 @@ class GeocodeProviderImpl(private val context: Context) : GeocodeProviderBase(co ) { verboseLog(TAG) { "forward geocode parameters: locationName: ${request.locationName}, " + - "lowerLeftLatitude: ${request.lowerLeftLongitude}, lowerLeftLongitude: ${request.lowerLeftLongitude}, " + - "upperRightLatitude: ${request.upperRightLatitude}, upperrightlongitude: ${request.upperRightLongitude}, " + + "lowerLeftLatitude: ${request.lowerLeftLatitude}, lowerLeftLongitude: ${request.lowerLeftLongitude}, " + + "upperRightLatitude: ${request.upperRightLatitude}, upperRightLongitude: ${request.upperRightLongitude}, " + "maxResults: ${request.maxResults}, locale: ${request.locale}" } try { diff --git a/src/app/grapheneos/geocoder/NominatimGeocoder.kt b/src/app/grapheneos/geocoder/NominatimGeocoder.kt index 54aac58..a98e211 100644 --- a/src/app/grapheneos/geocoder/NominatimGeocoder.kt +++ b/src/app/grapheneos/geocoder/NominatimGeocoder.kt @@ -139,12 +139,17 @@ class NominatimGeocoder : Geocoder { } val result = mutableListOf
() for (feature in response.features?.take(expectedMaxResults) ?: emptyList()) { + val coordinates = feature.geometry.coordinates + if (coordinates.size < 2) { + Log.w(TAG, "skipping feature with invalid coordinates size: ${coordinates.size}") + continue + } val extra = feature.properties.geocoding.extra?.toMutableMap() // we don't know which locale was actually used, so we just assume it was the one // we requested val address = Address(preferredLocale) - address.latitude = feature.geometry.coordinates[1] - address.longitude = feature.geometry.coordinates[0] + address.latitude = coordinates[1] + address.longitude = coordinates[0] with(feature.properties.geocoding) { address.postalCode = this.postcode address.featureName = this.name diff --git a/src/app/grapheneos/networklocation/LocationReportingTask.kt b/src/app/grapheneos/networklocation/LocationReportingTask.kt index 72d1c37..8999d4e 100644 --- a/src/app/grapheneos/networklocation/LocationReportingTask.kt +++ b/src/app/grapheneos/networklocation/LocationReportingTask.kt @@ -540,10 +540,14 @@ class LocationReportingTask( val estimatedGeoPoint = enuPointToGeoPoint(enuPoint, refGeoPoint) loc.longitude = estimatedGeoPoint.longitude loc.latitude = estimatedGeoPoint.latitude - loc.accuracy = sqrt(max(result.x.sixSigmaSquared, result.y.sixSigmaSquared)).toFloat() + val accuracySixSigma = sqrt(max(result.x.sixSigmaSquared, result.y.sixSigmaSquared)) + // Convert from 6-sigma to 1-sigma + loc.accuracy = accuracySixSigma.div(6.0).toFloat() estimatedGeoPoint.altitude?.let { estimatedAltitude -> loc.altitude = estimatedAltitude - loc.verticalAccuracyMeters = sqrt(result.z.sixSigmaSquared).toFloat() + val verticalAccuracySixSigma = sqrt(result.z.sixSigmaSquared) + // Convert from 6-sigma to 1-sigma + loc.verticalAccuracyMeters = verticalAccuracySixSigma.div(6.0).toFloat() } return loc } diff --git a/src/app/grapheneos/networklocation/wifi/WifiApRanger.kt b/src/app/grapheneos/networklocation/wifi/WifiApRanger.kt index 9f7e663..31f3054 100644 --- a/src/app/grapheneos/networklocation/wifi/WifiApRanger.kt +++ b/src/app/grapheneos/networklocation/wifi/WifiApRanger.kt @@ -8,6 +8,7 @@ import android.net.wifi.rtt.RangingResultCallback import android.net.wifi.rtt.WifiRttManager import android.os.WorkSource import app.grapheneos.verboseLog +import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException @@ -19,6 +20,7 @@ private const val TAG = "WifiApRanger" * TODO: WIP Wi-Fi RTT AP ranger, not currently used. */ class WifiApRanger(private val context: Context) { + private val rangingExecutor: ExecutorService = Executors.newSingleThreadExecutor() @Throws(WifiRangerUnavailableException::class, WifiRangerFailedException::class) suspend fun range(scanResults: List