Add full names to avoid road info
This commit is contained in:
parent
1cb49fe402
commit
2e15315a16
4 changed files with 18 additions and 24 deletions
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.router;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||
import net.osmand.router.GeneralRouter.RouteAttributeContext;
|
||||
import net.osmand.router.GeneralRouter.RouteDataObjectAttribute;
|
||||
|
@ -12,11 +11,10 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
public class RoutingConfiguration {
|
||||
|
@ -56,7 +54,7 @@ public class RoutingConfiguration {
|
|||
private String defaultRouter = "";
|
||||
private Map<String, GeneralRouter> routers = new LinkedHashMap<>();
|
||||
private Map<String, String> attributes = new LinkedHashMap<>();
|
||||
private List<Long> impassableRoadLocations = new ArrayList<>();
|
||||
private Set<Long> impassableRoadLocations = new HashSet<>();
|
||||
|
||||
public Builder() {
|
||||
|
||||
|
@ -111,17 +109,13 @@ public class RoutingConfiguration {
|
|||
// i.planRoadDirection = 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<Long> getImpassableRoadLocations() {
|
||||
|
||||
public Set<Long> getImpassableRoadLocations() {
|
||||
return impassableRoadLocations;
|
||||
}
|
||||
|
||||
public boolean addImpassableRoad(long routeId) {
|
||||
if (!impassableRoadLocations.contains(routeId)) {
|
||||
impassableRoadLocations.add(routeId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return impassableRoadLocations.add(routeId);
|
||||
}
|
||||
|
||||
public Map<String, String> getAttributes() {
|
||||
|
|
|
@ -2820,8 +2820,8 @@ public class OsmandSettings {
|
|||
|
||||
AvoidRoadInfo avoidRoadInfo = new AvoidRoadInfo();
|
||||
avoidRoadInfo.id = roadIds.get(i);
|
||||
avoidRoadInfo.lat = latLon.getLatitude();
|
||||
avoidRoadInfo.lon = latLon.getLongitude();
|
||||
avoidRoadInfo.latitude = latLon.getLatitude();
|
||||
avoidRoadInfo.longitude = latLon.getLongitude();
|
||||
avoidRoadInfo.name = description.getName();
|
||||
avoidRoadsInfo.add(avoidRoadInfo);
|
||||
}
|
||||
|
@ -2834,7 +2834,7 @@ public class OsmandSettings {
|
|||
List<String> descriptions = getPointDescriptions(points.size());
|
||||
List<Long> roadIds = getRoadIds(points.size());
|
||||
|
||||
points.add(0, new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon));
|
||||
points.add(0, new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude));
|
||||
descriptions.add(0, PointDescription.serializeToString(new PointDescription("", avoidRoadInfo.name)));
|
||||
roadIds.add(0, avoidRoadInfo.id);
|
||||
|
||||
|
@ -2846,7 +2846,7 @@ public class OsmandSettings {
|
|||
List<Long> roadIds = getRoadIds(points.size());
|
||||
List<String> descriptions = getPointDescriptions(points.size());
|
||||
|
||||
int index = points.indexOf(new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon));
|
||||
int index = points.indexOf(new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude));
|
||||
if (index != -1) {
|
||||
roadIds.set(index, avoidRoadInfo.id);
|
||||
descriptions.set(index, PointDescription.serializeToString(new PointDescription("", avoidRoadInfo.name)));
|
||||
|
|
|
@ -55,7 +55,7 @@ public class AvoidSpecificRoads {
|
|||
public AvoidSpecificRoads(final OsmandApplication app) {
|
||||
this.app = app;
|
||||
for (AvoidRoadInfo avoidRoadInfo : app.getSettings().getImpassableRoadPoints()) {
|
||||
impassableRoads.put(new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon), avoidRoadInfo);
|
||||
impassableRoads.put(new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude), avoidRoadInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class AvoidSpecificRoads {
|
|||
((ImageView) v.findViewById(R.id.waypoint_icon))
|
||||
.setImageDrawable(getIcon(R.drawable.ic_action_road_works_dark));
|
||||
|
||||
LatLon latLon = item != null ? new LatLon(item.lat, item.lon) : null;
|
||||
LatLon latLon = item != null ? new LatLon(item.latitude, item.longitude) : null;
|
||||
String name = item != null ? item.name : app.getString(R.string.shared_string_road);
|
||||
((TextView) v.findViewById(R.id.waypoint_dist)).setText(getDist(mapLocation, latLon));
|
||||
((TextView) v.findViewById(R.id.waypoint_text)).setText(name);
|
||||
|
@ -187,7 +187,7 @@ public class AvoidSpecificRoads {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
AvoidRoadInfo point = listAdapter.getItem(which);
|
||||
if (point != null) {
|
||||
showOnMap(mapActivity, point.lat, point.lon, point.name);
|
||||
showOnMap(mapActivity, point.latitude, point.longitude, point.name);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ public class AvoidSpecificRoads {
|
|||
public LatLon getLocation(AvoidRoadInfo avoidRoadInfo) {
|
||||
for (RoutingConfiguration.Builder builder : app.getAllRoutingConfigs()) {
|
||||
if (builder.getImpassableRoadLocations().contains(avoidRoadInfo.id)) {
|
||||
return new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon);
|
||||
return new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -374,16 +374,16 @@ public class AvoidSpecificRoads {
|
|||
avoidRoadInfo = new AvoidRoadInfo();
|
||||
}
|
||||
avoidRoadInfo.id = object != null ? object.id : 0;
|
||||
avoidRoadInfo.lat = lat;
|
||||
avoidRoadInfo.lon = lon;
|
||||
avoidRoadInfo.latitude = lat;
|
||||
avoidRoadInfo.longitude = lon;
|
||||
avoidRoadInfo.name = getRoadName(object);
|
||||
return avoidRoadInfo;
|
||||
}
|
||||
|
||||
public static class AvoidRoadInfo {
|
||||
public long id;
|
||||
public double lat;
|
||||
public double lon;
|
||||
public double latitude;
|
||||
public double longitude;
|
||||
public String name;
|
||||
}
|
||||
}
|
|
@ -165,7 +165,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
|
|||
public LatLon getObjectLocation(Object o) {
|
||||
if (o instanceof AvoidRoadInfo) {
|
||||
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) o;
|
||||
return new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon);
|
||||
return new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue