From 6093e4a3570b14e73d62c7a08bc80a763d0618fc Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 20 May 2020 13:28:53 +0200 Subject: [PATCH 1/4] Refactor --- .../osmand/plus/routing/RoutingHelper.java | 26 +++-- .../mapwidgets/MapInfoWidgetsFactory.java | 107 +++++++----------- 2 files changed, 55 insertions(+), 78 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index f7c7c3cffb..00262d58a1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -945,7 +945,13 @@ public class RoutingHelper { // return false; // } - public synchronized String getCurrentName(TurnType[] next, NextDirectionInfo n){ + + public static class CurrentStreetName { + public String text; + } + + public synchronized CurrentStreetName getCurrentName(TurnType[] next, NextDirectionInfo n){ + CurrentStreetName streetName = new CurrentStreetName(); Location l = lastFixedLocation; float speed = 0; if(l != null && l.hasSpeed()) { @@ -959,27 +965,27 @@ public class RoutingHelper { String nm = n.directionInfo.getStreetName(); String rf = n.directionInfo.getRef(); String dn = n.directionInfo.getDestinationName(); - - return formatStreetName(nm, null, dn, "»"); + streetName.text = formatStreetName(nm, null, dn, "»"); + return streetName; } RouteSegmentResult rs = getCurrentSegmentResult(); if(rs != null) { - String name = getRouteSegmentStreetName(rs); - if (!Algorithms.isEmpty(name)) { - return name; + streetName.text = getRouteSegmentStreetName(rs); + if (!Algorithms.isEmpty(streetName.text )) { + return streetName; } } rs = getNextStreetSegmentResult(); if(rs != null) { - String name = getRouteSegmentStreetName(rs); - if (!Algorithms.isEmpty(name)) { + streetName.text = getRouteSegmentStreetName(rs); + if (!Algorithms.isEmpty(streetName.text)) { if(next != null) { next[0] = TurnType.valueOf(TurnType.C, false); } - return name; + return streetName; } } - return null; + return streetName; } private String getRouteSegmentStreetName(RouteSegmentResult rs) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 61fffdb814..5042e3388c 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -981,96 +981,69 @@ public class MapInfoWidgetsFactory { } + public boolean updateInfo(DrawSettings d) { - String text = null; + RoutingHelper.CurrentStreetName streetName = null; + String exitRef = null; TurnType[] type = new TurnType[1]; boolean showNextTurn = false; boolean showMarker = this.showMarker; - boolean showExitInfo = false; - boolean showShield = false; - boolean imminentTurn = false; ExitInfo exitInfo = null; - RouteDataObject object = null; + RouteDataObject shieldObject = null; if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) { if (routingHelper.isFollowingMode()) { if (settings.SHOW_STREET_NAME.get()) { RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(calc1, true); - text = routingHelper.getCurrentName(type, nextDirInfo); - if (text == null) { - text = ""; + streetName = routingHelper.getCurrentName(type, nextDirInfo); + if (type[0] == null) { + showMarker = true; } else { - if (type[0] == null) { - showMarker = true; - } else { - turnDrawable.setColor(R.color.nav_arrow); + turnDrawable.setColor(R.color.nav_arrow); + } + RouteDirectionInfo nextDirectionInfo = nextDirInfo.directionInfo; + // show exit ref + if (nextDirectionInfo != null && nextDirectionInfo.getExitInfo() != null && + nextDirInfo.imminent >= 0) { + exitRef = exitInfo.getRef(); + if (!Algorithms.isEmpty(exitInfo.getExitStreetName())) { + streetName.text = exitInfo.getExitStreetName(); } } - - RouteDirectionInfo directionInfo = nextDirInfo.directionInfo; - - if (nextDirInfo.imminent >= 0) { - imminentTurn = true; - } else { - imminentTurn = false; - } - - if (directionInfo != null && directionInfo.getExitInfo() != null) { - exitInfo = directionInfo.getExitInfo(); - showExitInfo = true; - } else { - showExitInfo = false; - } - - if (showExitInfo) { - if(!Algorithms.isEmpty(exitInfo.getExitStreetName())) { - text = exitInfo.getExitStreetName(); - } - } - - if (directionInfo != null && directionInfo.getRouteDataObject() != null) { - object = directionInfo.getRouteDataObject(); - showShield = true; + // show shield + if (nextDirectionInfo != null) { + shieldObject = nextDirectionInfo.getRouteDataObject(); } } } else { int di = MapRouteInfoMenu.getDirectionInfo(); - if (di >= 0 && map.getMapRouteInfoMenu().isVisible() && - di < routingHelper.getRouteDirections().size()) { + if (di >= 0 && map.getMapRouteInfoMenu().isVisible() && di < routingHelper.getRouteDirections().size()) { + // TODO shields showNextTurn = true; RouteDirectionInfo next = routingHelper.getRouteDirections().get(di); type[0] = next.getTurnType(); turnDrawable.setColor(R.color.nav_arrow_distant); - text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»"); - if (text == null) { - text = ""; - } - } else { - text = null; + streetName = new RoutingHelper.CurrentStreetName(); + streetName.text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»"); } } } else if (map.getMapViewTrackingUtilities().isMapLinkedToLocation() && settings.SHOW_STREET_NAME.get()) { + streetName = new RoutingHelper.CurrentStreetName(); RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); if (rt != null) { Location lastKnownLocation = locationProvider.getLastKnownLocation(); - text = RoutingHelper.formatStreetName( + streetName.text = RoutingHelper.formatStreetName( rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()), rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)), "»"); - } - if (text == null) { - text = ""; - } else { - Location lastKnownLocation = locationProvider.getLastKnownLocation(); - if (!Algorithms.isEmpty(text) && lastKnownLocation != null) { - double dist = - CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation); + if (!Algorithms.isEmpty(streetName.text) && lastKnownLocation != null) { + double dist = CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation); if (dist < 50) { showMarker = true; } else { - text = map.getResources().getString(R.string.shared_string_near) + " " + text; + streetName.text = map.getResources().getString(R.string.shared_string_near) + " " + streetName.text; } } } @@ -1081,7 +1054,7 @@ public class MapInfoWidgetsFactory { updateVisibility(true); AndroidUiHelper.updateVisibility(addressText, false); AndroidUiHelper.updateVisibility(addressTextShadow, false); - } else if (text == null) { + } else if (streetName == null) { updateVisibility(false); } else { updateVisibility(true); @@ -1090,20 +1063,15 @@ public class MapInfoWidgetsFactory { AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0); boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker; this.showMarker = showMarker; - if (showShield && setRoadShield(shieldIcon, object)) { + if (shieldObject != null && setRoadShield(shieldIcon, shieldObject)) { AndroidUiHelper.updateVisibility(shieldIcon, true); } else { AndroidUiHelper.updateVisibility(shieldIcon, false); } - if (showExitInfo) { - String exitRef = exitInfo.getRef(); - if (!Algorithms.isEmpty(exitRef) && imminentTurn) { - exitRefText.setText(exitRef); - AndroidUiHelper.updateVisibility(exitRefText, true); - } else { - AndroidUiHelper.updateVisibility(exitRefText, false); - } + if (!Algorithms.isEmpty(exitRef) ) { + exitRefText.setText(exitRef); + AndroidUiHelper.updateVisibility(exitRefText, true); } else { AndroidUiHelper.updateVisibility(exitRefText, false); } @@ -1120,9 +1088,12 @@ public class MapInfoWidgetsFactory { AndroidUiHelper.updateVisibility(turnIcon, false); } } - if (!text.equals(addressText.getText().toString())) { - addressTextShadow.setText(text); - addressText.setText(text); + if(streetName.text == null || streetName.text.isEmpty()) { + addressTextShadow.setText(""); + addressText.setText(""); + } else if (!streetName.text.equals(addressText.getText().toString())) { + addressTextShadow.setText(streetName.text); + addressText.setText(streetName.text ); return true; } } From b222af223012ef80eb25c61b2297c48204cdcc59 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 20 May 2020 13:49:53 +0200 Subject: [PATCH 2/4] Refactor --- .../osmand/plus/routing/RoutingHelper.java | 50 +++++++++++----- .../mapwidgets/MapInfoWidgetsFactory.java | 58 +++++-------------- 2 files changed, 50 insertions(+), 58 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 00262d58a1..bfb53afeb3 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -948,17 +948,21 @@ public class RoutingHelper { public static class CurrentStreetName { public String text; + public TurnType turnType; + public boolean showMarker; // turn type has priority over showMarker + public RouteDataObject shieldObject; + public String exitRef; } - public synchronized CurrentStreetName getCurrentName(TurnType[] next, NextDirectionInfo n){ + public synchronized CurrentStreetName getCurrentName(NextDirectionInfo n){ CurrentStreetName streetName = new CurrentStreetName(); Location l = lastFixedLocation; float speed = 0; if(l != null && l.hasSpeed()) { speed = l.getSpeed(); } - if(next != null && n.directionInfo != null) { - next[0] = n.directionInfo.getTurnType(); + if(n.directionInfo != null) { + streetName.turnType = n.directionInfo.getTurnType(); } if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() && voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f)) { @@ -966,25 +970,39 @@ public class RoutingHelper { String rf = n.directionInfo.getRef(); String dn = n.directionInfo.getDestinationName(); streetName.text = formatStreetName(nm, null, dn, "»"); - return streetName; } - RouteSegmentResult rs = getCurrentSegmentResult(); - if(rs != null) { - streetName.text = getRouteSegmentStreetName(rs); - if (!Algorithms.isEmpty(streetName.text )) { - return streetName; + if (Algorithms.isEmpty(streetName.text)) { + RouteSegmentResult rs = getCurrentSegmentResult(); + if (rs != null) { + streetName.text = getRouteSegmentStreetName(rs); } } - rs = getNextStreetSegmentResult(); - if(rs != null) { - streetName.text = getRouteSegmentStreetName(rs); - if (!Algorithms.isEmpty(streetName.text)) { - if(next != null) { - next[0] = TurnType.valueOf(TurnType.C, false); + if (Algorithms.isEmpty(streetName.text)) { + RouteSegmentResult rs = getNextStreetSegmentResult(); + if (rs != null) { + streetName.text = getRouteSegmentStreetName(rs); + if (!Algorithms.isEmpty(streetName.text)) { + if (streetName.turnType != null) { + streetName.turnType = TurnType.valueOf(TurnType.C, false); + } } - return streetName; } } + // show exit ref + if (n.directionInfo != null && n.directionInfo.getExitInfo() != null && + n.imminent >= 0) { + streetName.exitRef = n.directionInfo.getExitInfo().getRef(); + if (!Algorithms.isEmpty(n.directionInfo.getExitInfo().getExitStreetName())) { + streetName.text = n.directionInfo.getExitInfo().getExitStreetName(); + } + } + // show shield + if (n.directionInfo != null) { + streetName.shieldObject = n.directionInfo.getRouteDataObject(); + } + if (streetName.turnType == null) { + streetName.showMarker = true; + } return streetName; } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 5042e3388c..5eef90a95d 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -931,11 +931,11 @@ public class MapInfoWidgetsFactory { private View waypointInfoBar; private LocationPointWrapper lastPoint; private TurnDrawable turnDrawable; - private boolean showMarker; private int shadowRad; RouteCalculationResult.NextDirectionInfo calc1; private static final Log LOG = PlatformUtil.getLog(TopTextView.class); + private boolean showMarker; public TopTextView(OsmandApplication app, MapActivity map) { turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true); @@ -984,47 +984,21 @@ public class MapInfoWidgetsFactory { public boolean updateInfo(DrawSettings d) { RoutingHelper.CurrentStreetName streetName = null; - String exitRef = null; - TurnType[] type = new TurnType[1]; - boolean showNextTurn = false; - boolean showMarker = this.showMarker; - ExitInfo exitInfo = null; - RouteDataObject shieldObject = null; - + boolean showClosestWaypointFirstInAddress = true; if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) { if (routingHelper.isFollowingMode()) { if (settings.SHOW_STREET_NAME.get()) { RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(calc1, true); - streetName = routingHelper.getCurrentName(type, nextDirInfo); - if (type[0] == null) { - showMarker = true; - } else { - turnDrawable.setColor(R.color.nav_arrow); - } - RouteDirectionInfo nextDirectionInfo = nextDirInfo.directionInfo; - // show exit ref - if (nextDirectionInfo != null && nextDirectionInfo.getExitInfo() != null && - nextDirInfo.imminent >= 0) { - exitRef = exitInfo.getRef(); - if (!Algorithms.isEmpty(exitInfo.getExitStreetName())) { - streetName.text = exitInfo.getExitStreetName(); - } - } - // show shield - if (nextDirectionInfo != null) { - shieldObject = nextDirectionInfo.getRouteDataObject(); - } + streetName = routingHelper.getCurrentName(nextDirInfo); + turnDrawable.setColor(R.color.nav_arrow); } } else { int di = MapRouteInfoMenu.getDirectionInfo(); if (di >= 0 && map.getMapRouteInfoMenu().isVisible() && di < routingHelper.getRouteDirections().size()) { - // TODO shields - showNextTurn = true; + showClosestWaypointFirstInAddress = false; RouteDirectionInfo next = routingHelper.getRouteDirections().get(di); - type[0] = next.getTurnType(); + streetName = routingHelper.getCurrentName(routingHelper.getNextRouteDirectionInfo(calc1, true)); turnDrawable.setColor(R.color.nav_arrow_distant); - streetName = new RoutingHelper.CurrentStreetName(); - streetName.text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»"); } } } else if (map.getMapViewTrackingUtilities().isMapLinkedToLocation() && @@ -1041,7 +1015,7 @@ public class MapInfoWidgetsFactory { if (!Algorithms.isEmpty(streetName.text) && lastKnownLocation != null) { double dist = CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation); if (dist < 50) { - showMarker = true; + streetName.showMarker = true; } else { streetName.text = map.getResources().getString(R.string.shared_string_near) + " " + streetName.text; } @@ -1050,7 +1024,7 @@ public class MapInfoWidgetsFactory { } if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) { updateVisibility(false); - } else if (!showNextTurn && updateWaypoint()) { + } else if (!showClosestWaypointFirstInAddress && updateWaypoint()) { updateVisibility(true); AndroidUiHelper.updateVisibility(addressText, false); AndroidUiHelper.updateVisibility(addressTextShadow, false); @@ -1061,26 +1035,26 @@ public class MapInfoWidgetsFactory { AndroidUiHelper.updateVisibility(waypointInfoBar, false); AndroidUiHelper.updateVisibility(addressText, true); AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0); - boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker; - this.showMarker = showMarker; - if (shieldObject != null && setRoadShield(shieldIcon, shieldObject)) { + + if (streetName.shieldObject != null && setRoadShield(shieldIcon, streetName.shieldObject)) { AndroidUiHelper.updateVisibility(shieldIcon, true); } else { AndroidUiHelper.updateVisibility(shieldIcon, false); } - if (!Algorithms.isEmpty(exitRef) ) { - exitRefText.setText(exitRef); + if (!Algorithms.isEmpty(streetName.exitRef) ) { + exitRefText.setText(streetName.exitRef); AndroidUiHelper.updateVisibility(exitRefText, true); } else { AndroidUiHelper.updateVisibility(exitRefText, false); } - if (update) { - if (type[0] != null) { + if (turnDrawable.setTurnType(streetName.turnType) || streetName.showMarker != this.showMarker) { + this.showMarker = streetName.showMarker; + if (streetName.turnType != null) { turnIcon.invalidateDrawable(turnDrawable); turnIcon.setImageDrawable(turnDrawable); AndroidUiHelper.updateVisibility(turnIcon, true); - } else if (showMarker) { + } else if (streetName.showMarker) { Drawable marker = map.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance); turnIcon.setImageDrawable(marker); AndroidUiHelper.updateVisibility(turnIcon, true); From a77e89bd20e2dcc1ad87edf0666973996a3912ed Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 20 May 2020 14:06:03 +0200 Subject: [PATCH 3/4] Fix turn next --- .../osmand/plus/routing/RoutingHelper.java | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index bfb53afeb3..7f2b6d3032 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -915,9 +915,6 @@ public class RoutingHelper { public static String formatStreetName(String name, String ref, String destination, String towards) { - //Hardy, 2016-08-05: - //Now returns: (ref) + ((" ")+name) + ((" ")+"toward "+dest) or "" - String formattedStreetName = ""; if (ref != null && ref.length() > 0) { formattedStreetName = ref; @@ -938,13 +935,6 @@ public class RoutingHelper { } -// protected boolean isDistanceLess(float currentSpeed, double dist, double etalon, float defSpeed){ -// if(dist < etalon || ((dist / currentSpeed) < (etalon / defSpeed))){ -// return true; -// } -// return false; -// } - public static class CurrentStreetName { public String text; @@ -958,47 +948,57 @@ public class RoutingHelper { CurrentStreetName streetName = new CurrentStreetName(); Location l = lastFixedLocation; float speed = 0; - if(l != null && l.hasSpeed()) { + if (l != null && l.hasSpeed()) { speed = l.getSpeed(); } - if(n.directionInfo != null) { - streetName.turnType = n.directionInfo.getTurnType(); - } - if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() && + boolean isSet = false; + // 1. turn is imminent + if (n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() && voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f)) { String nm = n.directionInfo.getStreetName(); String rf = n.directionInfo.getRef(); String dn = n.directionInfo.getDestinationName(); + isSet = !(Algorithms.isEmpty(nm) && Algorithms.isEmpty(rf) && Algorithms.isEmpty(dn)); streetName.text = formatStreetName(nm, null, dn, "»"); - } - if (Algorithms.isEmpty(streetName.text)) { - RouteSegmentResult rs = getCurrentSegmentResult(); - if (rs != null) { - streetName.text = getRouteSegmentStreetName(rs); + streetName.turnType = n.directionInfo.getTurnType(); + streetName.shieldObject = n.directionInfo.getRouteDataObject(); + if (streetName.turnType == null) { + streetName.turnType = TurnType.valueOf(TurnType.C, false); } - } - if (Algorithms.isEmpty(streetName.text)) { - RouteSegmentResult rs = getNextStreetSegmentResult(); - if (rs != null) { - streetName.text = getRouteSegmentStreetName(rs); - if (!Algorithms.isEmpty(streetName.text)) { - if (streetName.turnType != null) { - streetName.turnType = TurnType.valueOf(TurnType.C, false); - } + if (n.directionInfo.getExitInfo() != null) { + streetName.exitRef = n.directionInfo.getExitInfo().getRef(); + if (!Algorithms.isEmpty(n.directionInfo.getExitInfo().getExitStreetName())) { + streetName.text = n.directionInfo.getExitInfo().getExitStreetName(); } } } - // show exit ref - if (n.directionInfo != null && n.directionInfo.getExitInfo() != null && - n.imminent >= 0) { - streetName.exitRef = n.directionInfo.getExitInfo().getRef(); - if (!Algorithms.isEmpty(n.directionInfo.getExitInfo().getExitStreetName())) { - streetName.text = n.directionInfo.getExitInfo().getExitStreetName(); + // 2. display current road street name + if (!isSet) { + RouteSegmentResult rs = getCurrentSegmentResult(); + if (rs != null) { + streetName.text = getRouteSegmentStreetName(rs, false); + if (Algorithms.isEmpty(streetName.text)) { + isSet = Algorithms.isEmpty(getRouteSegmentStreetName(rs, true)); + } else { + isSet = true; + } + streetName.showMarker = true; + streetName.shieldObject = rs.getObject(); } } - // show shield - if (n.directionInfo != null) { - streetName.shieldObject = n.directionInfo.getRouteDataObject(); + // 3. display next road street name if this one empty + if (!isSet) { + RouteSegmentResult rs = getNextStreetSegmentResult(); + if (rs != null) { + streetName.text = getRouteSegmentStreetName(rs, false); + if (Algorithms.isEmpty(streetName.text)) { + isSet = Algorithms.isEmpty(getRouteSegmentStreetName(rs, true)); + } else { + isSet = true; + } + streetName.turnType = TurnType.valueOf(TurnType.C, false); + streetName.shieldObject = rs.getObject(); + } } if (streetName.turnType == null) { streetName.showMarker = true; @@ -1006,12 +1006,12 @@ public class RoutingHelper { return streetName; } - private String getRouteSegmentStreetName(RouteSegmentResult rs) { + private String getRouteSegmentStreetName(RouteSegmentResult rs, boolean includeRef) { String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()); -// String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection()); + String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection()); String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection()); - return formatStreetName(nm, null, dn, "»"); + return formatStreetName(nm, includeRef ? rf : null, dn, "»"); } public RouteSegmentResult getCurrentSegmentResult() { From 63483c672273de11643b8f0af988a4d44dd0d132 Mon Sep 17 00:00:00 2001 From: MadWasp79 Date: Wed, 20 May 2020 16:03:10 +0300 Subject: [PATCH 4/4] typo fix --- OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 7f2b6d3032..f60e4f7ea9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -978,7 +978,7 @@ public class RoutingHelper { if (rs != null) { streetName.text = getRouteSegmentStreetName(rs, false); if (Algorithms.isEmpty(streetName.text)) { - isSet = Algorithms.isEmpty(getRouteSegmentStreetName(rs, true)); + isSet = !Algorithms.isEmpty(getRouteSegmentStreetName(rs, true)); } else { isSet = true; } @@ -991,11 +991,6 @@ public class RoutingHelper { RouteSegmentResult rs = getNextStreetSegmentResult(); if (rs != null) { streetName.text = getRouteSegmentStreetName(rs, false); - if (Algorithms.isEmpty(streetName.text)) { - isSet = Algorithms.isEmpty(getRouteSegmentStreetName(rs, true)); - } else { - isSet = true; - } streetName.turnType = TurnType.valueOf(TurnType.C, false); streetName.shieldObject = rs.getObject(); }