Search in sources :

Example 6 with AvoidRoadInfo

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);
    }
}
Also used : PointF(android.graphics.PointF) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)

Example 7 with AvoidRoadInfo

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);
                }
            }
        }
    }
}
Also used : LatLon(net.osmand.data.LatLon) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) Map(java.util.Map) Paint(android.graphics.Paint)

Example 8 with AvoidRoadInfo

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();
            }
        });
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) AvoidSpecificRoadsCallback(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidSpecificRoadsCallback) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) MapActivity(net.osmand.plus.activities.MapActivity)

Example 9 with AvoidRoadInfo

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;
}
Also used : QuickAction(net.osmand.plus.quickaction.QuickAction) MapMarker(net.osmand.plus.mapmarkers.MapMarker) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) ITileSource(net.osmand.map.ITileSource) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) FileSubtype(net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype) File(java.io.File)

Example 10 with AvoidRoadInfo

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));
        }
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)16 LatLon (net.osmand.data.LatLon)6 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)6 QuickAction (net.osmand.plus.quickaction.QuickAction)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 ITileSource (net.osmand.map.ITileSource)5 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)5 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)5 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)5 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)5 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)5 ApplicationModeBean (net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean)5 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)4 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)4 GlobalSettingsItem (net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem)4 OsmandApplication (net.osmand.plus.OsmandApplication)3 MapMarker (net.osmand.plus.mapmarkers.MapMarker)3 List (java.util.List)2 Map (java.util.Map)2