Search in sources :

Example 1 with SelectedGpxPoint

use of net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint 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;
}
Also used : TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) WptPt(net.osmand.GPXUtilities.WptPt) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) TransportStopController(net.osmand.plus.mapcontextmenu.controllers.TransportStopController) FavouritePoint(net.osmand.data.FavouritePoint) MapMarker(net.osmand.plus.mapmarkers.MapMarker) MapillaryImage(net.osmand.plus.plugins.mapillary.MapillaryImage) AvoidSpecificRoads(net.osmand.plus.helpers.AvoidSpecificRoads) ParkingPositionMenuController(net.osmand.plus.plugins.parking.ParkingPositionMenuController) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) EditPOIMenuController(net.osmand.plus.plugins.osmedit.menu.EditPOIMenuController) TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) TransportStop(net.osmand.data.TransportStop) Pair(android.util.Pair) Amenity(net.osmand.data.Amenity) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) AudioVideoNoteMenuController(net.osmand.plus.plugins.audionotes.AudioVideoNoteMenuController) OsmBugMenuController(net.osmand.plus.plugins.osmedit.menu.OsmBugMenuController) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) TransportRouteController(net.osmand.plus.mapcontextmenu.controllers.TransportRouteController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) DownloadMapObject(net.osmand.plus.views.layers.DownloadedRegionsLayer.DownloadMapObject) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) EditPOIMenuController(net.osmand.plus.plugins.osmedit.menu.EditPOIMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) WptPtMenuController(net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController) MapillaryMenuController(net.osmand.plus.plugins.mapillary.MapillaryMenuController) AudioVideoNoteMenuController(net.osmand.plus.plugins.audionotes.AudioVideoNoteMenuController) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) OsmBugMenuController(net.osmand.plus.plugins.osmedit.menu.OsmBugMenuController) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) ParkingPositionMenuController(net.osmand.plus.plugins.parking.ParkingPositionMenuController) TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) SelectedGpxMenuController(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) SelectedGpxMenuController(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController) LatLon(net.osmand.data.LatLon) RenderedObject(net.osmand.NativeLibrary.RenderedObject) OpenStreetNote(net.osmand.plus.plugins.osmedit.OsmBugsLayer.OpenStreetNote) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) MapillaryMenuController(net.osmand.plus.plugins.mapillary.MapillaryMenuController)

Example 2 with SelectedGpxPoint

use of net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint in project Osmand by osmandapp.

the class GPXLayer method showMenuAction.

@Override
public boolean showMenuAction(@Nullable Object object) {
    OsmandApplication app = view.getApplication();
    MapActivity mapActivity = view.getMapActivity();
    if (mapActivity != null) {
        if (object instanceof Pair && ((Pair<?, ?>) object).first instanceof TravelGpx && ((Pair<?, ?>) object).second instanceof SelectedGpxPoint) {
            Pair<TravelGpx, SelectedGpxPoint> pair = (Pair) object;
            LatLon latLon = new LatLon(pair.second.getSelectedPoint().lat, pair.second.getSelectedPoint().lon);
            TravelHelper travelHelper = app.getTravelHelper();
            travelHelper.openTrackMenu(pair.first, mapActivity, pair.first.getRouteId(), latLon);
            return true;
        } else if (object instanceof SelectedGpxPoint) {
            SelectedGpxPoint selectedGpxPoint = (SelectedGpxPoint) object;
            if (selectedGpxPoint.shouldShowTrackPointMenu()) {
                WptPt selectedWptPt = selectedGpxPoint.getSelectedPoint();
                LatLon latLon = new LatLon(selectedWptPt.lat, selectedWptPt.lon);
                contextMenuLayer.showContextMenu(latLon, getObjectName(selectedGpxPoint), selectedGpxPoint, null);
            } else {
                SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
                TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, selectedGpxPoint);
            }
            return true;
        }
    }
    return false;
}
Also used : TravelGpx(net.osmand.plus.wikivoyage.data.TravelGpx) LatLon(net.osmand.data.LatLon) WptPt(net.osmand.GPXUtilities.WptPt) OsmandApplication(net.osmand.plus.OsmandApplication) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) MapActivity(net.osmand.plus.activities.MapActivity) Pair(android.util.Pair) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper)

Example 3 with SelectedGpxPoint

use of net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint in project Osmand by osmandapp.

the class GPXLayer method createSelectedGpxPoint.

private SelectedGpxPoint createSelectedGpxPoint(SelectedGpxFile selectedGpxFile, WptPt prevPoint, WptPt nextPoint, LatLon latLon, boolean showTrackPointMenu) {
    WptPt projectionPoint = createProjectionPoint(prevPoint, nextPoint, latLon);
    Location prevPointLocation = new Location("");
    prevPointLocation.setLatitude(prevPoint.lat);
    prevPointLocation.setLongitude(prevPoint.lon);
    Location nextPointLocation = new Location("");
    nextPointLocation.setLatitude(nextPoint.lat);
    nextPointLocation.setLongitude(nextPoint.lon);
    float bearing = prevPointLocation.bearingTo(nextPointLocation);
    return new SelectedGpxPoint(selectedGpxFile, projectionPoint, prevPoint, nextPoint, bearing, showTrackPointMenu);
}
Also used : WptPt(net.osmand.GPXUtilities.WptPt) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) Location(net.osmand.Location)

Example 4 with SelectedGpxPoint

use of net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint in project Osmand by osmandapp.

the class ContextMenuLayer method showContextMenu.

private boolean showContextMenu(PointF point, RotatedTileBox tileBox, boolean showUnknownLocation) {
    if (menu == null || mAddGpxPointBottomSheetHelper == null) {
        return false;
    }
    LatLon objectLatLon = null;
    Map<Object, IContextMenuProvider> selectedObjects = selectObjectsForContextMenu(tileBox, point, false, showUnknownLocation);
    NativeOsmandLibrary nativeLib = NativeOsmandLibrary.getLoadedLibrary();
    LatLon pointLatLon = tileBox.getLatLonFromPixel(point.x, point.y);
    OsmandApplication app = getApplication();
    IContextMenuProvider poiMenuProvider = app.getOsmandMap().getMapLayers().getPoiMapLayer();
    IContextMenuProvider gpxMenuProvider = app.getOsmandMap().getMapLayers().getGpxLayer();
    if (app.getSettings().USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) {
        MapRendererView rendererView = view.getMapRenderer();
        if (rendererView != null) {
            int delta = 20;
            PointI tl = new PointI((int) point.x - delta, (int) point.y - delta);
            PointI br = new PointI((int) point.x + delta, (int) point.y + delta);
            MapSymbolInformationList symbols = rendererView.getSymbolsIn(new AreaI(tl, br), false);
            for (int i = 0; i < symbols.size(); i++) {
                MapSymbolInformation symbolInfo = symbols.get(i);
                IBillboardMapSymbol billboardMapSymbol;
                try {
                    billboardMapSymbol = IBillboardMapSymbol.dynamic_pointer_cast(symbolInfo.getMapSymbol());
                } catch (Exception eBillboard) {
                    billboardMapSymbol = null;
                }
                if (billboardMapSymbol != null) {
                    double lat = Utilities.get31LatitudeY(billboardMapSymbol.getPosition31().getY());
                    double lon = Utilities.get31LongitudeX(billboardMapSymbol.getPosition31().getX());
                    objectLatLon = new LatLon(lat, lon);
                    AdditionalBillboardSymbolInstanceParameters billboardAdditionalParams;
                    try {
                        billboardAdditionalParams = AdditionalBillboardSymbolInstanceParameters.dynamic_pointer_cast(symbolInfo.getInstanceParameters());
                    } catch (Exception eBillboardParams) {
                        billboardAdditionalParams = null;
                    }
                    if (billboardAdditionalParams != null && billboardAdditionalParams.getOverridesPosition31()) {
                        lat = Utilities.get31LatitudeY(billboardAdditionalParams.getPosition31().getY());
                        lon = Utilities.get31LongitudeX(billboardAdditionalParams.getPosition31().getX());
                        objectLatLon = new LatLon(lat, lon);
                    }
                    Amenity amenity = null;
                    net.osmand.core.jni.Amenity jniAmenity;
                    try {
                        jniAmenity = AmenitySymbolsGroup.dynamic_cast(symbolInfo.getMapSymbol().getGroupPtr()).getAmenity();
                    } catch (Exception eAmenity) {
                        jniAmenity = null;
                    }
                    if (jniAmenity != null) {
                        List<String> names = getValues(jniAmenity.getLocalizedNames());
                        names.add(jniAmenity.getNativeName());
                        long id = jniAmenity.getId().getId().longValue() >> 7;
                        amenity = findAmenity(app, id, names, objectLatLon, AMENITY_SEARCH_RADIUS);
                    } else {
                        MapObject mapObject;
                        try {
                            mapObject = MapObjectSymbolsGroup.dynamic_cast(symbolInfo.getMapSymbol().getGroupPtr()).getMapObject();
                        } catch (Exception eMapObject) {
                            mapObject = null;
                        }
                        if (mapObject != null) {
                            ObfMapObject obfMapObject;
                            try {
                                obfMapObject = ObfMapObject.dynamic_pointer_cast(mapObject);
                            } catch (Exception eObfMapObject) {
                                obfMapObject = null;
                            }
                            if (obfMapObject != null) {
                                List<String> names = getValues(obfMapObject.getCaptionsInAllLanguages());
                                names.add(obfMapObject.getCaptionInNativeLanguage());
                                long id = obfMapObject.getId().getId().longValue() >> 7;
                                amenity = findAmenity(app, id, names, objectLatLon, AMENITY_SEARCH_RADIUS);
                            }
                        }
                    }
                    if (amenity != null && isUniqueAmenity(selectedObjects.keySet(), amenity)) {
                        selectedObjects.put(amenity, poiMenuProvider);
                    }
                }
            }
        }
    } else if (nativeLib != null) {
        MapRenderRepositories maps = app.getResourceManager().getRenderer();
        RenderingContext rc = maps.getVisibleRenderingContext();
        RenderedObject[] renderedObjects = null;
        if (rc != null && rc.zoom == tileBox.getZoom()) {
            double sinRotate = Math.sin(Math.toRadians(rc.rotate - tileBox.getRotate()));
            double cosRotate = Math.cos(Math.toRadians(rc.rotate - tileBox.getRotate()));
            float x = tileBox.getPixXFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor));
            float y = tileBox.getPixYFrom31((int) (rc.leftX * rc.tileDivisor), (int) (rc.topY * rc.tileDivisor));
            float dx = point.x - x;
            float dy = point.y - y;
            int coordX = (int) (dx * cosRotate - dy * sinRotate);
            int coordY = (int) (dy * cosRotate + dx * sinRotate);
            renderedObjects = nativeLib.searchRenderedObjectsFromContext(rc, coordX, coordY, true);
        }
        if (renderedObjects != null) {
            int TILE_SIZE = 256;
            double cosRotateTileSize = Math.cos(Math.toRadians(rc.rotate)) * TILE_SIZE;
            double sinRotateTileSize = Math.sin(Math.toRadians(rc.rotate)) * TILE_SIZE;
            for (RenderedObject renderedObject : renderedObjects) {
                String routeID = renderedObject.getRouteID();
                String fileName = renderedObject.getGpxFileName();
                String filter = routeID != null ? routeID : fileName;
                boolean isGpx = !Algorithms.isEmpty(filter);
                if (!isGpx && (renderedObject.getId() == null || !renderedObject.isVisible() || renderedObject.isDrawOnPath())) {
                    continue;
                }
                if (renderedObject.getLabelX() != 0 && renderedObject.getLabelY() != 0) {
                    double lat = MapUtils.get31LatitudeY(renderedObject.getLabelY());
                    double lon = MapUtils.get31LongitudeX(renderedObject.getLabelX());
                    renderedObject.setLabelLatLon(new LatLon(lat, lon));
                } else {
                    double cx = renderedObject.getBbox().centerX();
                    double cy = renderedObject.getBbox().centerY();
                    double dTileX = (cx * cosRotateTileSize + cy * sinRotateTileSize) / (TILE_SIZE * TILE_SIZE);
                    double dTileY = (cy * cosRotateTileSize - cx * sinRotateTileSize) / (TILE_SIZE * TILE_SIZE);
                    int x31 = (int) ((dTileX + rc.leftX) * rc.tileDivisor);
                    int y31 = (int) ((dTileY + rc.topY) * rc.tileDivisor);
                    double lat = MapUtils.get31LatitudeY(y31);
                    double lon = MapUtils.get31LongitudeX(x31);
                    renderedObject.setLabelLatLon(new LatLon(lat, lon));
                }
                if (renderedObject.getX() != null && renderedObject.getX().size() == 1 && renderedObject.getY() != null && renderedObject.getY().size() == 1) {
                    objectLatLon = new LatLon(MapUtils.get31LatitudeY(renderedObject.getY().get(0)), MapUtils.get31LongitudeX(renderedObject.getX().get(0)));
                } else if (renderedObject.getLabelLatLon() != null) {
                    objectLatLon = renderedObject.getLabelLatLon();
                }
                LatLon searchLatLon = objectLatLon != null ? objectLatLon : pointLatLon;
                if (isGpx) {
                    TravelGpx travelGpx = app.getTravelHelper().searchGpx(pointLatLon, filter, renderedObject.getTagValue("ref"));
                    if (travelGpx != null && isUniqueGpx(selectedObjects, travelGpx)) {
                        WptPt selectedPoint = new WptPt();
                        selectedPoint.lat = pointLatLon.getLatitude();
                        selectedPoint.lon = pointLatLon.getLongitude();
                        SelectedGpxPoint selectedGpxPoint = new SelectedGpxPoint(null, selectedPoint);
                        selectedObjects.put(new Pair<>(travelGpx, selectedGpxPoint), gpxMenuProvider);
                    }
                } else {
                    Amenity amenity = findAmenity(app, renderedObject.getId() >> 7, renderedObject.getOriginalNames(), searchLatLon, AMENITY_SEARCH_RADIUS);
                    if (amenity != null) {
                        if (renderedObject.getX() != null && renderedObject.getX().size() > 1 && renderedObject.getY() != null && renderedObject.getY().size() > 1) {
                            amenity.getX().addAll(renderedObject.getX());
                            amenity.getY().addAll(renderedObject.getY());
                        }
                        if (isUniqueAmenity(selectedObjects.keySet(), amenity)) {
                            selectedObjects.put(amenity, poiMenuProvider);
                        }
                    } else {
                        selectedObjects.put(renderedObject, null);
                    }
                }
            }
        }
    }
    for (Map.Entry<Object, IContextMenuProvider> entry : selectedObjects.entrySet()) {
        IContextMenuProvider provider = entry.getValue();
        if (provider != null && provider.runExclusiveAction(entry.getKey(), showUnknownLocation)) {
            return true;
        }
    }
    processTransportStops(selectedObjects);
    if (selectedObjects.size() == 1) {
        Object selectedObj = selectedObjects.keySet().iterator().next();
        LatLon latLon = objectLatLon;
        PointDescription pointDescription = null;
        final IContextMenuProvider provider = selectedObjects.get(selectedObj);
        if (provider != null) {
            if (latLon == null) {
                latLon = provider.getObjectLocation(selectedObj);
            }
            pointDescription = provider.getObjectName(selectedObj);
        }
        if (latLon == null) {
            latLon = pointLatLon;
        }
        if (mInAddGpxPointMode) {
            String title = pointDescription == null ? "" : pointDescription.getName();
            mAddGpxPointBottomSheetHelper.setTitle(title);
            view.getAnimatedDraggingThread().startMoving(latLon.getLatitude(), latLon.getLongitude(), view.getZoom(), true);
        } else {
            showContextMenu(latLon, pointDescription, selectedObj, provider);
        }
        return true;
    } else if (selectedObjects.size() > 1) {
        showContextMenuForSelectedObjects(pointLatLon, selectedObjects);
        return true;
    } else if (showUnknownLocation) {
        hideVisibleMenues();
        selectedObjectContextMenuProvider = null;
        getApplication().getMapViewTrackingUtilities().setMapLinkedToLocation(false);
        if (mInAddGpxPointMode) {
            mAddGpxPointBottomSheetHelper.setTitle("");
            view.getAnimatedDraggingThread().startMoving(pointLatLon.getLatitude(), pointLatLon.getLongitude(), view.getZoom(), true);
        } else {
            menu.show(pointLatLon, null, null);
        }
        return true;
    }
    return false;
}
Also used : ObfMapObject(net.osmand.core.jni.ObfMapObject) TravelGpx(net.osmand.plus.wikivoyage.data.TravelGpx) WptPt(net.osmand.GPXUtilities.WptPt) OsmandApplication(net.osmand.plus.OsmandApplication) MapRendererView(net.osmand.core.android.MapRendererView) PointI(net.osmand.core.jni.PointI) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) IBillboardMapSymbol(net.osmand.core.jni.IBillboardMapSymbol) MapRenderRepositories(net.osmand.plus.render.MapRenderRepositories) ObfMapObject(net.osmand.core.jni.ObfMapObject) MapObject(net.osmand.core.jni.MapObject) Pair(android.util.Pair) Amenity(net.osmand.data.Amenity) RenderingContext(net.osmand.RenderingContext) AdditionalBillboardSymbolInstanceParameters(net.osmand.core.jni.MapSymbolsGroup.AdditionalBillboardSymbolInstanceParameters) Paint(android.graphics.Paint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) FavouritePoint(net.osmand.data.FavouritePoint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) MapSymbolInformationList(net.osmand.core.jni.MapSymbolInformationList) LatLon(net.osmand.data.LatLon) MapSymbolInformation(net.osmand.core.jni.IMapRenderer.MapSymbolInformation) RenderedObject(net.osmand.NativeLibrary.RenderedObject) AreaI(net.osmand.core.jni.AreaI) PointDescription(net.osmand.data.PointDescription) NativeOsmandLibrary(net.osmand.plus.render.NativeOsmandLibrary) ObfMapObject(net.osmand.core.jni.ObfMapObject) CallbackWithObject(net.osmand.CallbackWithObject) RenderedObject(net.osmand.NativeLibrary.RenderedObject) MapObject(net.osmand.core.jni.MapObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with SelectedGpxPoint

use of net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint in project Osmand by osmandapp.

the class GPXLayer method onLongPressEvent.

@Override
public boolean onLongPressEvent(PointF point, RotatedTileBox tileBox) {
    if (tileBox.getZoom() >= START_ZOOM) {
        List<Object> trackPoints = new ArrayList<>();
        getTracksFromPoint(tileBox, point, trackPoints, true);
        if (!Algorithms.isEmpty(trackPoints)) {
            LatLon latLon = tileBox.getLatLonFromPixel(point.x, point.y);
            if (trackPoints.size() == 1) {
                SelectedGpxPoint gpxPoint = (SelectedGpxPoint) trackPoints.get(0);
                contextMenuLayer.showContextMenu(latLon, getObjectName(gpxPoint), gpxPoint, null);
            } else if (trackPoints.size() > 1) {
                Map<Object, IContextMenuProvider> selectedObjects = new HashMap<>();
                for (Object object : trackPoints) {
                    selectedObjects.put(object, this);
                }
                contextMenuLayer.showContextMenuForSelectedObjects(latLon, selectedObjects);
            }
            return true;
        }
    }
    return false;
}
Also used : LatLon(net.osmand.data.LatLon) ArrayList(java.util.ArrayList) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

SelectedGpxPoint (net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)5 WptPt (net.osmand.GPXUtilities.WptPt)4 LatLon (net.osmand.data.LatLon)4 Pair (android.util.Pair)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 RenderedObject (net.osmand.NativeLibrary.RenderedObject)2 Amenity (net.osmand.data.Amenity)2 FavouritePoint (net.osmand.data.FavouritePoint)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 Paint (android.graphics.Paint)1 ArrayList (java.util.ArrayList)1 CallbackWithObject (net.osmand.CallbackWithObject)1 Location (net.osmand.Location)1 RenderingContext (net.osmand.RenderingContext)1 AidlMapPointWrapper (net.osmand.aidl.AidlMapPointWrapper)1 MapRendererView (net.osmand.core.android.MapRendererView)1 AreaI (net.osmand.core.jni.AreaI)1 IBillboardMapSymbol (net.osmand.core.jni.IBillboardMapSymbol)1 MapSymbolInformation (net.osmand.core.jni.IMapRenderer.MapSymbolInformation)1