From 2e15315a16b4d95ee529e2703e19e719a81c1e55 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 18 Feb 2020 17:07:36 +0200 Subject: [PATCH] Add full names to avoid road info --- .../net/osmand/router/RoutingConfiguration.java | 16 +++++----------- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 8 ++++---- .../osmand/plus/helpers/AvoidSpecificRoads.java | 16 ++++++++-------- .../osmand/plus/views/ImpassableRoadsLayer.java | 2 +- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java b/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java index 005f3ba88c..fb3432d4aa 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RoutingConfiguration.java @@ -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 routers = new LinkedHashMap<>(); private Map attributes = new LinkedHashMap<>(); - private List impassableRoadLocations = new ArrayList<>(); + private Set impassableRoadLocations = new HashSet<>(); public Builder() { @@ -111,17 +109,13 @@ public class RoutingConfiguration { // i.planRoadDirection = 1; return i; } - - public List getImpassableRoadLocations() { + + public Set 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 getAttributes() { diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index b5ca671ace..bfeb7f1865 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -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 descriptions = getPointDescriptions(points.size()); List 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 roadIds = getRoadIds(points.size()); List 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))); diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 628e354e7c..965de9fe08 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -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; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java index b5b1d80ae1..1ab8daa1e6 100644 --- a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java @@ -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; }