Fix #3773
This commit is contained in:
parent
6a7b30e33d
commit
ce59706582
2 changed files with 34 additions and 33 deletions
|
@ -27,7 +27,6 @@ import net.osmand.plus.routing.AlarmInfo;
|
||||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||||
import net.osmand.plus.routing.RouteCalculationResult;
|
import net.osmand.plus.routing.RouteCalculationResult;
|
||||||
import net.osmand.plus.routing.VoiceRouter;
|
import net.osmand.plus.routing.VoiceRouter;
|
||||||
import net.osmand.router.RouteSegmentResult;
|
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -203,28 +202,9 @@ public class WaypointHelper {
|
||||||
kIterator++;
|
kIterator++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<RouteSegmentResult> segments = route.getUpcomingTunnel(500);
|
|
||||||
if (segments != null && !segments.isEmpty()) {
|
|
||||||
AlarmInfo inf = new AlarmInfo(AlarmInfoType.TUNNEL, 0);
|
|
||||||
int d = route.getDistanceToPoint(segments.get(0).getStartPointIndex());
|
|
||||||
float time = speed > 0 ? d / speed : Integer.MAX_VALUE;
|
|
||||||
inf.setFloatValue(calculateDistance(segments));
|
|
||||||
int vl = inf.updateDistanceAndGetPriority(time, d);
|
|
||||||
if (vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)) {
|
|
||||||
mostImportant = inf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mostImportant;
|
return mostImportant;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float calculateDistance(List<RouteSegmentResult> segments) {
|
|
||||||
float sum = 0f;
|
|
||||||
for (RouteSegmentResult r : segments) {
|
|
||||||
sum += r.getDistance();
|
|
||||||
}
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableWaypointType(int type, boolean enable) {
|
public void enableWaypointType(int type, boolean enable) {
|
||||||
//An item will be displayed in the Waypoint list if either "Show..." or "Announce..." is selected for it in the Navigation settings
|
//An item will be displayed in the Waypoint list if either "Show..." or "Announce..." is selected for it in the Navigation settings
|
||||||
//Keep both "Show..." and "Announce..." Nav settings in sync when user changes what to display in the Waypoint list, as follows:
|
//Keep both "Show..." and "Announce..." Nav settings in sync when user changes what to display in the Waypoint list, as follows:
|
||||||
|
@ -724,32 +704,39 @@ public class WaypointHelper {
|
||||||
|
|
||||||
} else if (type == ALARMS) {
|
} else if (type == ALARMS) {
|
||||||
//assign alarm list icons manually for now
|
//assign alarm list icons manually for now
|
||||||
if (((AlarmInfo) point).getType().toString().equals("SPEED_CAMERA")) {
|
String typeString = ((AlarmInfo) point).getType().toString();
|
||||||
|
if (typeString.equals("SPEED_CAMERA")) {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.mx_highway_speed_camera);
|
return uiCtx.getResources().getDrawable(R.drawable.mx_highway_speed_camera);
|
||||||
} else if (((AlarmInfo) point).getType().toString().equals("BORDER_CONTROL")) {
|
} else if (typeString.equals("BORDER_CONTROL")) {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control);
|
return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control);
|
||||||
} else if (((AlarmInfo) point).getType().toString().equals("RAILWAY")) {
|
} else if (typeString.equals("RAILWAY")) {
|
||||||
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
|
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us);
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us);
|
||||||
} else {
|
} else {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways);
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways);
|
||||||
}
|
}
|
||||||
} else if (((AlarmInfo) point).getType().toString().equals("TRAFFIC_CALMING")) {
|
} else if (typeString.equals("TRAFFIC_CALMING")) {
|
||||||
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
|
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us);
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us);
|
||||||
} else {
|
} else {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming);
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming);
|
||||||
}
|
}
|
||||||
} else if (((AlarmInfo) point).getType().toString().equals("TOLL_BOOTH")) {
|
} else if (typeString.equals("TOLL_BOOTH")) {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.mx_toll_booth);
|
return uiCtx.getResources().getDrawable(R.drawable.mx_toll_booth);
|
||||||
} else if (((AlarmInfo) point).getType().toString().equals("STOP")) {
|
} else if (typeString.equals("STOP")) {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.list_stop);
|
return uiCtx.getResources().getDrawable(R.drawable.list_stop);
|
||||||
} else if (((AlarmInfo) point).getType().toString().equals("PEDESTRIAN")) {
|
} else if (typeString.equals("PEDESTRIAN")) {
|
||||||
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
|
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us);
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us);
|
||||||
} else {
|
} else {
|
||||||
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian);
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian);
|
||||||
}
|
}
|
||||||
|
} else if (typeString.equals("TUNNEL")) {
|
||||||
|
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
|
||||||
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_tunnel);
|
||||||
|
} else {
|
||||||
|
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_tunnel_us);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package net.osmand.plus.routing;
|
package net.osmand.plus.routing;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import android.content.Context;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
|
@ -12,12 +10,14 @@ import net.osmand.data.LocationPoint;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||||
import net.osmand.router.RouteSegmentResult;
|
import net.osmand.router.RouteSegmentResult;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import android.content.Context;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||||
|
|
||||||
|
@ -221,12 +221,26 @@ public class RouteCalculationResult {
|
||||||
float prevDirectionDistance = 0;
|
float prevDirectionDistance = 0;
|
||||||
double lastHeight = HEIGHT_UNDEFINED;
|
double lastHeight = HEIGHT_UNDEFINED;
|
||||||
List<RouteSegmentResult> segmentsToPopulate = new ArrayList<RouteSegmentResult>();
|
List<RouteSegmentResult> segmentsToPopulate = new ArrayList<RouteSegmentResult>();
|
||||||
|
AlarmInfo tunnelAlarm = null;
|
||||||
for (int routeInd = 0; routeInd < list.size(); routeInd++) {
|
for (int routeInd = 0; routeInd < list.size(); routeInd++) {
|
||||||
RouteSegmentResult s = list.get(routeInd);
|
RouteSegmentResult s = list.get(routeInd);
|
||||||
float[] vls = s.getObject().calculateHeightArray();
|
float[] vls = s.getObject().calculateHeightArray();
|
||||||
boolean plus = s.getStartPointIndex() < s.getEndPointIndex();
|
boolean plus = s.getStartPointIndex() < s.getEndPointIndex();
|
||||||
int i = s.getStartPointIndex();
|
int i = s.getStartPointIndex();
|
||||||
int prevLocationSize = locations.size();
|
int prevLocationSize = locations.size();
|
||||||
|
if (s.getObject().tunnel()) {
|
||||||
|
if (tunnelAlarm == null) {
|
||||||
|
LatLon latLon = s.getPoint(i);
|
||||||
|
tunnelAlarm = new AlarmInfo(AlarmInfoType.TUNNEL, prevLocationSize);
|
||||||
|
tunnelAlarm.setLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||||
|
tunnelAlarm.setFloatValue(s.getDistance());
|
||||||
|
alarms.add(tunnelAlarm);
|
||||||
|
} else {
|
||||||
|
tunnelAlarm.setFloatValue(tunnelAlarm.getFloatValue() + s.getDistance());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tunnelAlarm = null;
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
Location n = new Location(""); //$NON-NLS-1$
|
Location n = new Location(""); //$NON-NLS-1$
|
||||||
LatLon point = s.getPoint(i);
|
LatLon point = s.getPoint(i);
|
||||||
|
|
Loading…
Reference in a new issue