diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java index 0dfc2e5c83..0fb0bdacf6 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java @@ -1011,6 +1011,17 @@ public class RouteDataObject { rf == null ? "" : rf); } + public boolean hasNameTagStartsWith(String tagStartsWith) { + int[] nextSegmentNameIds = nameIds; + for (int nm = 0; nm < nameIds.length; nm++) { + RouteTypeRule rtr = region.quickGetEncodingRule(nameIds[nm]); + if (rtr != null && rtr.getTag().startsWith(tagStartsWith)) { + return true; + } + } + return false; + } + public static class RestrictionInfo { public int type; public long toWay; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index b4b090442d..30da3fa575 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -230,6 +230,7 @@ public class RouteCalculationResult { RouteDirectionInfo info = new RouteDirectionInfo(localDirections.get(currentDirection).getAverageSpeed(), TurnType.straight()); info.setRef(toSplit.getRef()); info.setStreetName(toSplit.getStreetName()); + info.setRouteDataObject(toSplit.getRouteDataObject()); info.setDestinationName(toSplit.getDestinationName()); info.routePointOffset = interLocations[currentIntermediate]; info.setDescriptionRoute(ctx.getString(R.string.route_head));//; //$NON-NLS-1$ @@ -412,32 +413,17 @@ public class RouteCalculationResult { if (ref != null) { RouteDataObject nextRoad = next.getObject(); - boolean isNextShieldFound = false; - int[] nextSegmentNameIds = nextRoad.nameIds; - for (int nm = 0; nm < nextSegmentNameIds.length; nm++) { - if (nextRoad.region.quickGetEncodingRule(nextSegmentNameIds[nm]).getTag().startsWith("road_ref")) { - info.setRouteDataObject(nextRoad); - isNextShieldFound = true; - } - } + info.setRouteDataObject(nextRoad); - if (!isNextShieldFound) { - for (int ind = lind; ind < list.size(); ind++) { - if (list.get(ind).getTurnType() != null) { - info.setRouteDataObject(null); - break; - } else { - RouteDataObject obj = list.get(ind).getObject(); - int[] nameIds = obj.nameIds; - for (int idx = 0; idx < nameIds.length; idx ++) { - if (obj.region.routeEncodingRules.get(obj.nameIds[idx]).getTag().startsWith("road_ref")) { - info.setRouteDataObject(obj); - break; - } - } - if (info.getRouteDataObject() != null) { - break; - } + boolean isNextShieldFound = nextRoad.hasNameTagStartsWith("road_ref"); + for (int ind = lind; ind < list.size() && !isNextShieldFound; ind++) { + if (list.get(ind).getTurnType() != null) { + isNextShieldFound = true; + } else { + RouteDataObject obj = list.get(ind).getObject(); + if (obj.hasNameTagStartsWith("road_ref")) { + info.setRouteDataObject(obj); + isNextShieldFound = true; } } } @@ -787,6 +773,7 @@ public class RouteCalculationResult { if (segs != null) { RouteSegmentResult lastSegmentResult = segs.get(segs.size() - 1); RouteDataObject routeDataObject = lastSegmentResult.getObject(); + info.setRouteDataObject(routeDataObject); info.setRef(routeDataObject.getRef(ctx.getSettings().MAP_PREFERRED_LOCALE.get(), ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), lastSegmentResult.isForwardDirection())); info.setStreetName(routeDataObject.getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(), @@ -1143,6 +1130,7 @@ public class RouteCalculationResult { p = new RouteDirectionInfo(i.getAverageSpeed(), i.getTurnType()); p.routePointOffset = i.routePointOffset; p.routeEndPointOffset = i.routeEndPointOffset; + p.setRouteDataObject(i.getRouteDataObject()); p.setDestinationName(i.getDestinationName()); p.setRef(i.getRef()); p.setStreetName(i.getStreetName()); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 3d3c75dd5c..353dd7b0e8 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -480,7 +480,7 @@ public class RouteProvider { ch.routeEndPointOffset = info.routeEndPointOffset - startI[0]; } ch.setDescriptionRoute(info.getDescriptionRoutePart()); - + ch.setRouteDataObject(info.getRouteDataObject()); // Issue #2894 if (info.getRef() != null && !"null".equals(info.getRef())) { ch.setRef(info.getRef()); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 2b997cf25b..acc068178b 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -1144,6 +1144,9 @@ public class MapInfoWidgetsFactory { additional.append(key).append("=").append(val).append(";"); } } + if(name == null || nameTag == null) { + return false; + } Context context = topBar.getContext(); int[] tps = object.getTypes();