diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java index 2386764e9f..b37c9ccd3f 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapRouteReaderAdapter.java @@ -234,7 +234,7 @@ public class BinaryMapRouteReaderAdapter { refTypeRule = id; } else if (tags.equals("destination") || tags.equals("destination:forward") || tags.equals("destination:backward")) { destinationTypeRule = id; - } else if (tags.equals("destination:ref")) { + } else if (tags.equals("destination:ref") || tags.equals("destination:ref:forward") || tags.equals("destination:ref:backward")) { destinationRefTypeRule = id; } } diff --git a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java index 5696118545..598e428444 100644 --- a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java +++ b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java @@ -173,14 +173,14 @@ public class GeocodingUtilities { continue; } // System.out.println(road.toString() + " " + Math.sqrt(p.distSquare)); - boolean emptyName = Algorithms.isEmpty(road.getName()) && Algorithms.isEmpty(road.getRef()); + boolean emptyName = Algorithms.isEmpty(road.getName()) && Algorithms.isEmpty(road.getRef(true)); if (!emptyName) { if (distSquare == 0 || distSquare > p.distSquare) { distSquare = p.distSquare; } GeocodingResult sr = new GeocodingResult(); sr.searchPoint = new LatLon(lat, lon); - sr.streetName = Algorithms.isEmpty(road.getName()) ? road.getRef() : road.getName(); + sr.streetName = Algorithms.isEmpty(road.getName()) ? road.getRef(true) : road.getName(); sr.point = p; sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX)); sr.regionFP = road.region.getFilePointer(); diff --git a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java index 0e1387eaa0..52652673cf 100644 --- a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java @@ -98,9 +98,21 @@ public class RouteDataObject { return names; } - public String getRef(){ + public String getRef(boolean direction) { if (names != null) { - String ref = names.get(region.destinationRefTypeRule); + int[] kt = names.keys(); + String refTag = (direction == true) ? "destination:ref:forward" : "destination:ref:backward"; + String ref = null; + + for(int i = 0 ; i < kt.length; i++) { + int k = kt[i]; + if(region.routeEncodingRules.size() > k) { + if(refTag.equals(region.routeEncodingRules.get(k).getTag())) { + return names.get(k); + } + } + } + ref = names.get(region.destinationRefTypeRule); if (ref != null) { return ref; } @@ -521,7 +533,7 @@ public class RouteDataObject { @Override public String toString() { String name = getName(); - String rf = getRef(); + String rf = getRef(true); return MessageFormat.format("Road id {0} name {1} ref {2}", (getId() / 64) + "", name == null ? "" : name, rf == null ? "" : rf); } diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index c8f5aaf0bf..198f589a7b 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -333,7 +333,7 @@ public class RouteResultPreparation { if (PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST) { for (RouteSegmentResult res : result) { String name = res.getObject().getName(); - String ref = res.getObject().getRef(); + String ref = res.getObject().getRef(res.isForwardDirection()); if (name == null) { name = ""; } diff --git a/OsmAnd/src/net/osmand/plus/GeocodingLookupService.java b/OsmAnd/src/net/osmand/plus/GeocodingLookupService.java index df13e88cfc..76ed3a4ec3 100644 --- a/OsmAnd/src/net/osmand/plus/GeocodingLookupService.java +++ b/OsmAnd/src/net/osmand/plus/GeocodingLookupService.java @@ -158,7 +158,7 @@ public class GeocodingLookupService { if (Algorithms.isEmpty(sname)) { sname = ""; } - String ref = rd.getRef(); + String ref = rd.getRef(true); if (!Algorithms.isEmpty(ref)) { if (!Algorithms.isEmpty(sname)) { sname += ", "; diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 978edf27a8..4de9e09f53 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -111,7 +111,7 @@ public class AvoidSpecificRoads { protected String getText(RouteDataObject obj) { return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get()), - obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get(), true), app.getString(R.string.towards)); + obj.getRef(true), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get(), true), app.getString(R.string.towards)); } public void showDialog(@NonNull final MapActivity mapActivity) { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 5eba53ca86..5e8c11af4e 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -253,7 +253,7 @@ public class RouteCalculationResult { info.routeEndPointOffset = roundAboutEnd; } RouteSegmentResult next = list.get(lind); - info.setRef(next.getObject().getRef()); + info.setRef(next.getObject().getRef(next.isForwardDirection())); info.setStreetName(next.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get())); info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(), next.isForwardDirection())); } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index ed687f4c3b..6138d461c6 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -760,7 +760,7 @@ public class RoutingHelper { RouteSegmentResult rs = getCurrentSegmentResult(); if(rs != null) { String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get()); - String rf = rs.getObject().getRef(); + String rf = rs.getObject().getRef(rs.isForwardDirection()); String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rs.isForwardDirection()); return formatStreetName(nm, rf, dn, "»"); } diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index b091f7e91c..8eaef18698 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -586,12 +586,12 @@ public class VoiceRouter { // Issue 2377: Play Dest here only if not already previously announced, to avoid repetition if (includeDest == true) { RouteDataObject obj = currentSegment.getObject(); - current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef())), + current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef(currentSegment.isForwardDirection()))), getTermString(getSpeakablePointName(obj.getName(settings.MAP_PREFERRED_LOCALE.get()))), getTermString(getSpeakablePointName(obj.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), currentSegment.isForwardDirection()))) }); } else { RouteDataObject obj = currentSegment.getObject(); - current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef())), + current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef(currentSegment.isForwardDirection()))), getTermString(getSpeakablePointName(obj.getName(settings.MAP_PREFERRED_LOCALE.get()))), empty }); } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index a1e21cddf0..4389c4a6e9 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -581,7 +581,7 @@ public class MapInfoWidgetsFactory { RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); if (rt != null) { text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()), - rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), "»"); + rt.getRef(rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), "»"); } if (text == null) { text = "";