Fix #6838 Announce the change of street names
One road may be result of several streets changing one into another. In that case OsmAnd didn't indicate that street name would change, because thare was no turn left/right in the route. Commit adds the new feature. When two segments of stright part route have different street names, a new 'stright' direction with the new name will be inserted into the list of directions. This is not applied to roads that have international/national refs, like 'E 101'
This commit is contained in:
parent
6dbe18380a
commit
bda0b850fd
1 changed files with 36 additions and 2 deletions
|
@ -362,8 +362,40 @@ public class RouteCalculationResult {
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String streetName = null;
|
||||||
TurnType turn = s.getTurnType();
|
TurnType turn = s.getTurnType();
|
||||||
|
|
||||||
|
// Try to detect the case when a street changes is name to another (typically after road crossing)
|
||||||
|
// Then add RouteDirectionInfo of TurnType.straight()
|
||||||
|
if (turn == null && routeInd + 1 < list.size()) {
|
||||||
|
String curStreetName = s.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||||
|
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get());
|
||||||
|
String curIntRef = s.getObject().getValue("int_ref");
|
||||||
|
String curRoadRef2 = s.getObject().getValue("road_ref_2");
|
||||||
|
// Ignore the segments when has no street name or road is a highway (has ref like 'E 101')
|
||||||
|
if (!Algorithms.isEmpty(curStreetName) && Algorithms.isEmpty(curIntRef) && Algorithms.isEmpty(curRoadRef2)) {
|
||||||
|
int routeIndNext = routeInd + 1;
|
||||||
|
do {
|
||||||
|
RouteSegmentResult nextSegment = list.get(routeIndNext);
|
||||||
|
if (nextSegment.getTurnType() != null)
|
||||||
|
break; // in case instant turn is encountered then stop detection
|
||||||
|
String nextStreetName = nextSegment.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||||
|
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get());
|
||||||
|
if (!Algorithms.isEmpty(nextStreetName)) {
|
||||||
|
if (!Algorithms.stringsEqual(curStreetName, nextStreetName)) {
|
||||||
|
// If road changes street name, save valid data for RouteDirectionInfo
|
||||||
|
turn = TurnType.straight();
|
||||||
|
streetName = nextStreetName;
|
||||||
|
}
|
||||||
|
// If next segment has the same street name then stop detection
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
routeIndNext++;
|
||||||
|
} while (routeIndNext < routeInd + 5 && routeIndNext < list.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(turn != null) {
|
if(turn != null) {
|
||||||
RouteDirectionInfo info = new RouteDirectionInfo(s.getSegmentSpeed(), turn);
|
RouteDirectionInfo info = new RouteDirectionInfo(s.getSegmentSpeed(), turn);
|
||||||
if (routeInd < list.size()) {
|
if (routeInd < list.size()) {
|
||||||
|
@ -383,8 +415,10 @@ public class RouteCalculationResult {
|
||||||
String ref = next.getObject().getRef(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
String ref = next.getObject().getRef(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection());
|
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get(), next.isForwardDirection());
|
||||||
info.setRef(ref);
|
info.setRef(ref);
|
||||||
String streetName = next.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
if(streetName==null) {
|
||||||
|
streetName = next.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(),
|
||||||
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get());
|
ctx.getSettings().MAP_TRANSLITERATE_NAMES.get());
|
||||||
|
}
|
||||||
if (Algorithms.isEmpty(streetName)) {
|
if (Algorithms.isEmpty(streetName)) {
|
||||||
// try to get street names from following segments
|
// try to get street names from following segments
|
||||||
float distanceFromTurn = next.getDistance();
|
float distanceFromTurn = next.getDistance();
|
||||||
|
|
Loading…
Reference in a new issue