This commit is contained in:
Chumva 2019-10-24 17:02:02 +03:00
parent 2a8ca3e519
commit 9d2e28e901
2 changed files with 7 additions and 8 deletions

View file

@ -170,11 +170,11 @@ public class WaypointHelper {
return found; return found;
} }
public AlarmInfo getMostImportantAlarm(MetricsConstants mc, OsmandSettings.SpeedConstants sc, boolean showCameras) { public AlarmInfo getMostImportantAlarm(OsmandSettings.SpeedConstants sc, boolean showCameras) {
Location lastProjection = app.getRoutingHelper().getLastProjection(); Location lastProjection = app.getRoutingHelper().getLastProjection();
float mxspeed = route.getCurrentMaxSpeed(); float mxspeed = route.getCurrentMaxSpeed();
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f; float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f;
AlarmInfo speedAlarm = createSpeedAlarm(mc, sc, mxspeed, lastProjection, delta); AlarmInfo speedAlarm = createSpeedAlarm(sc, mxspeed, lastProjection, delta);
if (speedAlarm != null) { if (speedAlarm != null) {
getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), lastProjection.getSpeed()); getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), lastProjection.getSpeed());
} }
@ -271,7 +271,7 @@ public class WaypointHelper {
OsmandSettings.SpeedConstants sc, boolean showCameras) { OsmandSettings.SpeedConstants sc, boolean showCameras) {
float mxspeed = ro.getMaximumSpeed(ro.bearingVsRouteDirection(loc)); float mxspeed = ro.getMaximumSpeed(ro.bearingVsRouteDirection(loc));
float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f; float delta = app.getSettings().SPEED_LIMIT_EXCEED.get() / 3.6f;
AlarmInfo speedAlarm = createSpeedAlarm(mc, sc, mxspeed, loc, delta); AlarmInfo speedAlarm = createSpeedAlarm(sc, mxspeed, loc, delta);
if (speedAlarm != null) { if (speedAlarm != null) {
getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), loc.getSpeed()); getVoiceRouter().announceSpeedAlarm(speedAlarm.getIntValue(), loc.getSpeed());
return speedAlarm; return speedAlarm;
@ -308,15 +308,15 @@ public class WaypointHelper {
return null; return null;
} }
private static AlarmInfo createSpeedAlarm(MetricsConstants mc, OsmandSettings.SpeedConstants sc, float mxspeed, Location loc, float delta) { private static AlarmInfo createSpeedAlarm(OsmandSettings.SpeedConstants sc, float mxspeed, Location loc, float delta) {
AlarmInfo speedAlarm = null; AlarmInfo speedAlarm = null;
if (mxspeed != 0 && loc != null && loc.hasSpeed() && mxspeed != RouteDataObject.NONE_MAX_SPEED) { if (mxspeed != 0 && loc != null && loc.hasSpeed() && mxspeed != RouteDataObject.NONE_MAX_SPEED) {
if (loc.getSpeed() > mxspeed + delta) { if (loc.getSpeed() > mxspeed + delta) {
int speed; int speed;
if (sc.imperial) { if (sc.imperial) {
speed = Math.round(mxspeed * 3.6f);
} else {
speed = Math.round(mxspeed * 3.6f / 1.6f); speed = Math.round(mxspeed * 3.6f / 1.6f);
} else {
speed = Math.round(mxspeed * 3.6f);
} }
speedAlarm = AlarmInfo.createSpeedLimit(speed, loc); speedAlarm = AlarmInfo.createSpeedLimit(speed, loc);
} }

View file

@ -1258,8 +1258,7 @@ public class RouteInfoWidgetsFactory {
&& showRoutingAlarms && (trafficWarnings || cams)) { && showRoutingAlarms && (trafficWarnings || cams)) {
AlarmInfo alarm; AlarmInfo alarm;
if(rh.isFollowingMode() && !rh.isDeviatedFromRoute() && rh.getCurrentGPXRoute() == null) { if(rh.isFollowingMode() && !rh.isDeviatedFromRoute() && rh.getCurrentGPXRoute() == null) {
alarm = wh.getMostImportantAlarm(settings.METRIC_SYSTEM.get(), alarm = wh.getMostImportantAlarm(settings.SPEED_SYSTEM.get(), cams);
settings.SPEED_SYSTEM.get(), cams);
} else { } else {
RouteDataObject ro = locationProvider.getLastKnownRouteSegment(); RouteDataObject ro = locationProvider.getLastKnownRouteSegment();
Location loc = locationProvider.getLastKnownLocation(); Location loc = locationProvider.getLastKnownLocation();