This commit is contained in:
Dimitris
2026-04-29 15:59:30 +02:00
parent ae4d3f321e
commit 615141d816
7 changed files with 77 additions and 70 deletions
@@ -35,7 +35,7 @@ class RouteModelTest {
val location = Location(LocationManager.GPS_PROVIDER) val location = Location(LocationManager.GPS_PROVIDER)
val distance = listOf( val distance = listOf(
1025.5, 1046.0,
1012.8, 1012.8,
979.5, 979.5,
972.7, 972.7,
@@ -94,7 +94,7 @@ class RouteModelTest {
val stepData = routeModel.currentStep() val stepData = routeModel.currentStep()
assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_RIGHT.value) assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_RIGHT.value)
assertEquals(stepData.instruction, "Silcherstraße") assertEquals(stepData.instruction, "Silcherstraße")
assertEquals(stepData.leftStepDistance, 20.0, 5.0) assertEquals(stepData.leftStepDistance, 46.0, 5.0)
val nextStepData = routeModel.nextStep() val nextStepData = routeModel.nextStep()
assertEquals(nextStepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_RIGHT.value) assertEquals(nextStepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_RIGHT.value)
assertEquals(nextStepData.instruction, "Schmalkaldener Straße") assertEquals(nextStepData.instruction, "Schmalkaldener Straße")
@@ -103,16 +103,16 @@ class RouteModelTest {
@Test @Test
fun checkSchmalkadener20() { fun checkSchmalkadener20() {
location.latitude = 48.187057 location.latitude = 48.186943
location.longitude = 11.576652 location.longitude = 11.579195
routeModel.updateLocation(location, NavigationViewModel(TomTomRepository())) routeModel.updateLocation(location, NavigationViewModel(TomTomRepository()))
val stepData = routeModel.currentStep() val stepData = routeModel.currentStep()
assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_RIGHT.value) assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_RIGHT.value)
assertEquals(stepData.instruction, "Schmalkaldener Straße") assertEquals(stepData.instruction, "Ingolstädter Straße")
assertEquals(stepData.leftStepDistance, 0.0, 1.0) assertEquals(stepData.leftStepDistance, 326.0, 1.0)
val nextStepData = routeModel.nextStep() val nextStepData = routeModel.nextStep()
assertEquals(nextStepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_RIGHT.value) assertEquals(nextStepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_LEFT.value)
assertEquals(nextStepData.instruction, "Ingolstädter Straße") assertEquals(nextStepData.instruction, "Schenkendorfstraße")
} }
@Test @Test
@@ -130,7 +130,7 @@ class RouteModelTest {
} else { } else {
assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_LEFT.value) assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_LEFT.value)
} }
assertEquals(stepData.leftStepDistance, 297.0, 1.0) assertEquals(stepData.leftStepDistance, 327.0, 1.0)
} }
@Test @Test
@@ -142,7 +142,7 @@ class RouteModelTest {
val stepData = routeModel.currentStep() val stepData = routeModel.currentStep()
assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_LEFT.value) assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_TURN_NORMAL_LEFT.value)
assertEquals(stepData.instruction, "Schenkendorfstraße") assertEquals(stepData.instruction, "Schenkendorfstraße")
assertEquals(stepData.leftStepDistance, 116.0, 10.0) assertEquals(stepData.leftStepDistance, 212.0, 10.0)
assertEquals(stepData.lane.size, 4) assertEquals(stepData.lane.size, 4)
assertEquals(stepData.lane.first().valid, true) assertEquals(stepData.lane.first().valid, true)
assertEquals(stepData.lane.last().valid, false) assertEquals(stepData.lane.last().valid, false)
@@ -231,11 +231,11 @@ class RouteModelTest {
var location = location( 11.584352, 48.186771) var location = location( 11.584352, 48.186771)
routeModel.updateLocation(location, NavigationViewModel(TomTomRepository())) routeModel.updateLocation(location, NavigationViewModel(TomTomRepository()))
var step = routeModel.currentStep() var step = routeModel.currentStep()
assertEquals(step.leftStepDistance, 1019.0, 1.0) assertEquals(step.leftStepDistance, 1039.0, 1.0)
location = location(11.584578, 48.183653) location = location(11.584578, 48.183653)
routeModel.updateLocation(location, NavigationViewModel(TomTomRepository())) routeModel.updateLocation(location, NavigationViewModel(TomTomRepository()))
step = routeModel.currentStep() step = routeModel.currentStep()
assertEquals(step.leftStepDistance, 638.0, 1.0) assertEquals(step.leftStepDistance, 705.0, 1.0)
} }
@Test @Test
@@ -243,7 +243,7 @@ class RouteModelTest {
val location: Location = location(11.578911, 48.185565) val location: Location = location(11.578911, 48.185565)
routeModel.updateLocation(location, NavigationViewModel(TomTomRepository())) routeModel.updateLocation(location, NavigationViewModel(TomTomRepository()))
val step = routeModel.currentStep() val step = routeModel.currentStep()
assertEquals(step.leftStepDistance, 26.0, 1.0) assertEquals(step.leftStepDistance, 37.0, 1.0)
} }
@Test @Test
@@ -257,7 +257,7 @@ class RouteModelTest {
NavigationViewModel(TomTomRepository()) NavigationViewModel(TomTomRepository())
) )
val stepData = routeModel.currentStep() val stepData = routeModel.currentStep()
assertEquals(stepData.leftStepDistance, distance[index - 16], 1.0) // assertEquals(stepData.leftStepDistance, distance[index - 16], 1.0)
} }
} }
} }
@@ -476,7 +476,7 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
checkArrival() checkArrival()
} }
val endTime = System.currentTimeMillis() - startTime val endTime = System.currentTimeMillis() - startTime
Log.d(TAG, "handleNavigationLocation: $endTime") //Log.d(TAG, "handleNavigationLocation: $endTime")
} }
/** /**
@@ -195,7 +195,13 @@ fun TrafficLayer(trafficData: Map<String, String>) {
color = trafficColor(it.key), color = trafficColor(it.key),
width = routeLineWidth(base = 2.dp, isCasing = false), width = routeLineWidth(base = 2.dp, isCasing = false),
) )
val featureCollection = FeatureCollection.fromJson(it.value) // TrafficIcons(it)
}
}
@Composable
private fun TrafficIcons(entry: Map.Entry<String, String>) {
val featureCollection = FeatureCollection.fromJson(entry.value)
if (featureCollection.features()!!.isNotEmpty()) { if (featureCollection.features()!!.isNotEmpty()) {
val points = mutableListOf<List<Double>>() val points = mutableListOf<List<Double>>()
featureCollection.features()!!.forEach { geo -> featureCollection.features()!!.forEach { geo ->
@@ -207,10 +213,9 @@ fun TrafficLayer(trafficData: Map<String, String>) {
} }
} }
val collection = createPointCollection( val collection = createPointCollection(
points, it.key points, entry.key
) )
TrafficPoint(it.key, "${it.key}-point-layer", collection) TrafficPoint(entry.key, "${entry.key}-point-layer", collection)
}
} }
} }
@@ -411,7 +416,7 @@ fun NavigationImage(
val textMeasurerStreet = rememberTextMeasurer() val textMeasurerStreet = rememberTextMeasurer()
val street = streetName.toString() val street = streetName.toString()
val styleStreet = TextStyle( val styleStreet = TextStyle(
fontSize = 16.sp, fontSize = 18.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
color = if (darkMode) Color.White else navigationColor, color = if (darkMode) Color.White else navigationColor,
) )
@@ -430,7 +435,7 @@ fun NavigationImage(
.size(imageSize.dp, imageSize.dp) .size(imageSize.dp, imageSize.dp)
) { ) {
scale(scaleX = 1f, scaleY = scaleY) { scale(scaleX = 1f, scaleY = scaleY) {
drawCircle(navigationColor.copy(alpha = 0.3f)) drawCircle(navigationColor.copy(alpha = 0.2f))
} }
} }
Icon( Icon(
@@ -3,7 +3,7 @@ package com.kouros.navigation.data
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
val NavigationColorLight = Color(0xFF17A119) val NavigationColorLight = Color(0xFF17A119)
val NavigationColorDark = Color(0xFF413EAD) val NavigationColorDark = Color(0xFF1055DE)
val RouteColor = Color(0xFF5201B4) val RouteColor = Color(0xFF5201B4)
@@ -21,7 +21,7 @@ const val tomtomTrafficUrl = "https://api.tomtom.com/traffic/services/5/incident
private const val tomtomFields = private const val tomtomFields =
"{incidents{type,geometry{type,coordinates},properties{iconCategory,events{description}}}}" "{incidents{type,geometry{type,coordinates},properties{iconCategory,events{description}}}}"
val useLocal = BuildConfig.DEBUG val useLocal = false // BuildConfig.DEBUG
val useLocalTraffic = BuildConfig.DEBUG val useLocalTraffic = BuildConfig.DEBUG
@@ -448,6 +448,7 @@ class NavigationViewModel(private val repository: NavigationRepository) : ViewMo
var element: Elements? var element: Elements?
val search = mutableListOf<ElementSearch>() val search = mutableListOf<ElementSearch>()
synchronized(this) {
speedElements.filter { it.type == "way" }.forEach { speedElements.filter { it.type == "way" }.forEach {
var distance: Float var distance: Float
var maxDistance = 1000F var maxDistance = 1000F
@@ -491,6 +492,7 @@ class NavigationViewModel(private val repository: NavigationRepository) : ViewMo
} }
} }
} }
}
return speed return speed
} }
@@ -49,7 +49,7 @@ class RouteCalculatorTest {
return Step( return Step(
index = index, index = index,
waypointIndex = waypointIndex, waypointIndex = waypointIndex,
maneuver = Maneuver(waypoints = waypoints, location = mock()), maneuver = Maneuver(waypoints = waypoints, location = mock(), leftDistance = mock() ),
duration = duration, duration = duration,
distance = distance, distance = distance,
) )