diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java index f7d21c7792c..438ba0d2034 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java @@ -6,6 +6,7 @@ import static net.osmand.osm.MapPoiTypes.ROUTE_ARTICLE; import static net.osmand.osm.MapPoiTypes.ROUTE_ARTICLE_POINT; import static net.osmand.osm.MapPoiTypes.ROUTE_TRACK; +import static net.osmand.osm.MapPoiTypes.ROUTE_TRACK_POINT; import net.osmand.Location; import net.osmand.binary.BinaryMapIndexReader.TagValuePair; @@ -571,6 +572,10 @@ public boolean isRouteTrack() { return subType != null && (subType.equals(ROUTE_TRACK) || subType.startsWith(ROUTES_PREFIX)); } + public boolean isRoutePoint() { + return subType != null && (subType.equals(ROUTE_TRACK_POINT) || subType.equals(ROUTE_ARTICLE_POINT)); + } + public JSONObject toJSON() { JSONObject json = super.toJSON(); json.put("subType", subType); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java b/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java index 32fc98ef436..7f4690ba4db 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapSelectionHelper.java @@ -2,11 +2,13 @@ import static net.osmand.IndexConstants.GPX_FILE_EXT; import static net.osmand.binary.BinaryMapIndexReader.ACCEPT_ALL_POI_TYPE_FILTER; +import static net.osmand.data.Amenity.ROUTE; import static net.osmand.data.Amenity.ROUTE_ID; import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE; import static net.osmand.data.MapObject.AMENITY_ID_RIGHT_SHIFT; import static net.osmand.osm.OsmRouteType.HIKING; import static net.osmand.plus.transport.TransportLinesMenu.RENDERING_CATEGORY_TRANSPORT; +import static net.osmand.plus.wikivoyage.data.TravelGpx.TRAVEL_OSM_ID_TAG; import static net.osmand.render.RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN; import static net.osmand.router.network.NetworkRouteSelector.NetworkRouteSelectorFilter; import static net.osmand.router.network.NetworkRouteSelector.RouteKey; @@ -357,7 +359,7 @@ private void selectObjectsFromOpenGl(@NonNull MapSelectionResult result, @NonNul latLon = l == null ? latLon : l; tags.remove(TAG_POI_LAT_LON); } - amenity = getAmenity(latLon, obfMapObject); + amenity = getAmenity(latLon, obfMapObject, tags); if (amenity != null) { amenity.setMapIconName(getMapIconName(symbolInfo)); } else if (!isOsmRoute && !isTravelGpx) { @@ -438,13 +440,16 @@ private RasterMapSymbol getRasterMapSymbol(@NonNull MapSymbolInformation symbolI return null; } - private Amenity getAmenity(LatLon latLon, ObfMapObject obfMapObject) { + private Amenity getAmenity(LatLon latLon, ObfMapObject obfMapObject, Map tags) { Amenity amenity; List names = getValues(obfMapObject.getCaptionsInAllLanguages()); String caption = obfMapObject.getCaptionInNativeLanguage(); if (!caption.isEmpty()) { names.add(caption); } + if (!Algorithms.isEmpty(tags) && tags.containsKey(TRAVEL_OSM_ID_TAG) && "point".equals(tags.get(ROUTE))) { + names.add(tags.get(TRAVEL_OSM_ID_TAG)); // additional attribute for TravelGpx points (osm_id) + } long id = obfMapObject.getId().getId().longValue(); amenity = findAmenity(app, latLon, names, id); if (amenity != null && obfMapObject.getPoints31().size() > 1) { @@ -711,10 +716,14 @@ public static Amenity findAmenityByOsmId(@NonNull List amenities, long public static Amenity findAmenityByName(@NonNull List amenities, @Nullable List names) { if (!Algorithms.isEmpty(names)) { for (Amenity amenity : amenities) { + String travelOsmId = amenity.isRoutePoint() ? amenity.getAdditionalInfo(TRAVEL_OSM_ID_TAG) : null; for (String name : names) { if (name.equals(amenity.getName()) && !amenity.isClosed()) { return amenity; } + if (travelOsmId != null && name.equals(travelOsmId)) { + return amenity; + } } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java index 20ff2a5ba3c..cac34ab8af6 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java @@ -32,6 +32,7 @@ public class TravelGpx extends TravelArticle { public static final String ROUTE_RADIUS = "route_radius"; public static final String USER = "user"; public static final String ACTIVITY_TYPE = "route_activity_type"; + public static final String TRAVEL_OSM_ID_TAG = "osm_id"; public String user; public String activityType;