From 16b79b5cee013de1263eddf23b739dc14b5cdeb9 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 1 Jan 2021 14:48:52 +0100 Subject: [PATCH] Update default speed for voice router for car to take into account setting and have minimum speed --- .../net/osmand/plus/routing/RoutingHelper.java | 15 ++++++++------- .../src/net/osmand/plus/routing/VoiceRouter.java | 13 +++++-------- .../RecalculateRouteInDeviationBottomSheet.java | 3 +-- .../fragments/RouteParametersFragment.java | 3 +-- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 58cffca7f0..07482366de 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -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)); } diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 86523b6a49..996a6b825a 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -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()); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java index d3bdf98ee5..c270ea0ed8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index f7978aed47..d3d9ef2d93 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -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),