Merge pull request #5002 from osmandapp/tunnel_alarm

Tunnel alarm
This commit is contained in:
Alexey 2018-02-09 19:43:54 +03:00 committed by GitHub
commit f7541e511d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 6 deletions

View file

@ -183,15 +183,21 @@ public class WaypointHelper {
int kIterator = pointsProgress.get(ALARMS);
List<LocationPointWrapper> 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;
int currentRoute = route.getCurrentRoute();
if (inf.getLocationIndex() < currentRoute && inf.getLastLocationIndex() != -1
&& inf.getLastLocationIndex() < currentRoute) {
// skip
} else {
int d = route.getDistanceToPoint(lwp.routeIndex);
if (inf.getType() == AlarmInfoType.TUNNEL && inf.getLastLocationIndex() != -1
&& currentRoute > inf.getLocationIndex()
&& currentRoute < inf.getLastLocationIndex()) {
inf.setFloatValue(route.getDistanceToPoint(inf.getLastLocationIndex()));
}
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 +331,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;

View file

@ -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());

View file

@ -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) {