FindStep Performance
This commit is contained in:
@@ -31,7 +31,7 @@ fun test(applicationContext: Context, routeModel: RouteModel) {
|
||||
for ((index, step) in routeModel.curLeg.steps.withIndex()) {
|
||||
for ((windex, waypoint) in step.maneuver.waypoints.withIndex()) {
|
||||
routeModel.updateLocation(
|
||||
location(waypoint[0], waypoint[1]), navigationViewModel
|
||||
waypoint, navigationViewModel
|
||||
)
|
||||
val step = routeModel.currentStep()
|
||||
val nextStep = routeModel.nextStep()
|
||||
|
||||
@@ -33,38 +33,38 @@ class RouteModelTest {
|
||||
|
||||
val routeModel = RouteModel()
|
||||
val location = Location(LocationManager.GPS_PROVIDER)
|
||||
|
||||
val distance = listOf(
|
||||
1046.0,
|
||||
1012.8,
|
||||
979.5,
|
||||
1046.5,
|
||||
1026.5,
|
||||
1012.0,
|
||||
979.4,
|
||||
972.7,
|
||||
915.8,
|
||||
914.6,
|
||||
871.0,
|
||||
822.7,
|
||||
769.7,
|
||||
713.8,
|
||||
644.8,
|
||||
577.6,
|
||||
501.7,
|
||||
489.7,
|
||||
452.5,
|
||||
437.4,
|
||||
398.0,
|
||||
390.1,
|
||||
341.3,
|
||||
266.6,
|
||||
219.5,
|
||||
140.7,
|
||||
77.4,
|
||||
55.1,
|
||||
40.0,
|
||||
30.0,
|
||||
19.0,
|
||||
4.0
|
||||
971.6,
|
||||
914.8,
|
||||
873.6,
|
||||
831.3,
|
||||
781.1,
|
||||
719.9,
|
||||
653.1,
|
||||
578.4,
|
||||
566.2,
|
||||
490.4,
|
||||
482.6,
|
||||
451.4,
|
||||
443.6,
|
||||
391.2,
|
||||
346.7,
|
||||
316.6,
|
||||
237.5,
|
||||
141.7,
|
||||
78.22,
|
||||
55.94,
|
||||
41.31,
|
||||
31.0,
|
||||
20.9,
|
||||
)
|
||||
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
@@ -227,8 +227,7 @@ class RouteModelTest {
|
||||
|
||||
@Test
|
||||
fun `leftStepDistance Inglolstädter `() {
|
||||
|
||||
var location = location( 11.584352, 48.186771)
|
||||
var location = location(11.584352, 48.186771)
|
||||
routeModel.updateLocation(location, NavigationViewModel(TomTomRepository()))
|
||||
var step = routeModel.currentStep()
|
||||
assertEquals(step.leftStepDistance, 1039.0, 1.0)
|
||||
@@ -248,6 +247,7 @@ class RouteModelTest {
|
||||
|
||||
@Test
|
||||
fun leftStepDistance() {
|
||||
val start = System.currentTimeMillis()
|
||||
for ((index, waypoint) in routeModel.curRoute.waypoints.withIndex()) {
|
||||
val curLocation = location(waypoint[0], waypoint[1])
|
||||
if (routeModel.isNavigating()) {
|
||||
@@ -257,10 +257,12 @@ class RouteModelTest {
|
||||
NavigationViewModel(TomTomRepository())
|
||||
)
|
||||
val stepData = routeModel.currentStep()
|
||||
// assertEquals(stepData.leftStepDistance, distance[index - 16], 1.0)
|
||||
assertEquals(stepData.leftStepDistance, distance[index - 16], 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
val end = System.currentTimeMillis() - start
|
||||
println("Time $end")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -459,7 +459,6 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
* Snaps location to route and checks for deviation requiring reroute.
|
||||
*/
|
||||
private fun handleNavigationLocation(location: Location) {
|
||||
val startTime = System.currentTimeMillis()
|
||||
routeModel.updateLocation(location, navigationViewModel)
|
||||
val snappedLocation = snapLocation(location, routeModel.route.maneuverLocations())
|
||||
val streetName = routeModel.currentStep().street
|
||||
@@ -475,8 +474,6 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
updateNavigationScreen()
|
||||
checkArrival()
|
||||
}
|
||||
val endTime = System.currentTimeMillis() - startTime
|
||||
//Log.d(TAG, "handleNavigationLocation: $endTime")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,7 +493,6 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
}
|
||||
else -> {
|
||||
surfaceRenderer.updateLocation(location, streetName)
|
||||
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -116,7 +116,7 @@ data class Route(
|
||||
val points = mutableListOf<Point>()
|
||||
for ((index,loc) in waypoints.withIndex()) {
|
||||
if (index >= wayPointIndex && points.size < 20) {
|
||||
val point = Point.fromLngLat(loc[0], loc[1])
|
||||
val point = Point.fromLngLat(loc.longitude, loc.latitude)
|
||||
points.add(point)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class OsrmRoute {
|
||||
bearingBefore = step.maneuver.bearingBefore,
|
||||
bearingAfter = step.maneuver.bearingAfter,
|
||||
type = convertType(step.maneuver),
|
||||
waypoints = points,
|
||||
waypoints = points.map { location(it[0], it[1]) },
|
||||
exit = step.maneuver.exit,
|
||||
location = location(
|
||||
step.maneuver.location[0],
|
||||
|
||||
@@ -58,7 +58,7 @@ class Overpass {
|
||||
|out body geom;
|
||||
""".trimMargin()
|
||||
|
||||
Log.d("OverpassApi", "Overpass Query: $searchQuery")
|
||||
//Log.d("OverpassApi", "Overpass Query: $searchQuery")
|
||||
val connection = (URL(overpassUrl).openConnection() as HttpURLConnection).apply {
|
||||
requestMethod = "POST"
|
||||
setRequestProperty("Accept", "application/json")
|
||||
|
||||
@@ -6,7 +6,7 @@ data class Maneuver(
|
||||
val bearingBefore: Int = 0,
|
||||
val bearingAfter: Int = 0,
|
||||
val type: Int = 0,
|
||||
val waypoints: List<List<Double>>,
|
||||
val waypoints: List<Location>,
|
||||
val location: Location,
|
||||
val exit: Int = 0,
|
||||
val street: String = "",
|
||||
|
||||
@@ -21,7 +21,7 @@ const val tomtomTrafficUrl = "https://api.tomtom.com/traffic/services/5/incident
|
||||
private const val tomtomFields =
|
||||
"{incidents{type,geometry{type,coordinates},properties{iconCategory,events{description}}}}"
|
||||
|
||||
val useLocal = false // BuildConfig.DEBUG
|
||||
val useLocal = BuildConfig.DEBUG
|
||||
|
||||
val useLocalTraffic = BuildConfig.DEBUG
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class TomTomRoute {
|
||||
waypoints = points.subList(
|
||||
lastPointIndex,
|
||||
instruction.pointIndex + 1,
|
||||
),
|
||||
).map { location(it[0], it[1]) },
|
||||
exit = exitNumber(instruction),
|
||||
location = location(
|
||||
instruction.point.longitude, instruction.point.latitude
|
||||
|
||||
@@ -25,7 +25,7 @@ class ValhallaRoute {
|
||||
bearingAfter = it.bearingAfter,
|
||||
//type = it.type,
|
||||
type = convertType(it),
|
||||
waypoints =waypoints.subList(it.beginShapeIndex, it.endShapeIndex+1),
|
||||
waypoints = waypoints.subList(it.beginShapeIndex, it.endShapeIndex + 1).map { location(it[0], it[1]) },
|
||||
// TODO: calculate from ShapeIndex !
|
||||
location = location(0.0, 0.0),
|
||||
leftDistance = emptyList()
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.kouros.navigation.data.ApplicationConfig
|
||||
import com.kouros.navigation.data.Constants.MAXIMUM_LOCATION_DISTANCE
|
||||
import com.kouros.navigation.data.Constants.NEAREST_LOCATION_DISTANCE
|
||||
import com.kouros.navigation.data.Constants.SPEED_UPDATE_DISTANCE
|
||||
import com.kouros.navigation.data.Constants.TAG
|
||||
import com.kouros.navigation.utils.location
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.absoluteValue
|
||||
@@ -24,20 +25,20 @@ class RouteCalculator(var routeModel: RouteModel) {
|
||||
if (index >= routeModel.navState.route.currentStepIndex) {
|
||||
for ((wayIndex, waypoint) in step.maneuver.waypoints.withIndex()) {
|
||||
if (wayIndex >= step.waypointIndex) {
|
||||
distance = location.distanceTo(location(waypoint[0], waypoint[1]))
|
||||
distance = location.distanceTo(waypoint)
|
||||
if (distance < nearestDistance) {
|
||||
nearestDistance = distance
|
||||
routeModel.navState.route.currentStepIndex = step.index
|
||||
step.waypointIndex = wayIndex
|
||||
step.wayPointLocation = location(waypoint[0], waypoint[1])
|
||||
step.wayPointLocation = waypoint
|
||||
}
|
||||
}
|
||||
if (nearestDistance < NEAREST_LOCATION_DISTANCE && distance > NEAREST_LOCATION_DISTANCE * 10) {
|
||||
if (nearestDistance < NEAREST_LOCATION_DISTANCE && distance > NEAREST_LOCATION_DISTANCE * 5) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nearestDistance < NEAREST_LOCATION_DISTANCE && distance > NEAREST_LOCATION_DISTANCE * 10) {
|
||||
if (nearestDistance < NEAREST_LOCATION_DISTANCE && distance > NEAREST_LOCATION_DISTANCE * 5) {
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -78,7 +79,7 @@ class RouteCalculator(var routeModel: RouteModel) {
|
||||
var leftDistance = 0F
|
||||
if (step.waypointIndex < step.maneuver.waypoints.size -1) {
|
||||
leftDistance = step.maneuver.leftDistance[step.waypointIndex]
|
||||
val waypointLocation = location(step.maneuver.waypoints[step.waypointIndex][0], step.maneuver.waypoints[step.waypointIndex][1])
|
||||
val waypointLocation = step.maneuver.waypoints[step.waypointIndex]
|
||||
if (routeModel.navState.lastLocation.latitude != 0.0) {
|
||||
val locationDistance = waypointLocation.distanceTo(routeModel.navState.lastLocation)
|
||||
leftDistance -= locationDistance
|
||||
|
||||
@@ -66,11 +66,11 @@
|
||||
<string name="general">Allgemein</string>
|
||||
<string name="traffic">Verkehr anzeigen</string>
|
||||
<string name="trip_suggestion">Fahrten-Vorschläge</string>
|
||||
<string name="drive_settings">Drive settings</string>
|
||||
<string name="car_settings">Car settings</string>
|
||||
<string name="combustion">Combustion</string>
|
||||
<string name="electric">Electric</string>
|
||||
<string name="engine_type">Engine type</string>
|
||||
<string name="alternative_routes">Alternative routes</string>
|
||||
<string name="wait">Wait</string>
|
||||
<string name="drive_settings">Fahr-Einstellungen</string>
|
||||
<string name="car_settings">Fahrzeug-Einstellungen</string>
|
||||
<string name="combustion">Verbrenner</string>
|
||||
<string name="electric">Elektro</string>
|
||||
<string name="engine_type">Motortyp</string>
|
||||
<string name="alternative_routes">Alternative Routen</string>
|
||||
<string name="wait">Warten</string>
|
||||
</resources>
|
||||
|
||||
@@ -50,11 +50,11 @@
|
||||
<string name="general">Γενικά</string>
|
||||
<string name="traffic">Εμφάνιση κίνησης</string>
|
||||
<string name="trip_suggestion">Προτάσεις διαδρομής</string>
|
||||
<string name="drive_settings">Drive settings</string>
|
||||
<string name="car_settings">Car settings</string>
|
||||
<string name="combustion">Combustion</string>
|
||||
<string name="electric">Electric</string>
|
||||
<string name="engine_type">Engine type</string>
|
||||
<string name="alternative_routes">Alternative routes</string>
|
||||
<string name="wait">Wait</string>
|
||||
<string name="drive_settings">Ρυθμίσεις οδήγησης</string>
|
||||
<string name="car_settings">Ρυθμίσεις αυτοκινήτου</string>
|
||||
<string name="combustion">Κινητήρας εσωτερικής καύσης</string>
|
||||
<string name="electric">Ηλεκτρικό</string>
|
||||
<string name="engine_type">Τύπος κινητήρα</string>
|
||||
<string name="alternative_routes">Εναλλακτικές διαδρομές</string>
|
||||
<string name="wait">Περιμένετε</string>
|
||||
</resources>
|
||||
|
||||
@@ -50,11 +50,11 @@
|
||||
<string name="general">Ogólne</string>
|
||||
<string name="traffic">Pokaż natężenie ruchu</string>
|
||||
<string name="trip_suggestion">Sugestie dotyczące podróży</string>
|
||||
<string name="drive_settings">Drive settings</string>
|
||||
<string name="car_settings">Car settings</string>
|
||||
<string name="combustion">Combustion</string>
|
||||
<string name="electric">Electric</string>
|
||||
<string name="engine_type">Engine type</string>
|
||||
<string name="alternative_routes">Alternative routes</string>
|
||||
<string name="wait">Wait</string>
|
||||
<string name="drive_settings">Ustawienia jazdy</string>
|
||||
<string name="car_settings">Ustawienia samochodu</string>
|
||||
<string name="combustion">Spalinowy</string>
|
||||
<string name="electric">Elektryczny</string>
|
||||
<string name="engine_type">Typ silnika</string>
|
||||
<string name="alternative_routes">Alternatywne trasy</string>
|
||||
<string name="wait">Czekaj</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user