trigger route re-calculation also based on new directionDetection (Under some conditions route was not recalculated for very long times)
This commit is contained in:
parent
b8f6a443d8
commit
de62324e82
1 changed files with 11 additions and 4 deletions
|
@ -225,6 +225,7 @@ public class RoutingHelper {
|
||||||
|
|
||||||
boolean calculateRoute = false;
|
boolean calculateRoute = false;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
// 0. Route empty or needs to be extended? Then re-calculate route.
|
||||||
if(routeNodes.isEmpty() || routeNodes.size() <= currentRoute){
|
if(routeNodes.isEmpty() || routeNodes.size() <= currentRoute){
|
||||||
calculateRoute = true;
|
calculateRoute = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,7 +264,7 @@ public class RoutingHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. evaluate distance to the route and reevaluate if needed
|
// 4. >50m away from current routeNode? Then re-calculate route.
|
||||||
if(currentRoute > 0){
|
if(currentRoute > 0){
|
||||||
float bearing = routeNodes.get(currentRoute - 1).bearingTo(routeNodes.get(currentRoute));
|
float bearing = routeNodes.get(currentRoute - 1).bearingTo(routeNodes.get(currentRoute));
|
||||||
float bearingMovement = currentLocation.bearingTo(routeNodes.get(currentRoute));
|
float bearingMovement = currentLocation.bearingTo(routeNodes.get(currentRoute));
|
||||||
|
@ -274,12 +275,12 @@ public class RoutingHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. also check bearing by summing distance
|
// 5. Sum distance to last and current route nodes
|
||||||
if(!calculateRoute){
|
if(!calculateRoute){
|
||||||
float d = currentLocation.distanceTo(routeNodes.get(currentRoute));
|
float d = currentLocation.distanceTo(routeNodes.get(currentRoute));
|
||||||
if (d > 80) {
|
if (d > 80) {
|
||||||
if (currentRoute > 0) {
|
if (currentRoute > 0) {
|
||||||
// possibly that case is not needed (often it is covered by 4.)
|
// 5a. Greater than 2*distance between them? Then re-calculate route. (Case often covered by 4., but still needed.)
|
||||||
float f1 = currentLocation.distanceTo(routeNodes.get(currentRoute - 1)) + d;
|
float f1 = currentLocation.distanceTo(routeNodes.get(currentRoute - 1)) + d;
|
||||||
float c = routeNodes.get(currentRoute - 1).distanceTo(routeNodes.get(currentRoute));
|
float c = routeNodes.get(currentRoute - 1).distanceTo(routeNodes.get(currentRoute));
|
||||||
if (c * 2 < d + f1) {
|
if (c * 2 < d + f1) {
|
||||||
|
@ -287,7 +288,7 @@ public class RoutingHelper {
|
||||||
calculateRoute = true;
|
calculateRoute = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// that case is needed
|
// 5b. Too far from route start? Then re-calculate route.
|
||||||
log.info("Recalculate route, because too far from start : " + d); //$NON-NLS-1$
|
log.info("Recalculate route, because too far from start : " + d); //$NON-NLS-1$
|
||||||
calculateRoute = true;
|
calculateRoute = true;
|
||||||
}
|
}
|
||||||
|
@ -303,6 +304,12 @@ public class RoutingHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastFixedLocation = currentLocation;
|
lastFixedLocation = currentLocation;
|
||||||
|
|
||||||
|
// 8. Strange Direction? Then re-calculate route. (Added new, may possibly even replace triggers 4, 5a, 5b ?)
|
||||||
|
if(suppressTurnPrompt){
|
||||||
|
calculateRoute = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(calculateRoute){
|
if(calculateRoute){
|
||||||
recalculateRouteInBackground(lastFixedLocation, finalLocation, currentGPXRoute);
|
recalculateRouteInBackground(lastFixedLocation, finalLocation, currentGPXRoute);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue