RouteCalculator

This commit is contained in:
Dimitris
2026-05-07 10:34:27 +02:00
parent 8b612d5b80
commit 72b3185280
8 changed files with 79 additions and 53 deletions
@@ -107,8 +107,8 @@ class DeviceLocationManager(
val lastLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)
if (lastLocation != null) {
if (setIndividualLocation) {
onInitialLocation(lastLocation)
onLocationUpdate(lastLocation)
onInitialLocation(homeVogelhart)
onLocationUpdate(homeVogelhart)
} else {
onInitialLocation(lastLocation)
onLocationUpdate(lastLocation)
@@ -485,6 +485,7 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
val distance = location.distanceTo(snappedLocation)
when {
distance > MAXIMAL_ROUTE_DEVIATION -> {
Log.d(TAG, "Maximal route deviation")
stopNavigation()
navigationScreen.calculateNewRoute(routeModel.navState.destination)
return false
@@ -28,8 +28,8 @@ class Simulation {
) {
if (routeModel.navState.route.isRouteValid()) {
if (BuildConfig.DEBUG) {
gpxSimulation(routeModel, lifecycleScope, updateLocation)
//currentSimulation(routeModel, lifecycleScope, updateLocation)
//gpxSimulation(routeModel, lifecycleScope, updateLocation)
currentSimulation(routeModel, lifecycleScope, updateLocation)
} else {
currentSimulation(routeModel, lifecycleScope, updateLocation)
}
@@ -46,7 +46,7 @@ class Simulation {
if (points.isEmpty()) return
simulationJob?.cancel()
var lastLocation = Location(LocationManager.FUSED_PROVIDER)
var curBearing = 0f
var curBearing: Float
simulationJob = lifecycleScope.launch {
for ((index, point) in points.withIndex()) {
if (index >= 0) {
@@ -90,7 +90,7 @@ class Simulation {
simulationJob?.cancel()
simulationJob =lifecycleScope.launch() {
var lastLocation = Location(LocationManager.FUSED_PROVIDER)
var curBearing = 0f
val curBearing = 0f
val parser = GPXParser()
val parsedGpx: Gpx? =
parser.parse(route.byteInputStream())
@@ -118,9 +118,6 @@ 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)
if (duration > 100) {
// delay(duration / 4)
}
delay(200)
lastTime = p.time
lastLocation = fakeLocation