This commit is contained in:
Alexander Sytnyk 2018-02-06 15:02:35 +02:00
parent f87308bbda
commit de5a79f072
2 changed files with 34 additions and 33 deletions

View file

@ -27,7 +27,6 @@ import net.osmand.plus.routing.AlarmInfo;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.routing.VoiceRouter;
import net.osmand.router.RouteSegmentResult;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
@ -203,28 +202,9 @@ public class WaypointHelper {
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;
}
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) {
//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:
@ -724,32 +704,39 @@ public class WaypointHelper {
} else if (type == ALARMS) {
//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);
} 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);
} else if (((AlarmInfo) point).getType().toString().equals("RAILWAY")) {
} else if (typeString.equals("RAILWAY")) {
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us);
} else {
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) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us);
} else {
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);
} else if (((AlarmInfo) point).getType().toString().equals("STOP")) {
} else if (typeString.equals("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) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us);
} else {
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 {
return null;
}

View file

@ -1,8 +1,6 @@
package net.osmand.plus.routing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.content.Context;
import net.osmand.Location;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
@ -12,12 +10,14 @@ import net.osmand.data.LocationPoint;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.TurnType;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.util.Algorithms;
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;
@ -221,12 +221,26 @@ public class RouteCalculationResult {
float prevDirectionDistance = 0;
double lastHeight = HEIGHT_UNDEFINED;
List<RouteSegmentResult> segmentsToPopulate = new ArrayList<RouteSegmentResult>();
AlarmInfo tunnelAlarm = null;
for (int routeInd = 0; routeInd < list.size(); routeInd++) {
RouteSegmentResult s = list.get(routeInd);
float[] vls = s.getObject().calculateHeightArray();
boolean plus = s.getStartPointIndex() < s.getEndPointIndex();
int i = s.getStartPointIndex();
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) {
Location n = new Location(""); //$NON-NLS-1$
LatLon point = s.getPoint(i);