Avoid saved roads initial commit
This commit is contained in:
parent
5a731b8b04
commit
bd0d4a9c9e
8 changed files with 91 additions and 84 deletions
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.router;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||
|
@ -13,8 +12,10 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
|
@ -55,7 +56,7 @@ public class RoutingConfiguration {
|
|||
private String defaultRouter = "";
|
||||
private Map<String, GeneralRouter> routers = new LinkedHashMap<>();
|
||||
private Map<String, String> attributes = new LinkedHashMap<>();
|
||||
private HashMap<Long, Location> impassableRoadLocations = new HashMap<>();
|
||||
private List<Long> impassableRoadLocations = new ArrayList<>();
|
||||
|
||||
public Builder() {
|
||||
|
||||
|
@ -95,7 +96,7 @@ public class RoutingConfiguration {
|
|||
i.initialDirection = direction;
|
||||
i.recalculateDistance = parseSilentFloat(getAttribute(i.router, "recalculateDistanceHelp"), i.recalculateDistance) ;
|
||||
i.heuristicCoefficient = parseSilentFloat(getAttribute(i.router, "heuristicCoefficient"), i.heuristicCoefficient);
|
||||
i.router.addImpassableRoads(impassableRoadLocations.keySet());
|
||||
i.router.addImpassableRoads(new HashSet<>(impassableRoadLocations));
|
||||
i.ZOOM_TO_LOAD_TILES = parseSilentInt(getAttribute(i.router, "zoomToLoadTiles"), i.ZOOM_TO_LOAD_TILES);
|
||||
int desirable = parseSilentInt(getAttribute(i.router, "memoryLimitInMB"), 0);
|
||||
if(desirable != 0) {
|
||||
|
@ -111,13 +112,13 @@ public class RoutingConfiguration {
|
|||
return i;
|
||||
}
|
||||
|
||||
public Map<Long, Location> getImpassableRoadLocations() {
|
||||
public List<Long> getImpassableRoadLocations() {
|
||||
return impassableRoadLocations;
|
||||
}
|
||||
|
||||
public boolean addImpassableRoad(RouteDataObject route, Location location) {
|
||||
if (!impassableRoadLocations.containsKey(route.id)){
|
||||
impassableRoadLocations.put(route.id, location);
|
||||
public boolean addImpassableRoad(RouteDataObject route) {
|
||||
if (!impassableRoadLocations.contains(route.id)) {
|
||||
impassableRoadLocations.add(route.id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -159,8 +160,8 @@ public class RoutingConfiguration {
|
|||
return routers;
|
||||
}
|
||||
|
||||
public void removeImpassableRoad(RouteDataObject obj) {
|
||||
impassableRoadLocations.remove(obj.id);
|
||||
public void removeImpassableRoad(long routeId) {
|
||||
impassableRoadLocations.remove(routeId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -739,7 +739,7 @@ public class AppInitializer implements IProgress {
|
|||
notifyEvent(InitEvents.RESTORE_BACKUPS);
|
||||
app.mapMarkersHelper.syncAllGroupsAsync();
|
||||
app.searchUICore.initSearchUICore();
|
||||
app.avoidSpecificRoads.initRouteObjects();
|
||||
app.avoidSpecificRoads.initRouteObjects(false);
|
||||
|
||||
checkLiveUpdatesAlerts();
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import net.osmand.plus.api.SettingsAPI;
|
|||
import net.osmand.plus.api.SettingsAPI.SettingsEditor;
|
||||
import net.osmand.plus.api.SettingsAPIImpl;
|
||||
import net.osmand.plus.dialogs.RateUsBottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.mapillary.MapillaryPlugin;
|
||||
import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format;
|
||||
|
@ -2627,6 +2628,7 @@ public class OsmandSettings {
|
|||
|
||||
private static final String IMPASSABLE_ROAD_POINTS = "impassable_road_points";
|
||||
private static final String IMPASSABLE_ROADS_DESCRIPTIONS = "impassable_roads_descriptions";
|
||||
private static final String IMPASSABLE_ROADS_IDS = "impassable_roads_ids";
|
||||
private ImpassableRoadsStorage mImpassableRoadsStorage = new ImpassableRoadsStorage();
|
||||
|
||||
public void backupPointToStart() {
|
||||
|
@ -2989,11 +2991,11 @@ public class OsmandSettings {
|
|||
return settingsAPI.edit(globalPreferences).putInt(POINT_NAVIGATE_ROUTE, NAVIGATE).commit();
|
||||
}
|
||||
|
||||
public List<LatLon> getImpassableRoadPoints() {
|
||||
return mImpassableRoadsStorage.getPoints();
|
||||
public List<AvoidRoadInfo> getImpassableRoadPoints() {
|
||||
return mImpassableRoadsStorage.getImpassableRoadsInfo();
|
||||
}
|
||||
public boolean addImpassableRoad(double latitude, double longitude) {
|
||||
return mImpassableRoadsStorage.insertPoint(latitude, longitude, null, 0);
|
||||
public boolean addImpassableRoad(AvoidRoadInfo avoidRoadInfo) {
|
||||
return mImpassableRoadsStorage.addImpassableRoadInfo(avoidRoadInfo);
|
||||
}
|
||||
|
||||
public boolean removeImpassableRoad(int index) {
|
||||
|
|
|
@ -50,22 +50,24 @@ public class AvoidSpecificRoads {
|
|||
|
||||
private OsmandApplication app;
|
||||
|
||||
private Map<LatLon, RouteDataObject> impassableRoads = new LinkedHashMap<>();
|
||||
private Map<LatLon, AvoidRoadInfo> impassableRoads = new LinkedHashMap<>();
|
||||
|
||||
public AvoidSpecificRoads(final OsmandApplication app) {
|
||||
this.app = app;
|
||||
for (LatLon latLon : app.getSettings().getImpassableRoadPoints()) {
|
||||
impassableRoads.put(latLon, null);
|
||||
for (AvoidRoadInfo avoidRoadInfo : app.getSettings().getImpassableRoadPoints()) {
|
||||
impassableRoads.put(new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon), avoidRoadInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<LatLon, RouteDataObject> getImpassableRoads() {
|
||||
public Map<LatLon, AvoidRoadInfo> getImpassableRoads() {
|
||||
return impassableRoads;
|
||||
}
|
||||
|
||||
public void initRouteObjects() {
|
||||
for (LatLon latLon : impassableRoads.keySet()) {
|
||||
addImpassableRoad(null, latLon, false, true);
|
||||
public void initRouteObjects(boolean force) {
|
||||
for (Map.Entry<LatLon, AvoidRoadInfo> entry : impassableRoads.entrySet()) {
|
||||
if (force || entry.getValue().id == 0) {
|
||||
addImpassableRoad(null, entry.getKey(), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,25 +119,15 @@ public class AvoidSpecificRoads {
|
|||
|
||||
public String getText(@Nullable LatLon point) {
|
||||
if (point != null) {
|
||||
RouteDataObject obj = impassableRoads.get(point);
|
||||
if (obj != null) {
|
||||
String locale = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
||||
boolean transliterate = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
|
||||
String name = RoutingHelper.formatStreetName(
|
||||
obj.getName(locale, transliterate),
|
||||
obj.getRef(locale, transliterate, true),
|
||||
obj.getDestinationName(locale, transliterate, true),
|
||||
app.getString(R.string.towards)
|
||||
);
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
return name;
|
||||
}
|
||||
AvoidRoadInfo obj = impassableRoads.get(point);
|
||||
if (obj != null && !TextUtils.isEmpty(obj.name)) {
|
||||
return obj.name;
|
||||
}
|
||||
}
|
||||
return app.getString(R.string.shared_string_road);
|
||||
}
|
||||
|
||||
public String getText(@Nullable RouteDataObject obj) {
|
||||
public String getRoadName(@Nullable RouteDataObject obj) {
|
||||
if (obj != null) {
|
||||
String locale = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
||||
boolean transliterate = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
|
||||
|
@ -347,21 +339,35 @@ public class AvoidSpecificRoads {
|
|||
MapActivity.launchMapActivityMoveToTop(ctx);
|
||||
}
|
||||
|
||||
public LatLon getLocation(RouteDataObject object) {
|
||||
Location location = null;
|
||||
public LatLon getLocation(AvoidRoadInfo avoidRoadInfo) {
|
||||
for (RoutingConfiguration.Builder builder : app.getAllRoutingConfigs()) {
|
||||
location = builder.getImpassableRoadLocations().get(object.getId());
|
||||
if (location != null) {
|
||||
break;
|
||||
if (builder.getImpassableRoadLocations().contains(avoidRoadInfo.id)) {
|
||||
return new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon);
|
||||
}
|
||||
}
|
||||
return location == null ? null : new LatLon(location.getLatitude(), location.getLongitude());
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface AvoidSpecificRoadsCallback {
|
||||
|
||||
void onAddImpassableRoad(boolean success, RouteDataObject newObject);
|
||||
void onAddImpassableRoad(boolean success, AvoidRoadInfo avoidRoadInfo);
|
||||
|
||||
boolean isCancelled();
|
||||
}
|
||||
|
||||
private AvoidRoadInfo createAvoidRoadInfo(@Nullable RouteDataObject object, double lat, double lon) {
|
||||
AvoidRoadInfo avoidRoadInfo = new AvoidRoadInfo();
|
||||
avoidRoadInfo.id = object != null ? object.id : 0;
|
||||
avoidRoadInfo.lat = lat;
|
||||
avoidRoadInfo.lon = lon;
|
||||
avoidRoadInfo.name = getRoadName(object);
|
||||
return avoidRoadInfo;
|
||||
}
|
||||
|
||||
public static class AvoidRoadInfo {
|
||||
public long id;
|
||||
public double lat;
|
||||
public double lon;
|
||||
public String name;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.aidl.AidlMapPointWrapper;
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -45,6 +44,7 @@ import net.osmand.plus.download.DownloadActivityType;
|
|||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
import net.osmand.plus.download.DownloadValidationManager;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapsableView;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapseExpandListener;
|
||||
|
@ -220,8 +220,8 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
} else if (pointDescription.isMyLocation()) {
|
||||
menuController = new MyLocationMenuController(mapActivity, pointDescription);
|
||||
}
|
||||
} else if (object instanceof RouteDataObject) {
|
||||
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (RouteDataObject) object);
|
||||
} else if (object instanceof AvoidSpecificRoads.AvoidRoadInfo) {
|
||||
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (AvoidSpecificRoads.AvoidRoadInfo) object);
|
||||
} else if (object instanceof RenderedObject) {
|
||||
menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
|
||||
} else if (object instanceof MapillaryImage) {
|
||||
|
|
|
@ -4,24 +4,24 @@ import android.graphics.drawable.Drawable;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
||||
public class ImpassibleRoadsMenuController extends MenuController {
|
||||
|
||||
private RouteDataObject route;
|
||||
private AvoidRoadInfo avoidRoadInfo;
|
||||
|
||||
public ImpassibleRoadsMenuController(@NonNull MapActivity mapActivity,
|
||||
@NonNull PointDescription pointDescription,
|
||||
@NonNull RouteDataObject route) {
|
||||
@NonNull AvoidRoadInfo avoidRoadInfo) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.route = route;
|
||||
this.avoidRoadInfo = avoidRoadInfo;
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@ public class ImpassibleRoadsMenuController extends MenuController {
|
|||
MapActivity activity = getMapActivity();
|
||||
if (activity != null) {
|
||||
app.getAvoidSpecificRoads().removeImpassableRoad(
|
||||
ImpassibleRoadsMenuController.this.route);
|
||||
ImpassibleRoadsMenuController.this.avoidRoadInfo);
|
||||
RoutingHelper rh = app.getRoutingHelper();
|
||||
if (rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
|
||||
rh.recalculateRouteDueToSettingsChange();
|
||||
|
@ -44,12 +44,12 @@ public class ImpassibleRoadsMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
protected void setObject(Object object) {
|
||||
route = (RouteDataObject) object;
|
||||
avoidRoadInfo = (AvoidRoadInfo) object;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getObject() {
|
||||
return route;
|
||||
return avoidRoadInfo;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
@ -38,7 +38,6 @@ import net.osmand.Location;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -67,6 +66,7 @@ import net.osmand.plus.base.ContextMenuFragment.MenuState;
|
|||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenuFragment;
|
||||
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
|
@ -110,13 +110,13 @@ import org.apache.commons.logging.Log;
|
|||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class MapRouteInfoMenu implements IRouteInformationListener, CardListener, FavoritesListener {
|
||||
|
||||
|
@ -1204,7 +1204,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
final LinearLayout item = createToolbarOptionView(false, null, -1, -1, null);
|
||||
if (item != null) {
|
||||
item.findViewById(R.id.route_option_container).setVisibility(View.GONE);
|
||||
Map<LatLon, RouteDataObject> impassableRoads = new TreeMap<>();
|
||||
Map<LatLon, AvoidRoadInfo> impassableRoads = new HashMap<>();
|
||||
if (parameter instanceof AvoidRoadsRoutingParameter) {
|
||||
impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads();
|
||||
}
|
||||
|
@ -1232,22 +1232,19 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
return avoidedParameters;
|
||||
}
|
||||
|
||||
private void createImpassableRoadsItems(MapActivity mapActivity, Map<LatLon, RouteDataObject> impassableRoads, final LocalRoutingParameter parameter, final RouteMenuAppModes mode, final LinearLayout item) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
Iterator<RouteDataObject> it = impassableRoads.values().iterator();
|
||||
private void createImpassableRoadsItems(MapActivity mapActivity, Map<LatLon, AvoidRoadInfo> impassableRoads,
|
||||
final LocalRoutingParameter parameter, final RouteMenuAppModes mode, final LinearLayout item) {
|
||||
Iterator<AvoidRoadInfo> it = impassableRoads.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
final RouteDataObject routeDataObject = it.next();
|
||||
final View container = createToolbarSubOptionView(false, app.getAvoidSpecificRoads().getText(routeDataObject), R.drawable.ic_action_remove_dark, !it.hasNext(), new OnClickListener() {
|
||||
final AvoidRoadInfo avoidRoadInfo = it.next();
|
||||
final View container = createToolbarSubOptionView(false, avoidRoadInfo.name, R.drawable.ic_action_remove_dark, !it.hasNext(), new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (routeDataObject != null) {
|
||||
app.getAvoidSpecificRoads().removeImpassableRoad(routeDataObject);
|
||||
}
|
||||
routingHelper.recalculateRouteDueToSettingsChange();
|
||||
app.getAvoidSpecificRoads().removeImpassableRoad(avoidRoadInfo);
|
||||
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||
if (app.getAvoidSpecificRoads().getImpassableRoads().isEmpty() && getAvoidedParameters(app).isEmpty()) {
|
||||
mode.parameters.remove(parameter);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.graphics.PointF;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -18,6 +17,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidSpecificRoadsCallback;
|
||||
import net.osmand.plus.views.ContextMenuLayer.ApplyMovedObjectCallback;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
|
|||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if (contextMenuLayer.getMoveableObject() instanceof RouteDataObject) {
|
||||
if (contextMenuLayer.getMoveableObject() instanceof AvoidRoadInfo) {
|
||||
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
|
||||
drawPoint(canvas, pf.x, pf.y, true);
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
|
|||
@Override
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if (tileBox.getZoom() >= START_ZOOM) {
|
||||
for (Map.Entry<LatLon, RouteDataObject> entry : avoidSpecificRoads.getImpassableRoads().entrySet()) {
|
||||
for (Map.Entry<LatLon, AvoidRoadInfo> entry : avoidSpecificRoads.getImpassableRoads().entrySet()) {
|
||||
LatLon location = entry.getKey();
|
||||
RouteDataObject road = entry.getValue();
|
||||
if (road != null && contextMenuLayer.getMoveableObject() instanceof RouteDataObject) {
|
||||
RouteDataObject object = (RouteDataObject) contextMenuLayer.getMoveableObject();
|
||||
AvoidRoadInfo road = entry.getValue();
|
||||
if (road != null && contextMenuLayer.getMoveableObject() instanceof AvoidRoadInfo) {
|
||||
AvoidRoadInfo object = (AvoidRoadInfo) contextMenuLayer.getMoveableObject();
|
||||
if (object.id == road.id) {
|
||||
continue;
|
||||
}
|
||||
|
@ -146,9 +146,9 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
|
|||
int compare = getRadiusPoi(tileBox);
|
||||
int radius = compare * 3 / 2;
|
||||
|
||||
for (Map.Entry<LatLon, RouteDataObject> entry : avoidSpecificRoads.getImpassableRoads().entrySet()) {
|
||||
for (Map.Entry<LatLon, AvoidRoadInfo> entry : avoidSpecificRoads.getImpassableRoads().entrySet()) {
|
||||
LatLon location = entry.getKey();
|
||||
RouteDataObject road = entry.getValue();
|
||||
AvoidRoadInfo road = entry.getValue();
|
||||
if (location != null && road != null) {
|
||||
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
|
@ -163,36 +163,37 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
|
|||
|
||||
@Override
|
||||
public LatLon getObjectLocation(Object o) {
|
||||
if (o instanceof RouteDataObject) {
|
||||
return avoidSpecificRoads.getLocation((RouteDataObject) o);
|
||||
if (o instanceof AvoidRoadInfo) {
|
||||
AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) o;
|
||||
return new LatLon(avoidRoadInfo.lat, avoidRoadInfo.lon);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointDescription getObjectName(Object o) {
|
||||
if (o instanceof RouteDataObject) {
|
||||
RouteDataObject route = (RouteDataObject) o;
|
||||
return new PointDescription(PointDescription.POINT_TYPE_BLOCKED_ROAD, route.getName());
|
||||
if (o instanceof AvoidRoadInfo) {
|
||||
AvoidRoadInfo route = (AvoidRoadInfo) o;
|
||||
return new PointDescription(PointDescription.POINT_TYPE_BLOCKED_ROAD, route.name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObjectMovable(Object o) {
|
||||
return o instanceof RouteDataObject;
|
||||
return o instanceof AvoidRoadInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyNewObjectPosition(@NonNull Object o,
|
||||
@NonNull LatLon position,
|
||||
@Nullable final ApplyMovedObjectCallback callback) {
|
||||
if (o instanceof RouteDataObject) {
|
||||
final RouteDataObject object = (RouteDataObject) o;
|
||||
if (o instanceof AvoidRoadInfo) {
|
||||
final AvoidRoadInfo object = (AvoidRoadInfo) o;
|
||||
final OsmandApplication application = activity.getMyApplication();
|
||||
application.getAvoidSpecificRoads().replaceImpassableRoad(activity, object, position, false, new AvoidSpecificRoadsCallback() {
|
||||
@Override
|
||||
public void onAddImpassableRoad(boolean success, RouteDataObject newObject) {
|
||||
public void onAddImpassableRoad(boolean success, AvoidRoadInfo newObject) {
|
||||
if (callback != null) {
|
||||
callback.onApplyMovedObject(success, newObject);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue