Loading cardinal-android/app/src/main/java/earth/maps/cardinal/routing/RoutingOptions.kt +7 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ interface AutoOptions { val maneuverPenalty: Double? val gateCost: Double? val privateAccessPenalty: Double? val tollBoothCost: Double? val useHighways: Double? val useTolls: Double? val useLivingStreets: Double? Loading @@ -70,7 +71,8 @@ data class AutoRoutingOptions( // Maneuver and access penalties override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val privateAccessPenalty: Double? = null, // Road type preferences (0-1 range) Loading Loading @@ -98,7 +100,8 @@ data class TruckRoutingOptions( // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading Loading @@ -130,6 +133,7 @@ data class MotorScooterRoutingOptions( // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val tollBoothCost: Double? = null, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading @@ -156,6 +160,7 @@ data class MotorcycleRoutingOptions( // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val tollBoothCost: Double? = null, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading cardinal-android/app/src/main/java/earth/maps/cardinal/ui/navigation/NavigationChrome.kt +19 −1 Original line number Diff line number Diff line Loading @@ -126,10 +126,19 @@ fun CardinalProgressView( } val distanceFormatter = remember(distanceMeasurementSystem) { LocalizedDistanceFormatter(distanceMeasurementSystemOverride = distanceMeasurementSystem) } uiState.progress?.let { progress -> val smoothedSpeedMs = viewModel.getSmoothedSpeed(uiState.location?.speed?.value ?: 0.0) val remainingMeters = progress.distanceRemaining val correctedSeconds = remainingMeters / smoothedSpeedMs val correctedProgress = remember(progress, correctedSeconds) { progress.copy( durationRemaining = maxOf(correctedSeconds, progress.durationRemaining) ) } TripProgressView( modifier = modifier, theme = CardinalNavigationUITheme.tripProgressViewTheme, progress = progress, progress = correctedProgress, onTapExit = onTapExit, distanceFormatter = distanceFormatter, fromDate = now, Loading Loading @@ -195,6 +204,7 @@ class NavigationChromeViewModel @Inject constructor( val now = MutableStateFlow(Clock.System.now()) val distanceUnits = appPreferences.distanceUnit private val speedBuffer = mutableListOf<Double>() private var cleared = false Loading @@ -207,6 +217,12 @@ class NavigationChromeViewModel @Inject constructor( } } fun getSmoothedSpeed(currentSpeedInMs: Double): Float { if (speedBuffer.size >= SPEED_WINDOW_SIZE) speedBuffer.removeAt(0) speedBuffer.add(currentSpeedInMs.coerceAtLeast(0.5)) return speedBuffer.average().toFloat() } override fun onCleared() { cleared = true super.onCleared() Loading @@ -214,5 +230,7 @@ class NavigationChromeViewModel @Inject constructor( companion object { private val DELAY = 5.seconds private const val SPEED_WINDOW_SIZE = 5 } } Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/routing/RoutingOptions.kt +7 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ interface AutoOptions { val maneuverPenalty: Double? val gateCost: Double? val privateAccessPenalty: Double? val tollBoothCost: Double? val useHighways: Double? val useTolls: Double? val useLivingStreets: Double? Loading @@ -70,7 +71,8 @@ data class AutoRoutingOptions( // Maneuver and access penalties override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val privateAccessPenalty: Double? = null, // Road type preferences (0-1 range) Loading Loading @@ -98,7 +100,8 @@ data class TruckRoutingOptions( // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading Loading @@ -130,6 +133,7 @@ data class MotorScooterRoutingOptions( // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val tollBoothCost: Double? = null, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading @@ -156,6 +160,7 @@ data class MotorcycleRoutingOptions( // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = null, override val tollBoothCost: Double? = null, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/ui/navigation/NavigationChrome.kt +19 −1 Original line number Diff line number Diff line Loading @@ -126,10 +126,19 @@ fun CardinalProgressView( } val distanceFormatter = remember(distanceMeasurementSystem) { LocalizedDistanceFormatter(distanceMeasurementSystemOverride = distanceMeasurementSystem) } uiState.progress?.let { progress -> val smoothedSpeedMs = viewModel.getSmoothedSpeed(uiState.location?.speed?.value ?: 0.0) val remainingMeters = progress.distanceRemaining val correctedSeconds = remainingMeters / smoothedSpeedMs val correctedProgress = remember(progress, correctedSeconds) { progress.copy( durationRemaining = maxOf(correctedSeconds, progress.durationRemaining) ) } TripProgressView( modifier = modifier, theme = CardinalNavigationUITheme.tripProgressViewTheme, progress = progress, progress = correctedProgress, onTapExit = onTapExit, distanceFormatter = distanceFormatter, fromDate = now, Loading Loading @@ -195,6 +204,7 @@ class NavigationChromeViewModel @Inject constructor( val now = MutableStateFlow(Clock.System.now()) val distanceUnits = appPreferences.distanceUnit private val speedBuffer = mutableListOf<Double>() private var cleared = false Loading @@ -207,6 +217,12 @@ class NavigationChromeViewModel @Inject constructor( } } fun getSmoothedSpeed(currentSpeedInMs: Double): Float { if (speedBuffer.size >= SPEED_WINDOW_SIZE) speedBuffer.removeAt(0) speedBuffer.add(currentSpeedInMs.coerceAtLeast(0.5)) return speedBuffer.average().toFloat() } override fun onCleared() { cleared = true super.onCleared() Loading @@ -214,5 +230,7 @@ class NavigationChromeViewModel @Inject constructor( companion object { private val DELAY = 5.seconds private const val SPEED_WINDOW_SIZE = 5 } }