Search in sources :

Example 16 with MapMarker

use of net.osmand.plus.mapmarkers.MapMarker 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 17 with MapMarker

use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.

the class MarkersHistorySettingsFragment method shareItems.

@Override
protected void shareItems() {
    List<MapMarker> mapMarkers = getSelectedMarkers();
    ItineraryDataHelper dataHelper = app.getMapMarkersHelper().getDataHelper();
    GPXFile gpxFile = dataHelper.generateGpx(mapMarkers, true);
    GpxUiHelper.saveAndShareGpx(app, gpxFile);
}
Also used : MapMarker(net.osmand.plus.mapmarkers.MapMarker) ItineraryDataHelper(net.osmand.plus.mapmarkers.ItineraryDataHelper) GPXFile(net.osmand.GPXUtilities.GPXFile)

Example 18 with MapMarker

use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.

the class MarkersHistorySettingsFragment method updateHistoryItems.

@Override
protected void updateHistoryItems() {
    clearItems();
    List<Pair<Long, MapMarker>> pairs = new ArrayList<>();
    for (MapMarker marker : app.getMapMarkersHelper().getMapMarkersHistory()) {
        pairs.add(new Pair<>(marker.visitedDate, marker));
    }
    Map<Integer, List<MapMarker>> markerGroups = new HashMap<>();
    HistoryAdapter.createHistoryGroups(pairs, markerGroups, items);
    for (Map.Entry<Integer, List<MapMarker>> entry : markerGroups.entrySet()) {
        itemsGroups.put(entry.getKey(), new ArrayList<>(entry.getValue()));
    }
}
Also used : MapMarker(net.osmand.plus.mapmarkers.MapMarker) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Pair(android.util.Pair)

Example 19 with MapMarker

use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.

the class MapMarkersLayer method applyNewObjectPosition.

@Override
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position, @Nullable ApplyMovedObjectCallback callback) {
    boolean result = false;
    MapMarker newObject = null;
    if (o instanceof MapMarker) {
        MapMarkersHelper markersHelper = getApplication().getMapMarkersHelper();
        MapMarker marker = (MapMarker) o;
        PointDescription originalDescription = marker.getOriginalPointDescription();
        if (originalDescription.isLocation()) {
            originalDescription.setName(PointDescription.getSearchAddressStr(getContext()));
        }
        markersHelper.moveMapMarker(marker, position);
        int index = markersHelper.getMapMarkers().indexOf(marker);
        if (index != -1) {
            newObject = markersHelper.getMapMarkers().get(index);
        }
        result = true;
    }
    if (callback != null) {
        callback.onApplyMovedObject(result, newObject == null ? o : newObject);
    }
}
Also used : MapMarker(net.osmand.plus.mapmarkers.MapMarker) MapMarkersHelper(net.osmand.plus.mapmarkers.MapMarkersHelper) PointDescription(net.osmand.data.PointDescription) QuadPoint(net.osmand.data.QuadPoint) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)

Example 20 with MapMarker

use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.

the class MapMarkersLayer method onDraw.

@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
    if (widgetsFactory != null) {
        widgetsFactory.updateInfo(useFingerLocation ? fingerLocation : null, tileBox.getZoom());
    }
    OsmandApplication app = getApplication();
    OsmandSettings settings = app.getSettings();
    if (tileBox.getZoom() < 3 || !settings.SHOW_MAP_MARKERS.get()) {
        return;
    }
    int displayedWidgets = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get();
    MapMarkersHelper markersHelper = app.getMapMarkersHelper();
    updateBitmaps(false);
    for (MapMarker marker : markersHelper.getMapMarkers()) {
        if (isMarkerVisible(tileBox, marker) && !overlappedByWaypoint(marker) && !isInMotion(marker) && !isSynced(marker)) {
            Bitmap bmp = getMapMarkerBitmap(marker.colorIndex);
            int marginX = bmp.getWidth() / 6;
            int marginY = bmp.getHeight();
            int locationX = tileBox.getPixXFromLonNoRot(marker.getLongitude());
            int locationY = tileBox.getPixYFromLatNoRot(marker.getLatitude());
            canvas.rotate(-tileBox.getRotate(), locationX, locationY);
            canvas.drawBitmap(bmp, locationX - marginX, locationY - marginY, bitmapPaint);
            canvas.rotate(tileBox.getRotate(), locationX, locationY);
        }
    }
    if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
        LatLon loc = tileBox.getCenterLatLon();
        int i = 0;
        for (MapMarker marker : markersHelper.getMapMarkers()) {
            if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
                canvas.save();
                net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(), marker.getLatitude(), marker.getLongitude(), calculations);
                float bearing = calculations[1] - 90;
                float radiusBearing = DIST_TO_SHOW * tileBox.getDensity();
                final QuadPoint cp = tileBox.getCenterPixelPoint();
                canvas.rotate(bearing, cp.x, cp.y);
                canvas.translate(-24 * tileBox.getDensity() + radiusBearing, -22 * tileBox.getDensity());
                canvas.drawBitmap(arrowShadow, cp.x, cp.y, bitmapPaint);
                canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
                canvas.drawBitmap(arrowLight, cp.x, cp.y, bitmapPaint);
                canvas.restore();
            }
            i++;
            if (i > displayedWidgets - 1) {
                break;
            }
        }
    }
    if (contextMenuLayer.getMoveableObject() instanceof MapMarker) {
        MapMarker objectInMotion = (MapMarker) contextMenuLayer.getMoveableObject();
        PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
        Bitmap bitmap = getMapMarkerBitmap(objectInMotion.colorIndex);
        int marginX = bitmap.getWidth() / 6;
        int marginY = bitmap.getHeight();
        float locationX = pf.x;
        float locationY = pf.y;
        canvas.rotate(-tileBox.getRotate(), locationX, locationY);
        canvas.drawBitmap(bitmap, locationX - marginX, locationY - marginY, bitmapPaint);
    }
}
Also used : LatLon(net.osmand.data.LatLon) Bitmap(android.graphics.Bitmap) OsmandApplication(net.osmand.plus.OsmandApplication) MapMarkersHelper(net.osmand.plus.mapmarkers.MapMarkersHelper) MapMarker(net.osmand.plus.mapmarkers.MapMarker) QuadPoint(net.osmand.data.QuadPoint) PointF(android.graphics.PointF) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) QuadPoint(net.osmand.data.QuadPoint) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)

Aggregations

MapMarker (net.osmand.plus.mapmarkers.MapMarker)106 LatLon (net.osmand.data.LatLon)42 ArrayList (java.util.ArrayList)30 OsmandApplication (net.osmand.plus.OsmandApplication)26 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)24 MapMarkersHelper (net.osmand.plus.mapmarkers.MapMarkersHelper)20 GPXFile (net.osmand.GPXUtilities.GPXFile)18 PointDescription (net.osmand.data.PointDescription)18 File (java.io.File)16 FavouritePoint (net.osmand.data.FavouritePoint)16 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)16 View (android.view.View)14 MapActivity (net.osmand.plus.activities.MapActivity)14 Paint (android.graphics.Paint)12 NonNull (androidx.annotation.NonNull)12 Nullable (androidx.annotation.Nullable)12 RecyclerView (androidx.recyclerview.widget.RecyclerView)12 WptPt (net.osmand.GPXUtilities.WptPt)12 Location (net.osmand.Location)12 Amenity (net.osmand.data.Amenity)12