Remove profile based constants use speed to replicate their values cause speed could be configured - #8749
This commit is contained in:
parent
e196b322a6
commit
713b86d2fb
4 changed files with 22 additions and 37 deletions
|
@ -505,7 +505,7 @@ public class BinaryMapIndexReader {
|
||||||
finishInit.add(transportRoute);
|
finishInit.add(transportRoute);
|
||||||
}
|
}
|
||||||
TIntObjectHashMap<String> indexedStringTable = transportAdapter.initializeStringTable(ind, stringTable);
|
TIntObjectHashMap<String> indexedStringTable = transportAdapter.initializeStringTable(ind, stringTable);
|
||||||
for(TransportRoute transportRoute : finishInit ) {
|
for (TransportRoute transportRoute : finishInit) {
|
||||||
transportAdapter.initializeNames(false, transportRoute, indexedStringTable);
|
transportAdapter.initializeNames(false, transportRoute, indexedStringTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,9 +65,6 @@ public class ApplicationMode {
|
||||||
private ApplicationMode parentAppMode;
|
private ApplicationMode parentAppMode;
|
||||||
private int iconRes = R.drawable.ic_world_globe_dark;
|
private int iconRes = R.drawable.ic_world_globe_dark;
|
||||||
|
|
||||||
private int minDistanceForTurn = 50;
|
|
||||||
private int offRouteDistance = 350;
|
|
||||||
|
|
||||||
private ApplicationMode(int key, String stringKey) {
|
private ApplicationMode(int key, String stringKey) {
|
||||||
this.keyName = key;
|
this.keyName = key;
|
||||||
this.stringKey = stringKey;
|
this.stringKey = stringKey;
|
||||||
|
@ -77,21 +74,18 @@ public class ApplicationMode {
|
||||||
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); NAUTICAL("boat"); PUBLIC_TRANSPORT("Public transport"); AIRCRAFT("Aircraft")
|
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); NAUTICAL("boat"); PUBLIC_TRANSPORT("Public transport"); AIRCRAFT("Aircraft")
|
||||||
*/
|
*/
|
||||||
public static final ApplicationMode DEFAULT = createBase(R.string.app_mode_default, "default")
|
public static final ApplicationMode DEFAULT = createBase(R.string.app_mode_default, "default")
|
||||||
.distanceForTurn(5).offRouteDistance(350)
|
|
||||||
.icon(R.drawable.ic_world_globe_dark).reg();
|
.icon(R.drawable.ic_world_globe_dark).reg();
|
||||||
|
|
||||||
|
|
||||||
public static final ApplicationMode CAR = createBase(R.string.app_mode_car, "car")
|
public static final ApplicationMode CAR = createBase(R.string.app_mode_car, "car")
|
||||||
.distanceForTurn(35).offRouteDistance(350)
|
|
||||||
.icon(R.drawable.ic_action_car_dark)
|
.icon(R.drawable.ic_action_car_dark)
|
||||||
.description(R.string.base_profile_descr_car).reg();
|
.description(R.string.base_profile_descr_car).reg();
|
||||||
|
|
||||||
public static final ApplicationMode BICYCLE = createBase(R.string.app_mode_bicycle, "bicycle")
|
public static final ApplicationMode BICYCLE = createBase(R.string.app_mode_bicycle, "bicycle")
|
||||||
.distanceForTurn(15).offRouteDistance(50)
|
|
||||||
.icon(R.drawable.ic_action_bicycle_dark)
|
.icon(R.drawable.ic_action_bicycle_dark)
|
||||||
.description(R.string.base_profile_descr_bicycle).reg();
|
.description(R.string.base_profile_descr_bicycle).reg();
|
||||||
|
|
||||||
public static final ApplicationMode PEDESTRIAN = createBase(R.string.app_mode_pedestrian, "pedestrian")
|
public static final ApplicationMode PEDESTRIAN = createBase(R.string.app_mode_pedestrian, "pedestrian")
|
||||||
.distanceForTurn(5).offRouteDistance(20)
|
|
||||||
.icon(R.drawable.ic_action_pedestrian_dark)
|
.icon(R.drawable.ic_action_pedestrian_dark)
|
||||||
.description(R.string.base_profile_descr_pedestrian).reg();
|
.description(R.string.base_profile_descr_pedestrian).reg();
|
||||||
|
|
||||||
|
@ -100,17 +94,14 @@ public class ApplicationMode {
|
||||||
.description(R.string.base_profile_descr_public_transport).reg();
|
.description(R.string.base_profile_descr_public_transport).reg();
|
||||||
|
|
||||||
public static final ApplicationMode BOAT = createBase(R.string.app_mode_boat, "boat")
|
public static final ApplicationMode BOAT = createBase(R.string.app_mode_boat, "boat")
|
||||||
.distanceForTurn(20)
|
|
||||||
.icon(R.drawable.ic_action_sail_boat_dark)
|
.icon(R.drawable.ic_action_sail_boat_dark)
|
||||||
.description(R.string.base_profile_descr_boat).reg();
|
.description(R.string.base_profile_descr_boat).reg();
|
||||||
|
|
||||||
public static final ApplicationMode AIRCRAFT = createBase(R.string.app_mode_aircraft, "aircraft")
|
public static final ApplicationMode AIRCRAFT = createBase(R.string.app_mode_aircraft, "aircraft")
|
||||||
.distanceForTurn(100)
|
|
||||||
.icon(R.drawable.ic_action_aircraft)
|
.icon(R.drawable.ic_action_aircraft)
|
||||||
.description(R.string.base_profile_descr_aircraft).reg();
|
.description(R.string.base_profile_descr_aircraft).reg();
|
||||||
|
|
||||||
public static final ApplicationMode SKI = createBase(R.string.app_mode_skiing, "ski")
|
public static final ApplicationMode SKI = createBase(R.string.app_mode_skiing, "ski")
|
||||||
.distanceForTurn(15).offRouteDistance(50)
|
|
||||||
.icon(R.drawable.ic_action_skiing)
|
.icon(R.drawable.ic_action_skiing)
|
||||||
.description(R.string.base_profile_descr_ski).reg();
|
.description(R.string.base_profile_descr_ski).reg();
|
||||||
|
|
||||||
|
@ -313,8 +304,6 @@ public class ApplicationMode {
|
||||||
public void setParentAppMode(ApplicationMode parentAppMode) {
|
public void setParentAppMode(ApplicationMode parentAppMode) {
|
||||||
if (isCustomProfile()) {
|
if (isCustomProfile()) {
|
||||||
this.parentAppMode = parentAppMode;
|
this.parentAppMode = parentAppMode;
|
||||||
minDistanceForTurn = parentAppMode.minDistanceForTurn;
|
|
||||||
offRouteDistance = parentAppMode.offRouteDistance;
|
|
||||||
app.getSettings().PARENT_APP_MODE.setModeValue(this, parentAppMode.getStringKey());
|
app.getSettings().PARENT_APP_MODE.setModeValue(this, parentAppMode.getStringKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,12 +356,18 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinDistanceForTurn() {
|
public int getMinDistanceForTurn() {
|
||||||
return minDistanceForTurn;
|
// used to be: 50 kmh - 35 m, 10 kmh - 15 m, 4 kmh - 5 m, 10 kmh - 20 m, 400 kmh - 100 m,
|
||||||
|
float speed = Math.max(getDefaultSpeed(), 0.3f);
|
||||||
|
// 2 sec + 7 m: 50 kmh - 35 m, 10 kmh - 12 m, 4 kmh - 9 m, 400 kmh - 230 m
|
||||||
|
return (int) (7 + speed * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getOffRouteDistance() {
|
public int getOffRouteDistance() {
|
||||||
return offRouteDistance;
|
// used to be: 50/14 - 350 m, 10/2.7 - 50 m, 4/1.11 - 20 m
|
||||||
|
float speed = Math.max(getDefaultSpeed(), 0.3f);
|
||||||
|
// become: 50 kmh - 280 m, 10 kmh - 55 m, 4 kmh - 22 m
|
||||||
|
return (int) (speed * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFastSpeed() {
|
public boolean hasFastSpeed() {
|
||||||
|
@ -699,9 +694,6 @@ public class ApplicationMode {
|
||||||
values.add(applicationMode);
|
values.add(applicationMode);
|
||||||
|
|
||||||
ApplicationMode parent = applicationMode.parentAppMode;
|
ApplicationMode parent = applicationMode.parentAppMode;
|
||||||
applicationMode.minDistanceForTurn = parent.minDistanceForTurn;
|
|
||||||
applicationMode.offRouteDistance = parent.offRouteDistance;
|
|
||||||
|
|
||||||
applicationMode.setParentAppMode(parent);
|
applicationMode.setParentAppMode(parent);
|
||||||
applicationMode.setUserProfileName(userProfileName);
|
applicationMode.setUserProfileName(userProfileName);
|
||||||
applicationMode.setRouteService(routeService);
|
applicationMode.setRouteService(routeService);
|
||||||
|
@ -730,16 +722,6 @@ public class ApplicationMode {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder distanceForTurn(int distForTurn) {
|
|
||||||
applicationMode.minDistanceForTurn = distForTurn;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationModeBuilder offRouteDistance(int offRouteDistance) {
|
|
||||||
applicationMode.offRouteDistance = offRouteDistance;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationModeBuilder setUserProfileName(String userProfileName) {
|
public ApplicationModeBuilder setUserProfileName(String userProfileName) {
|
||||||
this.userProfileName = userProfileName;
|
this.userProfileName = userProfileName;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -46,7 +46,9 @@ public class RoutingHelper {
|
||||||
public static final float ALLOWED_DEVIATION = 2;
|
public static final float ALLOWED_DEVIATION = 2;
|
||||||
|
|
||||||
// This should be correlated with RoutingHelper.updateCurrentRouteStatus ( when processed turn now is not announced)
|
// This should be correlated with RoutingHelper.updateCurrentRouteStatus ( when processed turn now is not announced)
|
||||||
public static int GPS_TOLERANCE = 12;
|
private static int DEFAULT_GPS_TOLERANCE = 12;
|
||||||
|
public static int GPS_TOLERANCE = DEFAULT_GPS_TOLERANCE;
|
||||||
|
public static float ARRIVAL_DISTANCE_FACTOR = 1;
|
||||||
|
|
||||||
private List<WeakReference<IRouteInformationListener>> listeners = new LinkedList<>();
|
private List<WeakReference<IRouteInformationListener>> listeners = new LinkedList<>();
|
||||||
private List<WeakReference<IRoutingDataUpdateListener>> updateListeners = new LinkedList<>();
|
private List<WeakReference<IRoutingDataUpdateListener>> updateListeners = new LinkedList<>();
|
||||||
|
@ -263,6 +265,8 @@ public class RoutingHelper {
|
||||||
|
|
||||||
public void setAppMode(ApplicationMode mode){
|
public void setAppMode(ApplicationMode mode){
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
ARRIVAL_DISTANCE_FACTOR = Math.max(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(mode), 0.1f);
|
||||||
|
GPS_TOLERANCE = (int) (DEFAULT_GPS_TOLERANCE * ARRIVAL_DISTANCE_FACTOR);
|
||||||
voiceRouter.updateAppMode();
|
voiceRouter.updateAppMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +489,7 @@ public class RoutingHelper {
|
||||||
voiceRouter.interruptRouteCommands();
|
voiceRouter.interruptRouteCommands();
|
||||||
voiceRouterStopped = true; // Prevents excessive execution of stop() code
|
voiceRouterStopped = true; // Prevents excessive execution of stop() code
|
||||||
}
|
}
|
||||||
if (distOrth > mode.getOffRouteDistance() && !settings.DISABLE_OFFROUTE_RECALC.get()) {
|
if (distOrth > mode.getOffRouteDistance() * ARRIVAL_DISTANCE_FACTOR && !settings.DISABLE_OFFROUTE_RECALC.get()) {
|
||||||
voiceRouter.announceOffRoute(distOrth);
|
voiceRouter.announceOffRoute(distOrth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -583,8 +587,8 @@ public class RoutingHelper {
|
||||||
}
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
} else if (newDist < dist || newDist < 10) {
|
} else if (newDist < dist || newDist < GPS_TOLERANCE / 2) {
|
||||||
// newDist < 10 (avoid distance 0 till next turn)
|
// newDist < GPS_TOLERANCE (avoid distance 0 till next turn)
|
||||||
if (dist > posTolerance) {
|
if (dist > posTolerance) {
|
||||||
processed = true;
|
processed = true;
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
@ -739,7 +743,7 @@ public class RoutingHelper {
|
||||||
// return ((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(m);
|
// return ((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(m);
|
||||||
// GPS_TOLERANCE - 12 m
|
// GPS_TOLERANCE - 12 m
|
||||||
// 5 seconds: car - 80 m @ 50 kmh, bicyle - 45 m @ 25 km/h, bicyle - 25 m @ 10 km/h, pedestrian - 18 m @ 4 km/h,
|
// 5 seconds: car - 80 m @ 50 kmh, bicyle - 45 m @ 25 km/h, bicyle - 25 m @ 10 km/h, pedestrian - 18 m @ 4 km/h,
|
||||||
return (float) (GPS_TOLERANCE + defaultSpeed * 5) * settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(m);
|
return GPS_TOLERANCE + defaultSpeed * 5 * ARRIVAL_DISTANCE_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -190,16 +190,15 @@ public class VoiceRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn now: 3.5 sec normal speed, 7 second for halfspeed (default)
|
// Turn now: 3.5 sec normal speed, 7 second for halfspeed (default)
|
||||||
float TURN_NOW_TIME = 7;
|
// float TURN_NOW_TIME = 7;
|
||||||
|
|
||||||
// ** #8749 to keep 1m / 1 sec precision (GPS_TOLERANCE - 12 m)
|
// ** #8749 to keep 1m / 1 sec precision (GPS_TOLERANCE - 12 m)
|
||||||
// 1 kmh - 1 m, 4 kmh - 4 m (pedestrian), 10 kmh - 10 m (bicycle), 50 kmh - 50 m (car)
|
// 1 kmh - 1 m, 4 kmh - 4 m (pedestrian), 10 kmh - 10 m (bicycle), 50 kmh - 50 m (car)
|
||||||
// TURN_NOW_DISTANCE = (int) (DEFAULT_SPEED * 3.6); // 3.6 sec
|
// 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
|
// 50 kmh - 48 m (car), 10 kmh - 20 m, 4 kmh - 15 m, 1 kmh - 12 m
|
||||||
float factor = settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(appMode);
|
TURN_NOW_DISTANCE = (int) (RoutingHelper.GPS_TOLERANCE + DEFAULT_SPEED * 2.5 * RoutingHelper.ARRIVAL_DISTANCE_FACTOR); // 3.6 sec
|
||||||
TURN_NOW_DISTANCE = (int) ((RoutingHelper.GPS_TOLERANCE + DEFAULT_SPEED * 2.5) * factor); // 3.6 sec
|
|
||||||
// 1 kmh - 1 sec, 4 kmh - 2 sec (pedestrian), 10 kmh - 3 sec (*bicycle), 50 kmh - 7 sec (car)
|
// 1 kmh - 1 sec, 4 kmh - 2 sec (pedestrian), 10 kmh - 3 sec (*bicycle), 50 kmh - 7 sec (car)
|
||||||
TURN_NOW_TIME = (float) Math.min(Math.sqrt(DEFAULT_SPEED * 3.6), 8);
|
float TURN_NOW_TIME = (float) Math.min(Math.sqrt(DEFAULT_SPEED * 3.6), 8);
|
||||||
|
|
||||||
TURN_NOW_SPEED = TURN_NOW_DISTANCE / TURN_NOW_TIME;
|
TURN_NOW_SPEED = TURN_NOW_DISTANCE / TURN_NOW_TIME;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue