Update default speed for voice router for car to take into account setting and have minimum speed

This commit is contained in:
Victor Shcherb 2021-01-01 14:48:52 +01:00
parent c29ed71fc6
commit 16b79b5cee
4 changed files with 15 additions and 19 deletions

View file

@ -43,12 +43,13 @@ public class RoutingHelper {
private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(RoutingHelper.class);
// Used to 1) calculate current closest segment of the route during navigation
// 2) calculate max allowed deviation before route recalculation
private static final float POSITION_TOLERANCE = 60;
// POS_TOLERANCE
// 1) calculate current closest segment of the route during navigation
// 2) identify u-turn, projected distance
// 3) calculate max allowed deviation before route recalculation * multiplier
private static final float POS_TOLERANCE = 60; // 60m or 30m + accuracy
private static final float POS_TOLERANCE_DEVIATION_MULTIPLIER = 2;
// This should be correlated with RoutingHelper.updateCurrentRouteStatus ( when processed turn now is not announced)
private static final int DEFAULT_GPS_TOLERANCE = 12;
// TODO make private
@ -682,9 +683,9 @@ public class RoutingHelper {
private static float getPosTolerance(float accuracy) {
if (accuracy > 0) {
return POSITION_TOLERANCE / 2 + accuracy;
return POS_TOLERANCE / 2 + accuracy;
}
return POSITION_TOLERANCE;
return POS_TOLERANCE;
}
private static float getDefaultAllowedDeviation(OsmandSettings settings, ApplicationMode mode, float posTolerance) {
@ -704,7 +705,7 @@ public class RoutingHelper {
return posTolerance * POS_TOLERANCE_DEVIATION_MULTIPLIER;
}
public static float getDefaultAllowedDeviationAccuracy(OsmandSettings settings, ApplicationMode mode) {
public static float getDefaultAllowedDeviation(OsmandSettings settings, ApplicationMode mode) {
return getDefaultAllowedDeviation(settings, mode, getPosTolerance(0));
}

View file

@ -72,7 +72,9 @@ public class VoiceRouter {
private long lastAnnouncement = 0;
// Default speed to have comfortable announcements (Speed in m/s)
private float DEFAULT_SPEED = 12;
// initial value is updated from default speed settings anyway
private float DEFAULT_SPEED = 10;
// TODO review turn now speed
private float TURN_NOW_SPEED;
private int PREPARE_LONG_DISTANCE;
@ -181,13 +183,8 @@ public class VoiceRouter {
public void updateAppMode() {
ApplicationMode appMode = router.getAppMode() == null ? settings.getApplicationMode() : router.getAppMode();
if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
// could be changed in future as others by default in settings is 45 kmh
DEFAULT_SPEED = 14; // ~50 km/h
//DEFAULT speed is configurable
// } else if (router.getAppMode().isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
// DEFAULT_SPEED = 2.77f; // 10 km/h
// } else if (router.getAppMode().isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
// DEFAULT_SPEED = 1.11f; //4 km/h 2f; // 7,2 km/h
// keep it as minimum 30 kmh for voice announcement
DEFAULT_SPEED = (float) Math.max(8, appMode.getDefaultSpeed());
} else {
// minimal is 1 meter for turn now
DEFAULT_SPEED = (float) Math.max(0.3, appMode.getDefaultSpeed());

View file

@ -16,7 +16,6 @@ import com.google.android.material.slider.Slider;
import net.osmand.AndroidUtils;
import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelperUtils;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
@ -208,7 +207,7 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot
}
private void getDefaultValue() {
currentValue = RoutingHelper.getDefaultAllowedDeviationAccuracy(settings, appMode);
currentValue = RoutingHelper.getDefaultAllowedDeviation(settings, appMode);
}
private int findIndexOfValue(float allowedValue) {

View file

@ -33,7 +33,6 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version;
import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelperUtils;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.BooleanPreference;
import net.osmand.plus.settings.backend.CommonPreference;
@ -479,7 +478,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
float allowedValue = settings.ROUTE_RECALCULATION_DISTANCE.getModeValue(appMode);
boolean enabled = allowedValue != DISABLE_MODE;
if (allowedValue <= 0) {
allowedValue = RoutingHelper.getDefaultAllowedDeviationAccuracy(settings, appMode);
allowedValue = RoutingHelper.getDefaultAllowedDeviation(settings, appMode);
}
String summary = String.format(getString(R.string.ltr_or_rtl_combine_via_bold_point),
enabled ? getString(R.string.shared_string_enabled) : getString(R.string.shared_string_disabled),