diff --git a/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayReaderTask.java b/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayAsyncTask.java similarity index 71% rename from OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayReaderTask.java rename to OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayAsyncTask.java index 03f22e4bc5a..e6a82af765c 100644 --- a/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayReaderTask.java +++ b/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayAsyncTask.java @@ -6,15 +6,15 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseLoadAsyncTask; -public class ClickableWayReaderTask extends BaseLoadAsyncTask { +public class ClickableWayAsyncTask extends BaseLoadAsyncTask { private final ClickableWay clickableWay; private final CallbackWithObject readHeightData; private final CallbackWithObject openAsGpxFile; - public ClickableWayReaderTask(@NonNull MapActivity mapActivity, - @NonNull ClickableWay clickableWay, - @NonNull CallbackWithObject readHeightData, - @NonNull CallbackWithObject openAsGpxFile) { + public ClickableWayAsyncTask(@NonNull MapActivity mapActivity, + @NonNull ClickableWay clickableWay, + @NonNull CallbackWithObject readHeightData, + @NonNull CallbackWithObject openAsGpxFile) { super(mapActivity); this.clickableWay = clickableWay; this.readHeightData = readHeightData; diff --git a/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayLoader.java b/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayHelper.java similarity index 86% rename from OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayLoader.java rename to OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayHelper.java index 553bb674853..27e7162517d 100644 --- a/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayLoader.java +++ b/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayHelper.java @@ -40,7 +40,7 @@ import gnu.trove.list.array.TIntArrayList; -public class ClickableWayLoader { +public class ClickableWayHelper { public static final Set clickableTags = Set.of("piste:type", "piste:difficulty", "mtb:scale", "dirtbike:scale"); public static final Map forbiddenTags = Map.of("area", "yes", "access", "no"); public static final Map gpxColors = Map.ofEntries( @@ -62,12 +62,14 @@ public class ClickableWayLoader { private final OsmandApplication app; private final OsmandMapTileView view; - private final ClickableWayActivator activator; + private final ClickableWayMenuActivator activator; - public ClickableWayLoader(@NonNull OsmandApplication app, @NonNull OsmandMapTileView view) { +// private static final Log log = PlatformUtil.getLog(ClickableWay.class); + + public ClickableWayHelper(@NonNull OsmandApplication app, @NonNull OsmandMapTileView view) { this.app = app; this.view = view; - this.activator = new ClickableWayActivator(view, this::readHeightData, this::openAsGpxFile); + this.activator = new ClickableWayMenuActivator(view, this::readHeightData, this::openAsGpxFile); } @NonNull @@ -194,6 +196,22 @@ private boolean isClickableWayTags(@NonNull Map tags) { private boolean readHeightData(ClickableWay clickableWay) { // TODO read height data, implement simple cache +// BinaryMapIndexReader[] readers = app.getResourceManager().getReverseGeocodingMapFiles(); +// NetworkRouteSelector.NetworkRouteSelectorFilter selectorFilter = new NetworkRouteSelector.NetworkRouteSelectorFilter(); +// NetworkRouteSelector routeSelector = new NetworkRouteSelector(readers, selectorFilter, null); +// try { +// QuadRect bbox31 = clickableWay.getBbox(); +// QuadRect bboxLatLon = new QuadRect( +// MapUtils.get31LongitudeX((int)bbox31.left), +// MapUtils.get31LatitudeY((int)bbox31.top), +// MapUtils.get31LongitudeX((int)bbox31.right), +// MapUtils.get31LatitudeY((int)bbox31.bottom) +// ); +// Map routes = routeSelector.getRoutes(bboxLatLon, true, null); +// System.err.printf("XXX routes\n"); +// } catch (IOException e) { +// log.error(e); +// } return true; } diff --git a/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayActivator.java b/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayMenuActivator.java similarity index 81% rename from OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayActivator.java rename to OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayMenuActivator.java index 64d06d0e618..af890eb5640 100644 --- a/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayActivator.java +++ b/OsmAnd/src/net/osmand/plus/track/clickable/ClickableWayMenuActivator.java @@ -17,14 +17,14 @@ import java.util.List; -public class ClickableWayActivator implements ContextMenuLayer.IContextMenuProvider { +public class ClickableWayMenuActivator implements ContextMenuLayer.IContextMenuProvider { private final OsmandMapTileView view; private final CallbackWithObject readHeights; private final CallbackWithObject openAsGpxFile; - public ClickableWayActivator(@NonNull OsmandMapTileView view, - @NonNull CallbackWithObject readHeightData, - @NonNull CallbackWithObject openAsGpxFile) { + public ClickableWayMenuActivator(@NonNull OsmandMapTileView view, + @NonNull CallbackWithObject readHeightData, + @NonNull CallbackWithObject openAsGpxFile) { this.view = view; this.readHeights = readHeightData; this.openAsGpxFile = openAsGpxFile; @@ -36,7 +36,7 @@ public boolean showMenuAction(@Nullable Object object) { if (object instanceof ClickableWay that) { MapActivity mapActivity = view.getMapActivity(); if (mapActivity != null) { - (new ClickableWayReaderTask(mapActivity, that, readHeights, openAsGpxFile)) + (new ClickableWayAsyncTask(mapActivity, that, readHeights, openAsGpxFile)) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java b/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java index 584cd68e4cf..8410af84c93 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java @@ -77,7 +77,7 @@ import net.osmand.util.Algorithms; import net.osmand.util.GeoParsedPoint; import net.osmand.util.MapUtils; -import net.osmand.plus.track.clickable.ClickableWayLoader; +import net.osmand.plus.track.clickable.ClickableWayHelper; import org.apache.commons.logging.Log; @@ -108,13 +108,13 @@ public class MapSelectionHelper { private Map touchedFullMapObjects = new HashMap<>(); private Map touchedSmallMapObjects = new HashMap<>(); - private ClickableWayLoader clickableWayLoader; + private ClickableWayHelper clickableWayHelper; public MapSelectionHelper(@NonNull Context context) { app = (OsmandApplication) context.getApplicationContext(); view = app.getOsmandMap().getMapView(); mapLayers = app.getOsmandMap().getMapLayers(); - clickableWayLoader = new ClickableWayLoader(app, view); + clickableWayHelper = new ClickableWayHelper(app, view); } @NonNull @@ -232,7 +232,7 @@ private void selectObjectsFromNative(@NonNull MapSelectionResult result, @NonNul boolean isTravelGpx = !Algorithms.isEmpty(travelGpxFilter); boolean isOsmRoute = !Algorithms.isEmpty(OsmRouteType.getRouteKeys(tags)); - boolean isClickableWay = clickableWayLoader.isClickableWayV1(renderedObject); + boolean isClickableWay = clickableWayHelper.isClickableWayV1(renderedObject); if (!isClickableWay && !isTravelGpx && !isOsmRoute && (renderedObject.getId() == null || !renderedObject.isVisible() || renderedObject.isDrawOnPath())) { @@ -350,7 +350,7 @@ private void selectObjectsFromOpenGl(@NonNull MapSelectionResult result, @NonNul boolean isTravelGpx = app.getTravelHelper().isTravelGpxTags(tags); boolean isOsmRoute = !Algorithms.isEmpty(OsmRouteType.getRouteKeys(tags)); - boolean isClickableWay = clickableWayLoader.isClickableWayV2(obfMapObject, tags); + boolean isClickableWay = clickableWayHelper.isClickableWayV2(obfMapObject, tags); if (isOsmRoute && !isDerivedGpxSelected) { NetworkRouteSelectorFilter routeFilter = createRouteFilter(); @@ -491,9 +491,9 @@ private boolean addTravelGpx(@NonNull MapSelectionResult result, @Nullable Strin } private boolean addClickableWayV1(@NonNull MapSelectionResult result, @NonNull RenderedObject renderedObject) { - ClickableWay clickableWay = clickableWayLoader.loadClickableWayV1(result.pointLatLon, renderedObject); + ClickableWay clickableWay = clickableWayHelper.loadClickableWayV1(result.pointLatLon, renderedObject); if (clickableWay != null && isUniqueClickableWay(result.selectedObjects, clickableWay)) { - result.selectedObjects.put(clickableWay, clickableWayLoader.getContextMenuProvider()); + result.selectedObjects.put(clickableWay, clickableWayHelper.getContextMenuProvider()); return true; } return false; @@ -501,9 +501,9 @@ private boolean addClickableWayV1(@NonNull MapSelectionResult result, @NonNull R private boolean addClickableWayV2(@NonNull MapSelectionResult result, @NonNull ObfMapObject obfMapObject, @NonNull Map tags) { - ClickableWay clickableWay = clickableWayLoader.loadClickableWayV2(result.pointLatLon, obfMapObject, tags); + ClickableWay clickableWay = clickableWayHelper.loadClickableWayV2(result.pointLatLon, obfMapObject, tags); if (clickableWay != null && isUniqueClickableWay(result.selectedObjects, clickableWay)) { - result.selectedObjects.put(clickableWay, clickableWayLoader.getContextMenuProvider()); + result.selectedObjects.put(clickableWay, clickableWayHelper.getContextMenuProvider()); return true; } return false;