diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index 3da9866b7b..d9c45d4994 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -183,15 +183,15 @@ public class WaypointHelper { int kIterator = pointsProgress.get(ALARMS); List lp = locationPoints.get(ALARMS); while (kIterator < lp.size()) { - LocationPointWrapper lwp = lp.get(kIterator); - if (lp.get(kIterator).routeIndex < route.getCurrentRoute()) { + AlarmInfo inf = (AlarmInfo) lp.get(kIterator).point; + if (inf.getLocationIndex() < route.getCurrentRoute() && inf.getLastLocationIndex() != -1 + && inf.getLastLocationIndex() < route.getCurrentRoute()) { // skip } else { - int d = route.getDistanceToPoint(lwp.routeIndex); + int d = route.getDistanceToPoint(inf.getLocationIndex()); if (d > LONG_ANNOUNCE_RADIUS) { break; } - AlarmInfo inf = (AlarmInfo) lwp.point; float time = speed > 0 ? d / speed : Integer.MAX_VALUE; int vl = inf.updateDistanceAndGetPriority(time, d); if (vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)) { @@ -325,11 +325,21 @@ public class WaypointHelper { if (lp != null) { int kIterator = pointsProgress.get(type); while (kIterator < lp.size() && lp.get(kIterator).routeIndex < currentRoute) { + if (type == ALARMS) { + AlarmInfo alarm = (AlarmInfo) lp.get(kIterator).getPoint(); + if (alarm.getLastLocationIndex() >= currentRoute) { + break; + } + } kIterator++; } pointsProgress.set(type, kIterator); while (kIterator < lp.size()) { LocationPointWrapper lwp = lp.get(kIterator); + if (type == ALARMS && lwp.routeIndex < currentRoute) { + kIterator++; + continue; + } if (lwp.announce) { if (route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS * 2) { break; diff --git a/OsmAnd/src/net/osmand/plus/routing/AlarmInfo.java b/OsmAnd/src/net/osmand/plus/routing/AlarmInfo.java index bd3846c418..126e6287c5 100644 --- a/OsmAnd/src/net/osmand/plus/routing/AlarmInfo.java +++ b/OsmAnd/src/net/osmand/plus/routing/AlarmInfo.java @@ -41,6 +41,7 @@ public class AlarmInfo implements LocationPoint { private AlarmInfoType type; protected final int locationIndex; + private int lastLocationIndex = -1; private int intValue; private float floatValue; private double latitude; @@ -81,11 +82,19 @@ public class AlarmInfo implements LocationPoint { public int getLocationIndex() { return locationIndex; } - + + public int getLastLocationIndex() { + return lastLocationIndex; + } + + public void setLastLocationIndex(int lastLocationIndex) { + this.lastLocationIndex = lastLocationIndex; + } + public void setIntValue(int intValue) { this.intValue = intValue; } - + public static AlarmInfo createSpeedLimit(int speed, Location loc){ AlarmInfo info = new AlarmInfo(AlarmInfoType.SPEED_LIMIT, 0); info.setLatLon(loc.getLatitude(), loc.getLongitude()); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index ffa3dab6c6..3ca74781e8 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -239,6 +239,9 @@ public class RouteCalculationResult { tunnelAlarm.setFloatValue(tunnelAlarm.getFloatValue() + s.getDistance()); } } else { + if (tunnelAlarm != null) { + tunnelAlarm.setLastLocationIndex(locations.size()); + } tunnelAlarm = null; } while (true) {