diff --git a/core/model/src/main/kotlin/org/meshtastic/core/model/util/LocationUtils.kt b/core/model/src/main/kotlin/org/meshtastic/core/model/util/LocationUtils.kt index e2d64e9f1..c2a194a9c 100644 --- a/core/model/src/main/kotlin/org/meshtastic/core/model/util/LocationUtils.kt +++ b/core/model/src/main/kotlin/org/meshtastic/core/model/util/LocationUtils.kt @@ -55,8 +55,7 @@ fun latLongToMeter(latitudeA: Double, longitudeA: Double, latitudeB: Double, lon // Same as above, but takes Mesh Position proto. @Suppress("MagicNumber") -fun positionToMeter(a: Position, b: Position): Double = - latLongToMeter(a.latitude * 1e-7, a.longitude * 1e-7, b.latitude * 1e-7, b.longitude * 1e-7) +fun positionToMeter(a: Position, b: Position): Double = latLongToMeter(a.latitude, a.longitude, b.latitude, b.longitude) /** * Computes the bearing in degrees between two points on Earth. diff --git a/feature/settings/src/main/kotlin/org/meshtastic/feature/settings/SettingsViewModel.kt b/feature/settings/src/main/kotlin/org/meshtastic/feature/settings/SettingsViewModel.kt index 7c5394ee8..0dc5ceb4e 100644 --- a/feature/settings/src/main/kotlin/org/meshtastic/feature/settings/SettingsViewModel.kt +++ b/feature/settings/src/main/kotlin/org/meshtastic/feature/settings/SettingsViewModel.kt @@ -142,8 +142,10 @@ constructor( // Capture the current node value while we're still on main thread val nodes = nodeRepository.nodeDBbyNum.value + // Converts a MeshProtos.Position (nullable) to a Position, but only if it's valid, otherwise returns null. + // The returned Position is guaranteed to be non-null and valid, or null if the input was null or invalid. val positionToPos: (MeshProtos.Position?) -> Position? = { meshPosition -> - meshPosition?.let { Position(it) }.takeIf { it?.isValid() == true } + meshPosition?.let { Position(it) }?.takeIf { it.isValid() } } writeToUri(uri) { writer -> @@ -151,7 +153,7 @@ constructor( @Suppress("MaxLineLength") writer.appendLine( - "\"date\",\"time\",\"from\",\"sender name\",\"sender lat\",\"sender long\",\"rx lat\",\"rx long\",\"rx elevation\",\"rx snr\",\"distance\",\"hop limit\",\"payload\"", + "\"date\",\"time\",\"from\",\"sender name\",\"sender lat\",\"sender long\",\"rx lat\",\"rx long\",\"rx elevation\",\"rx snr\",\"distance(m)\",\"hop limit\",\"payload\"", ) // Packets are ordered by time, we keep most recent position of