require 5 sec confirmation time before announcing "U-turn when possible" to avoid false positives
This commit is contained in:
parent
d55fce74ea
commit
9edf90b02b
1 changed files with 9 additions and 7 deletions
|
@ -71,6 +71,7 @@ public class RoutingHelper {
|
||||||
public static boolean makeUturnWhenPossible = false;
|
public static boolean makeUturnWhenPossible = false;
|
||||||
public static boolean suppressTurnPrompt = false;
|
public static boolean suppressTurnPrompt = false;
|
||||||
public static int turnImminent = 0;
|
public static int turnImminent = 0;
|
||||||
|
private long makeUTwpDetected = 0;
|
||||||
|
|
||||||
public static boolean makeUturnWhenPossible() {
|
public static boolean makeUturnWhenPossible() {
|
||||||
return makeUturnWhenPossible;
|
return makeUturnWhenPossible;
|
||||||
|
@ -382,18 +383,19 @@ public class RoutingHelper {
|
||||||
// 7. Check necessity for unscheduled U-turn, Issue 863
|
// 7. Check necessity for unscheduled U-turn, Issue 863
|
||||||
if (Math.abs(bearing - bearingRoute) > 135f && 360 - Math.abs(bearing - bearingRoute) > 135f) {
|
if (Math.abs(bearing - bearingRoute) > 135f && 360 - Math.abs(bearing - bearingRoute) > 135f) {
|
||||||
float d = currentLocation.distanceTo(routeNodes.get(currentRoute));
|
float d = currentLocation.distanceTo(routeNodes.get(currentRoute));
|
||||||
// tolerance 60m or 6sec. Time tolerance to avoid false positives after route recalculation in motion
|
// 60m tolerance to allow for GPS inaccuracy
|
||||||
if (currentLocation.hasSpeed()) {
|
if (d > 60) {
|
||||||
if ((d > 60) && (d > (currentLocation.getSpeed() * 6f))) {
|
if (makeUTwpDetected == 0) {
|
||||||
|
makeUTwpDetected = System.currentTimeMillis();
|
||||||
|
// require 5 sec since first detection, to avoid false positive announcements
|
||||||
|
} else if ((System.currentTimeMillis() - makeUTwpDetected > 5000)) {
|
||||||
makeUturnWhenPossible = true;
|
makeUturnWhenPossible = true;
|
||||||
turnImminent = 1;
|
turnImminent = 1;
|
||||||
//log.info("Bearing is opposite to bearingRoute"); //$NON-NLS-1$
|
//log.info("Bearing is opposite to bearingRoute"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
} else if (d > 60) {
|
|
||||||
makeUturnWhenPossible = true;
|
|
||||||
turnImminent = 1;
|
|
||||||
//log.info("Bearing is opposite to bearingRoute"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
makeUTwpDetected = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue