Loading cardinal-android/app/src/main/java/earth/maps/cardinal/routing/RoutingOptions.kt +24 −9 Original line number Diff line number Diff line Loading @@ -67,12 +67,12 @@ interface AutoOptions { * Routing options for automobile mode. */ data class AutoRoutingOptions( override val costingType: String = "auto", override val costingType: String = COSTING_TYPE_AUTO, // Maneuver and access penalties override val maneuverPenalty: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val maneuverPenalty: Double? = DEFAULT_MANEUVER_PENALTY, override val gateCost: Double? = DEFAULT_GATE_COST, override val tollBoothCost: Double? = DEFAULT_TOLL_BOOTH_COST, override val privateAccessPenalty: Double? = null, // Road type preferences (0-1 range) Loading @@ -90,18 +90,26 @@ data class AutoRoutingOptions( // HOV options override val excludeUnpaved: Boolean? = null, override val excludeCashOnlyTolls: Boolean? = null ) : RoutingOptions(), AutoOptions ) : RoutingOptions(), AutoOptions { companion object { const val COSTING_TYPE_AUTO = "auto" const val DEFAULT_MANEUVER_PENALTY = 25.0 const val DEFAULT_GATE_COST = 45.0 const val DEFAULT_TOLL_BOOTH_COST = 30.0 } } /** * Routing options for truck mode (extends auto with truck-specific parameters). */ data class TruckRoutingOptions( override val costingType: String = "truck", override val costingType: String = COSTING_TYPE_AUTO, // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val gateCost: Double? = DEFAULT_GATE_COST, override val tollBoothCost: Double? = DEFAULT_TOLL_BOOTH_COST, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading @@ -122,7 +130,14 @@ data class TruckRoutingOptions( val axleCount: Int? = null, val hazmat: Boolean? = null, val useTruckRoute: Double? = null // 0-1 range ) : RoutingOptions(), AutoOptions ) : RoutingOptions(), AutoOptions { companion object { const val COSTING_TYPE_AUTO = "truck" const val DEFAULT_GATE_COST = 45.0 const val DEFAULT_TOLL_BOOTH_COST = 30.0 } } /** * Routing options for motor scooter mode. Loading cardinal-android/app/src/main/java/earth/maps/cardinal/ui/navigation/NavigationChrome.kt +2 −30 Original line number Diff line number Diff line package earth.maps.cardinal.ui.navigation import android.util.Log import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer Loading Loading @@ -126,26 +127,10 @@ 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 correctedProgress = remember(progress, smoothedSpeedMs) { val finalDuration = if (smoothedSpeedMs != null) { // We have enough data for a dynamic estimate (remainingMeters / smoothedSpeedMs) } else { // Fallback to the original route estimate during "warm-up" progress.durationRemaining } progress.copy( durationRemaining = finalDuration ) } TripProgressView( modifier = modifier, theme = CardinalNavigationUITheme.tripProgressViewTheme, progress = correctedProgress, progress = progress, onTapExit = onTapExit, distanceFormatter = distanceFormatter, fromDate = now, Loading Loading @@ -211,7 +196,6 @@ class NavigationChromeViewModel @Inject constructor( val now = MutableStateFlow(Clock.System.now()) val distanceUnits = appPreferences.distanceUnit private val speedBuffer = mutableListOf<Double>() private var cleared = false Loading @@ -223,15 +207,6 @@ class NavigationChromeViewModel @Inject constructor( } } } fun getSmoothedSpeed(currentSpeedInMs: Double): Float? { if (speedBuffer.size >= SPEED_WINDOW_SIZE) speedBuffer.removeAt(0) speedBuffer.add(currentSpeedInMs.coerceAtLeast(MINIMUM_SPEED)) if (speedBuffer.size < SPEED_WINDOW_SIZE) return null val average = speedBuffer.average() return if (average < MINIMUM_SPEED) null else average.toFloat() } override fun onCleared() { cleared = true super.onCleared() Loading @@ -239,8 +214,5 @@ class NavigationChromeViewModel @Inject constructor( companion object { private val DELAY = 5.seconds private const val SPEED_WINDOW_SIZE = 5 private const val MINIMUM_SPEED = 0.5 } } Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/routing/RoutingOptions.kt +24 −9 Original line number Diff line number Diff line Loading @@ -67,12 +67,12 @@ interface AutoOptions { * Routing options for automobile mode. */ data class AutoRoutingOptions( override val costingType: String = "auto", override val costingType: String = COSTING_TYPE_AUTO, // Maneuver and access penalties override val maneuverPenalty: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val maneuverPenalty: Double? = DEFAULT_MANEUVER_PENALTY, override val gateCost: Double? = DEFAULT_GATE_COST, override val tollBoothCost: Double? = DEFAULT_TOLL_BOOTH_COST, override val privateAccessPenalty: Double? = null, // Road type preferences (0-1 range) Loading @@ -90,18 +90,26 @@ data class AutoRoutingOptions( // HOV options override val excludeUnpaved: Boolean? = null, override val excludeCashOnlyTolls: Boolean? = null ) : RoutingOptions(), AutoOptions ) : RoutingOptions(), AutoOptions { companion object { const val COSTING_TYPE_AUTO = "auto" const val DEFAULT_MANEUVER_PENALTY = 25.0 const val DEFAULT_GATE_COST = 45.0 const val DEFAULT_TOLL_BOOTH_COST = 30.0 } } /** * Routing options for truck mode (extends auto with truck-specific parameters). */ data class TruckRoutingOptions( override val costingType: String = "truck", override val costingType: String = COSTING_TYPE_AUTO, // Basic auto options override val maneuverPenalty: Double? = null, override val gateCost: Double? = 45.0, override val tollBoothCost: Double? = 30.0, override val gateCost: Double? = DEFAULT_GATE_COST, override val tollBoothCost: Double? = DEFAULT_TOLL_BOOTH_COST, override val privateAccessPenalty: Double? = null, override val useHighways: Double? = null, override val useTolls: Double? = null, Loading @@ -122,7 +130,14 @@ data class TruckRoutingOptions( val axleCount: Int? = null, val hazmat: Boolean? = null, val useTruckRoute: Double? = null // 0-1 range ) : RoutingOptions(), AutoOptions ) : RoutingOptions(), AutoOptions { companion object { const val COSTING_TYPE_AUTO = "truck" const val DEFAULT_GATE_COST = 45.0 const val DEFAULT_TOLL_BOOTH_COST = 30.0 } } /** * Routing options for motor scooter mode. Loading
cardinal-android/app/src/main/java/earth/maps/cardinal/ui/navigation/NavigationChrome.kt +2 −30 Original line number Diff line number Diff line package earth.maps.cardinal.ui.navigation import android.util.Log import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer Loading Loading @@ -126,26 +127,10 @@ 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 correctedProgress = remember(progress, smoothedSpeedMs) { val finalDuration = if (smoothedSpeedMs != null) { // We have enough data for a dynamic estimate (remainingMeters / smoothedSpeedMs) } else { // Fallback to the original route estimate during "warm-up" progress.durationRemaining } progress.copy( durationRemaining = finalDuration ) } TripProgressView( modifier = modifier, theme = CardinalNavigationUITheme.tripProgressViewTheme, progress = correctedProgress, progress = progress, onTapExit = onTapExit, distanceFormatter = distanceFormatter, fromDate = now, Loading Loading @@ -211,7 +196,6 @@ class NavigationChromeViewModel @Inject constructor( val now = MutableStateFlow(Clock.System.now()) val distanceUnits = appPreferences.distanceUnit private val speedBuffer = mutableListOf<Double>() private var cleared = false Loading @@ -223,15 +207,6 @@ class NavigationChromeViewModel @Inject constructor( } } } fun getSmoothedSpeed(currentSpeedInMs: Double): Float? { if (speedBuffer.size >= SPEED_WINDOW_SIZE) speedBuffer.removeAt(0) speedBuffer.add(currentSpeedInMs.coerceAtLeast(MINIMUM_SPEED)) if (speedBuffer.size < SPEED_WINDOW_SIZE) return null val average = speedBuffer.average() return if (average < MINIMUM_SPEED) null else average.toFloat() } override fun onCleared() { cleared = true super.onCleared() Loading @@ -239,8 +214,5 @@ class NavigationChromeViewModel @Inject constructor( companion object { private val DELAY = 5.seconds private const val SPEED_WINDOW_SIZE = 5 private const val MINIMUM_SPEED = 0.5 } }