use of net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo in project Osmand by osmandapp.
the class ImpassableRoadsLayer method onDraw.
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof AvoidRoadInfo) {
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
drawPoint(canvas, pf.x, pf.y, true);
}
}
use of net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo in project Osmand by osmandapp.
the class ImpassableRoadsLayer method collectObjectsFromPoint.
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o, boolean unknownLocation) {
if (tileBox.getZoom() >= START_ZOOM) {
int ex = (int) point.x;
int ey = (int) point.y;
int compare = getScaledTouchRadius(getApplication(), getRadiusPoi(tileBox));
int radius = compare * 3 / 2;
for (Map.Entry<LatLon, AvoidRoadInfo> entry : avoidSpecificRoads.getImpassableRoads().entrySet()) {
LatLon location = entry.getKey();
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());
if (calculateBelongs(ex, ey, x, y, compare)) {
compare = radius;
o.add(road);
}
}
}
}
}
use of net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo in project Osmand by osmandapp.
the class ImpassableRoadsLayer method applyNewObjectPosition.
@Override
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position, @Nullable final ApplyMovedObjectCallback callback) {
MapActivity mapActivity = getMapActivity();
if (o instanceof AvoidRoadInfo && mapActivity != null) {
final AvoidRoadInfo object = (AvoidRoadInfo) o;
final OsmandApplication application = getApplication();
application.getAvoidSpecificRoads().replaceImpassableRoad(mapActivity, object, position, false, new AvoidSpecificRoadsCallback() {
@Override
public void onAddImpassableRoad(boolean success, AvoidRoadInfo newObject) {
if (callback != null) {
callback.onApplyMovedObject(success, newObject);
}
}
@Override
public boolean isCancelled() {
return callback != null && callback.isCancelled();
}
});
}
}
use of net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo in project Osmand by osmandapp.
the class ImportDuplicatesFragment method prepareDuplicates.
protected List<Object> prepareDuplicates(List<? super Object> duplicatesList) {
List<? super Object> duplicates = new ArrayList<>();
List<ApplicationMode.ApplicationModeBean> profiles = new ArrayList<>();
List<QuickAction> actions = new ArrayList<>();
List<PoiUIFilter> filters = new ArrayList<>();
List<ITileSource> tileSources = new ArrayList<>();
List<File> renderFilesList = new ArrayList<>();
List<File> routingFilesList = new ArrayList<>();
List<File> multimediaFilesList = new ArrayList<>();
List<File> trackFilesList = new ArrayList<>();
List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
List<FavoriteGroup> favoriteGroups = new ArrayList<>();
List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
List<File> ttsVoiceFilesList = new ArrayList<>();
List<File> voiceFilesList = new ArrayList<>();
List<File> mapFilesList = new ArrayList<>();
List<MapMarker> mapMarkers = new ArrayList<>();
List<MapMarker> mapMarkersHistory = new ArrayList<>();
List<HistoryEntry> historyEntries = new ArrayList<>();
List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
List<MapMarkersGroup> itineraryGroups = new ArrayList<>();
for (Object object : duplicatesList) {
if (object instanceof ApplicationMode.ApplicationModeBean) {
profiles.add((ApplicationMode.ApplicationModeBean) object);
} else if (object instanceof QuickAction) {
actions.add((QuickAction) object);
} else if (object instanceof PoiUIFilter) {
filters.add((PoiUIFilter) object);
} else if (object instanceof ITileSource) {
tileSources.add((ITileSource) object);
} else if (object instanceof File) {
File file = (File) object;
FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
if (fileSubtype == FileSubtype.RENDERING_STYLE) {
renderFilesList.add(file);
} else if (fileSubtype == FileSubtype.ROUTING_CONFIG) {
routingFilesList.add(file);
} else if (fileSubtype == FileSubtype.MULTIMEDIA_NOTES) {
multimediaFilesList.add(file);
} else if (fileSubtype == FileSubtype.GPX) {
trackFilesList.add(file);
} else if (fileSubtype.isMap()) {
mapFilesList.add(file);
} else if (fileSubtype == FileSubtype.TTS_VOICE) {
ttsVoiceFilesList.add(file);
} else if (fileSubtype == FileSubtype.VOICE) {
voiceFilesList.add(file);
}
} else if (object instanceof AvoidRoadInfo) {
avoidRoads.add((AvoidRoadInfo) object);
} else if (object instanceof FavoriteGroup) {
favoriteGroups.add((FavoriteGroup) object);
} else if (object instanceof OsmNotesPoint) {
osmNotesPointList.add((OsmNotesPoint) object);
} else if (object instanceof OpenstreetmapPoint) {
osmEditsPointList.add((OpenstreetmapPoint) object);
} else if (object instanceof MapMarker) {
MapMarker mapMarker = (MapMarker) object;
if (mapMarker.history) {
mapMarkersHistory.add(mapMarker);
} else {
mapMarkers.add(mapMarker);
}
} else if (object instanceof HistoryEntry) {
historyEntries.add((HistoryEntry) object);
} else if (object instanceof OnlineRoutingEngine) {
onlineRoutingEngines.add((OnlineRoutingEngine) object);
} else if (object instanceof MapMarkersGroup) {
itineraryGroups.add((MapMarkersGroup) object);
}
}
if (!profiles.isEmpty()) {
duplicates.add(getString(R.string.shared_string_profiles));
duplicates.addAll(profiles);
}
if (!actions.isEmpty()) {
duplicates.add(getString(R.string.shared_string_quick_actions));
duplicates.addAll(actions);
}
if (!filters.isEmpty()) {
duplicates.add(getString(R.string.shared_string_poi_types));
duplicates.addAll(filters);
}
if (!tileSources.isEmpty()) {
duplicates.add(getString(R.string.quick_action_map_source_title));
duplicates.addAll(tileSources);
}
if (!routingFilesList.isEmpty()) {
duplicates.add(getString(R.string.shared_string_routing));
duplicates.addAll(routingFilesList);
}
if (!renderFilesList.isEmpty()) {
duplicates.add(getString(R.string.shared_string_rendering_style));
duplicates.addAll(renderFilesList);
}
if (!multimediaFilesList.isEmpty()) {
duplicates.add(getString(R.string.audionotes_plugin_name));
duplicates.addAll(multimediaFilesList);
}
if (!trackFilesList.isEmpty()) {
duplicates.add(getString(R.string.shared_string_tracks));
duplicates.addAll(trackFilesList);
}
if (!avoidRoads.isEmpty()) {
duplicates.add(getString(R.string.avoid_road));
duplicates.addAll(avoidRoads);
}
if (!favoriteGroups.isEmpty()) {
duplicates.add(getString(R.string.shared_string_favorites));
duplicates.addAll(favoriteGroups);
}
if (!osmNotesPointList.isEmpty()) {
duplicates.add(getString(R.string.osm_notes));
duplicates.addAll(osmNotesPointList);
}
if (!osmEditsPointList.isEmpty()) {
duplicates.add(getString(R.string.osm_edits));
duplicates.addAll(osmEditsPointList);
}
if (!mapFilesList.isEmpty()) {
duplicates.add(getString(R.string.shared_string_maps));
duplicates.addAll(mapFilesList);
}
if (!ttsVoiceFilesList.isEmpty()) {
duplicates.add(getString(R.string.local_indexes_cat_tts));
duplicates.addAll(ttsVoiceFilesList);
}
if (!voiceFilesList.isEmpty()) {
duplicates.add(getString(R.string.local_indexes_cat_voice));
duplicates.addAll(voiceFilesList);
}
if (!mapMarkers.isEmpty()) {
duplicates.add(getString(R.string.map_markers));
duplicates.addAll(mapMarkers);
}
if (!mapMarkersHistory.isEmpty()) {
duplicates.add(getString(R.string.markers_history));
duplicates.addAll(mapMarkersHistory);
}
if (!onlineRoutingEngines.isEmpty()) {
duplicates.add(getString(R.string.online_routing_engines));
duplicates.addAll(onlineRoutingEngines);
}
if (!historyEntries.isEmpty()) {
duplicates.add(getString(R.string.shared_string_search_history));
duplicates.addAll(historyEntries);
}
if (!itineraryGroups.isEmpty()) {
duplicates.add(getString(R.string.shared_string_itinerary));
duplicates.addAll(itineraryGroups);
}
return duplicates;
}
use of net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo in project Osmand by osmandapp.
the class MapRouteInfoMenu method createImpassableRoadsItems.
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 AvoidRoadInfo avoidRoadInfo = it.next();
final View container = createToolbarSubOptionView(false, avoidRoadInfo.name, R.drawable.ic_action_remove_dark, !it.hasNext(), v -> {
MapActivity mapActivity1 = getMapActivity();
if (mapActivity1 != null) {
OsmandApplication app = mapActivity1.getMyApplication();
app.getAvoidSpecificRoads().removeImpassableRoad(avoidRoadInfo);
app.getRoutingHelper().onSettingsChanged(true);
if (app.getAvoidSpecificRoads().getImpassableRoads().isEmpty() && getAvoidedParameters(app).isEmpty()) {
mode.parameters.remove(parameter);
}
mapActivity1.refreshMap();
if (mode.parameters.size() > 2) {
item.removeView(v);
} else {
updateOptionsButtons();
}
}
});
if (container != null) {
item.addView(container, getContainerButtonLayoutParams(mapActivity, false));
}
}
}
Aggregations