use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.
the class MarkersSettingsItem method apply.
@Override
public void apply() {
List<MapMarker> newItems = getNewItems();
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
appliedItems = new ArrayList<>(newItems);
for (MapMarker duplicate : duplicateItems) {
if (shouldReplace) {
MapMarker existingMarker = markersHelper.getMapMarker(duplicate.point);
markersHelper.removeMarker(existingMarker);
}
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
}
for (MapMarker marker : appliedItems) {
markersHelper.addMarker(marker);
}
}
}
use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.
the class MarkersSettingsItem method getReader.
@Nullable
@Override
public SettingsItemReader<MarkersSettingsItem> getReader() {
return new SettingsItemReader<MarkersSettingsItem>(this) {
@Override
public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IllegalArgumentException {
GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream);
if (gpxFile.error != null) {
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error);
} else {
List<MapMarker> mapMarkers = markersHelper.getDataHelper().readMarkersFromGpx(gpxFile, false);
items.addAll(mapMarkers);
}
}
};
}
use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.
the class HistoryMarkersSettingsItem method apply.
@Override
public void apply() {
List<MapMarker> newItems = getNewItems();
if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
appliedItems = new ArrayList<>(newItems);
for (MapMarker duplicate : duplicateItems) {
if (shouldReplace) {
MapMarker existingMarker = markersHelper.getMapMarker(duplicate.point);
markersHelper.removeMarker(existingMarker);
}
appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
}
for (MapMarker marker : appliedItems) {
markersHelper.addMarker(marker);
}
}
}
use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.
the class MenuController method getMenuController.
public static MenuController getMenuController(@NonNull MapActivity mapActivity, @NonNull LatLon latLon, @NonNull PointDescription pointDescription, @Nullable Object object, @NonNull MenuType menuType) {
MenuController menuController = null;
if (object != null) {
if (object instanceof Amenity) {
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
} else if (object instanceof FavouritePoint) {
if (pointDescription.isParking() || (FavouritePoint.SpecialPointType.PARKING.equals(((FavouritePoint) object).getSpecialPointType()))) {
menuController = new ParkingPositionMenuController(mapActivity, pointDescription, (FavouritePoint) object);
} else {
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
}
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
} else if (object instanceof TargetPoint) {
menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
} else if (object instanceof Recording) {
menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
} else if (object instanceof OsmPoint) {
menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
} else if (object instanceof WptPt) {
menuController = WptPtMenuController.getInstance(mapActivity, pointDescription, (WptPt) object);
} else if (object instanceof DownloadMapObject) {
menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
} else if (object instanceof OpenStreetNote) {
menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
} else if (object instanceof GpxDisplayItem) {
menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
} else if (object instanceof MapMarker) {
menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
} else if (object instanceof TransportStopRoute) {
menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
} else if (object instanceof TransportStop) {
menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
} else if (object instanceof AidlMapPointWrapper) {
menuController = new AMapPointMenuController(mapActivity, pointDescription, (AidlMapPointWrapper) object);
} else if (object instanceof LatLon) {
if (pointDescription.isMyLocation()) {
menuController = new MyLocationMenuController(mapActivity, pointDescription);
}
} 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) {
menuController = new MapillaryMenuController(mapActivity, pointDescription, (MapillaryImage) object);
} else if (object instanceof SelectedGpxPoint) {
menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) object);
} else if (object instanceof Pair && ((Pair<?, ?>) object).second instanceof SelectedGpxPoint) {
menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) ((Pair<?, ?>) object).second);
}
}
if (menuController == null) {
menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
}
menuController.menuType = menuType;
menuController.setLatLon(latLon);
menuController.onCreated();
return menuController;
}
use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.
the class SettingsHelper method getMyPlacesItems.
private Map<ExportSettingsType, List<?>> getMyPlacesItems(@Nullable List<ExportSettingsType> settingsTypes, boolean addEmptyItems) {
Map<ExportSettingsType, List<?>> myPlacesItems = new LinkedHashMap<>();
List<FavoriteGroup> favoriteGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.FAVORITES) ? app.getFavoritesHelper().getFavoriteGroups() : Collections.emptyList();
if (!favoriteGroups.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.FAVORITES, favoriteGroups);
}
List<GpxDataItem> gpxItems = settingsTypes == null || settingsTypes.contains(ExportSettingsType.TRACKS) ? app.getGpxDbHelper().getItems() : Collections.emptyList();
if (!gpxItems.isEmpty() || addEmptyItems) {
List<File> files = new ArrayList<>();
for (GpxDataItem gpxItem : gpxItems) {
File file = gpxItem.getFile();
if (file.exists() && !file.isDirectory()) {
files.add(file);
}
}
if (!files.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.TRACKS, files);
}
}
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getActivePlugin(OsmEditingPlugin.class);
if (osmEditingPlugin != null) {
List<OsmNotesPoint> notesPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_NOTES) ? osmEditingPlugin.getDBBug().getOsmbugsPoints() : Collections.emptyList();
if (!notesPointList.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.OSM_NOTES, notesPointList);
}
List<OpenstreetmapPoint> editsPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_EDITS) ? osmEditingPlugin.getDBPOI().getOpenstreetmapPoints() : Collections.emptyList();
if (!editsPointList.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.OSM_EDITS, editsPointList);
}
}
AudioVideoNotesPlugin avNotesPlugin = OsmandPlugin.getActivePlugin(AudioVideoNotesPlugin.class);
if (avNotesPlugin != null) {
List<File> files = new ArrayList<>();
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.MULTIMEDIA_NOTES)) {
for (Recording rec : avNotesPlugin.getAllRecordings()) {
File file = rec.getFile();
if (file != null && file.exists()) {
files.add(file);
}
}
}
if (!files.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.MULTIMEDIA_NOTES, files);
}
}
List<MapMarker> mapMarkers = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ACTIVE_MARKERS) ? app.getMapMarkersHelper().getMapMarkers() : Collections.emptyList();
if (!mapMarkers.isEmpty() || addEmptyItems) {
String name = app.getString(R.string.map_markers);
String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
markersGroup.setMarkers(mapMarkers);
myPlacesItems.put(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup));
}
List<MapMarker> markersHistory = settingsTypes == null || settingsTypes.contains(ExportSettingsType.HISTORY_MARKERS) ? app.getMapMarkersHelper().getMapMarkersHistory() : Collections.emptyList();
if (!markersHistory.isEmpty() || addEmptyItems) {
String name = app.getString(R.string.shared_string_history);
String groupId = ExportSettingsType.HISTORY_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
markersGroup.setMarkers(markersHistory);
myPlacesItems.put(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup));
}
List<HistoryEntry> historyEntries = settingsTypes == null || settingsTypes.contains(ExportSettingsType.SEARCH_HISTORY) ? SearchHistoryHelper.getInstance(app).getHistoryEntries(false) : Collections.emptyList();
if (!historyEntries.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
}
List<MapMarkersGroup> markersGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ITINERARY_GROUPS) ? app.getMapMarkersHelper().getVisibleMapMarkersGroups() : Collections.emptyList();
if (!markersGroups.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.ITINERARY_GROUPS, markersGroups);
}
return myPlacesItems;
}
Aggregations