FindStep
This commit is contained in:
@@ -446,6 +446,17 @@ class RouteModelTest {
|
||||
assertEquals(nextStepData.instruction, "Schmalkaldener Straße")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkArrival() {
|
||||
location.latitude = 48.116829
|
||||
location.longitude = 11.594309
|
||||
routeModel.updateLocation(location, NavigationViewModel(TomTomRepository()))
|
||||
val stepData = routeModel.currentStep()
|
||||
assertEquals(stepData.currentManeuverType, ManeuverType.TYPE_DESTINATION_LEFT.value)
|
||||
assertEquals(stepData.instruction, "Hohenwaldeckstraße")
|
||||
assertEquals(stepData.leftDistance, 0.0, 5.0)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkSchmalkadener20() {
|
||||
|
||||
@@ -80,10 +80,10 @@ class DeviceLocationManager(
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
fun locationFlow(): Flow<Location> = callbackFlow {
|
||||
val listener = LocationListener { location ->
|
||||
if (shouldUseDeviceLocation && isListening) {
|
||||
trySend(location) // Emit the location update to the flow
|
||||
}
|
||||
val listener = LocationListener { location ->
|
||||
if (shouldUseDeviceLocation && isListening) {
|
||||
trySend(location) // Emit the location update to the flow
|
||||
}
|
||||
}
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 5f, listener)
|
||||
awaitClose {
|
||||
@@ -101,22 +101,17 @@ class DeviceLocationManager(
|
||||
@SuppressLint("MissingPermission")
|
||||
fun startLocationUpdates(minTimeMs: Long = 1000, minDistanceM: Float = 5f) {
|
||||
if (isListening) return
|
||||
val setIndividualLocation = BuildConfig.DEBUG
|
||||
|
||||
// Get and deliver last known location first
|
||||
val lastLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)
|
||||
if (lastLocation != null) {
|
||||
if (setIndividualLocation) {
|
||||
onInitialLocation(homeVogelhart)
|
||||
onLocationUpdate(homeVogelhart)
|
||||
} else {
|
||||
if (BuildConfig.DEBUG) {
|
||||
onInitialLocation(homeVogelhart)
|
||||
onLocationUpdate(homeVogelhart)
|
||||
} else {
|
||||
// Get and deliver last known location first
|
||||
val lastLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)
|
||||
if (lastLocation != null) {
|
||||
onInitialLocation(lastLocation)
|
||||
onLocationUpdate(lastLocation)
|
||||
}
|
||||
}
|
||||
|
||||
// Start continuous location updates
|
||||
if (!setIndividualLocation) {
|
||||
// Start continuous location updates
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.GPS_PROVIDER,
|
||||
minTimeMs,
|
||||
|
||||
@@ -479,7 +479,7 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
checkArrival()
|
||||
}
|
||||
val end = System.currentTimeMillis()
|
||||
// Log.d(TAG, "UpdateLoction ${end-start} ms")
|
||||
Log.d(TAG, "UpdateLocation ${end-start} ms")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,6 +493,7 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
val distance = location.distanceTo(snappedLocation)
|
||||
when {
|
||||
distance > MAXIMAL_ROUTE_DEVIATION -> {
|
||||
Log.d(TAG, "Recalculate $distance ")
|
||||
stopNavigation()
|
||||
navigationScreen.calculateNewRoute(routeModel.navState.destination)
|
||||
return false
|
||||
@@ -548,6 +549,7 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
* Checks for arrival
|
||||
*/
|
||||
fun checkArrival() {
|
||||
Log.d(TAG, "maneuverType ${routeModel.navState.maneuverType} Distance ${routeModel.routeCalculator.leftStepDistance()}")
|
||||
if (routeModel.isManeuverArrival()
|
||||
&& routeModel.routeCalculator.leftStepDistance() < DESTINATION_ARRIVAL_DISTANCE
|
||||
) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.kouros.data.R
|
||||
import com.kouros.navigation.data.Constants
|
||||
import com.kouros.navigation.data.HeavyColor
|
||||
import com.kouros.navigation.data.LaneColor
|
||||
import com.kouros.navigation.data.NavigationCircle
|
||||
import com.kouros.navigation.data.NavigationColorDark
|
||||
import com.kouros.navigation.data.NavigationColorLight
|
||||
import com.kouros.navigation.data.PharmacyColor
|
||||
@@ -161,7 +162,7 @@ fun RouteLayer(routeData: String?) {
|
||||
fun TrafficLayer(trafficData: Map<String, String>) {
|
||||
trafficData.forEach {
|
||||
if (it.key == "closed") {
|
||||
ClosedLayer(it)
|
||||
//ClosedLayer(it)
|
||||
} else {
|
||||
val traffic = rememberGeoJsonSource(GeoJsonData.JsonString(it.value))
|
||||
LineLayer(
|
||||
@@ -464,7 +465,7 @@ fun NavigationImage(
|
||||
.size(imageSize.dp, imageSize.dp)
|
||||
) {
|
||||
scale(scaleX = 1f, scaleY = scaleY) {
|
||||
drawCircle(navigationColor.copy(alpha = 0.2f))
|
||||
drawCircle(NavigationCircle.copy(alpha = 0.4f))
|
||||
}
|
||||
}
|
||||
Icon(
|
||||
|
||||
@@ -63,7 +63,7 @@ class Simulation {
|
||||
// Update your app's state as if a real GPS update occurred
|
||||
updateLocation(fakeLocation)
|
||||
// Wait before moving to the next point (e.g., every 1 second)
|
||||
delay(1500)
|
||||
delay(1000)
|
||||
lastLocation = fakeLocation
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user