diff --git a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java index 1b6586ed8e..7f79ce539b 100644 --- a/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java +++ b/OsmAnd/src/net/osmand/plus/routing/data/AnnounceTimeDistances.java @@ -16,11 +16,12 @@ public class AnnounceTimeDistances { public final static int STATE_LONG_ALARM_ANNOUNCE = 6; public final static int STATE_SHORT_ALARM_ANNOUNCE = 7; + public final static int STATE_ARRIVAL_DISTANCE = 10; + public final static int STATE_OFF_ROUTE_DISTANCE = 11; // Default speed to have comfortable announcements (Speed in m/s) // initial value is updated from default speed settings anyway private float DEFAULT_SPEED = 10; - private float ARRIVAL_DISTANCE_FACTOR = 1; private double voicePromptDelayTimeSec = 0; private float ARRIVAL_DISTANCE; @@ -29,17 +30,15 @@ public class AnnounceTimeDistances { private float TURN_NOW_SPEED; private int PREPARE_LONG_DISTANCE; private int PREPARE_LONG_DISTANCE_END; - protected int PREPARE_DISTANCE; + private int PREPARE_DISTANCE; private int PREPARE_DISTANCE_END; private int TURN_IN_DISTANCE; private int TURN_IN_DISTANCE_END; private int TURN_NOW_DISTANCE; - - // TODO - private static final int LONG_PNT_ANNOUNCE_RADIUS = 700; - private static final int SHORT_PNT_ANNOUNCE_RADIUS = 150; - private static final int LONG_ALARM_ANNOUNCE_RADIUS = 150; - private static final int SHORT_ALARM_ANNOUNCE_RADIUS = 100; + private int LONG_PNT_ANNOUNCE_RADIUS; + private int SHORT_PNT_ANNOUNCE_RADIUS; + private int LONG_ALARM_ANNOUNCE_RADIUS; + private int SHORT_ALARM_ANNOUNCE_RADIUS; public AnnounceTimeDistances(ApplicationMode appMode, OsmandSettings settings) { if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) { @@ -85,16 +84,22 @@ public class AnnounceTimeDistances { // 1 kmh - 1 sec, 4 kmh - 2 sec (pedestrian), 10 kmh - 3 sec (*bicycle), 50 kmh - 7 sec (car) float TURN_NOW_TIME = (float) Math.min(Math.sqrt(DEFAULT_SPEED * 3.6), 8); - // test new: 50 kmh - 50 m (car), 10 kmh - 10 m (bike), 4 kmh - 4 m - // TURN_NOW_DISTANCE = (int) (TURN_NOW_TIME * DEFAULT_SPEED / 2); - // old value - // 1 kmh - 1 m, 4 kmh - 4 m (pedestrian), 10 kmh - 10 m (bicycle), 50 kmh - 50 m (car) + float ARRIVAL_DISTANCE_FACTOR = Math.max(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(appMode), 0.1f); // TURN_NOW_DISTANCE = (int) (DEFAULT_SPEED * 3.6); // 3.6 sec // 50 kmh - 48 m (car), 10 kmh - 20 m, 4 kmh - 15 m, 1 kmh - 12 m - float factor = Math.max(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(appMode), 0.1f); - TURN_NOW_DISTANCE = (int) ((DEFAULT_GPS_TOLERANCE + DEFAULT_SPEED * 2.5) * factor); // 3.6 sec + TURN_NOW_DISTANCE = (int) ((DEFAULT_GPS_TOLERANCE + DEFAULT_SPEED * 2.5) * ARRIVAL_DISTANCE_FACTOR); // 3.6 sec TURN_NOW_SPEED = TURN_NOW_DISTANCE / TURN_NOW_TIME; + // 5 seconds: car - 80 m @ 50 kmh, bicycle - 45 m @ 25 km/h, bicycle - 25 m @ 10 km/h, pedestrian - 18 m @ 4 km/h, + ARRIVAL_DISTANCE = (DEFAULT_GPS_TOLERANCE + DEFAULT_SPEED * 5) * ARRIVAL_DISTANCE_FACTOR; + // 50 kmh - 280 m, 10 kmh - 55 m, 4 kmh - 22 m + OFF_ROUTE_DISTANCE = DEFAULT_SPEED * 20 * ARRIVAL_DISTANCE_FACTOR; // 20 seconds + // assume for backward compatibility speed - 10 m/s + LONG_PNT_ANNOUNCE_RADIUS = (int) (60 * DEFAULT_SPEED * ARRIVAL_DISTANCE_FACTOR); // 700m + SHORT_PNT_ANNOUNCE_RADIUS = (int) (15 * DEFAULT_SPEED * ARRIVAL_DISTANCE_FACTOR); // 150m + LONG_ALARM_ANNOUNCE_RADIUS = (int) (12 * DEFAULT_SPEED * ARRIVAL_DISTANCE_FACTOR); // 150m + SHORT_ALARM_ANNOUNCE_RADIUS = (int) (7 * DEFAULT_SPEED * ARRIVAL_DISTANCE_FACTOR); // 100m + // Trigger close prompts earlier to allow BT SCO link being established, or when VOICE_PROMPT_DELAY is set >0 for the other stream types int ams = settings.AUDIO_MANAGER_STREAM.getModeValue(appMode); if ((ams == 0 && !AbstractPrologCommandPlayer.btScoStatus) || ams > 0) { @@ -102,13 +107,6 @@ public class AnnounceTimeDistances { voicePromptDelayTimeSec = (double) settings.VOICE_PROMPT_DELAY[ams].get() / 1000; } } - - // 5 seconds: car - 80 m @ 50 kmh, bicycle - 45 m @ 25 km/h, bicycle - 25 m @ 10 km/h, pedestrian - 18 m @ 4 km/h, - ARRIVAL_DISTANCE_FACTOR = Math.max(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(appMode), 0.1f); - ARRIVAL_DISTANCE = (DEFAULT_GPS_TOLERANCE + DEFAULT_SPEED * 5) * ARRIVAL_DISTANCE_FACTOR; - - // 50 kmh - 280 m, 10 kmh - 55 m, 4 kmh - 22 m - OFF_ROUTE_DISTANCE = DEFAULT_SPEED * 20 * ARRIVAL_DISTANCE_FACTOR; // 20 seconds } public int getImminentTurnStatus(float dist, Location loc) { @@ -155,6 +153,8 @@ public class AnnounceTimeDistances { return !isDistanceLess(currentSpeed, dist, PREPARE_LONG_DISTANCE_END); case STATE_LONG_PNT_ANNOUNCE: return !isDistanceLess(currentSpeed, dist, LONG_PNT_ANNOUNCE_RADIUS * 0.5); + case STATE_LONG_ALARM_ANNOUNCE: + return !isDistanceLess(currentSpeed, dist, LONG_ALARM_ANNOUNCE_RADIUS * 0.5); } return true; }