From 8c7f2e68e745de3700fcac89a3959fb938f90381 Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Mon, 13 Oct 2014 09:53:52 -0500 Subject: [PATCH] Add a right/left turn arrow on the rightmost/leftmost lane if it's not included as per turn:lanes and a right/left turn is being taken. --- .../osmand/router/RouteResultPreparation.java | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index 6cf75df325..f590a9e0b1 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -439,7 +439,7 @@ public class RouteResultPreparation { } else { t = TurnType.valueOf(TurnType.TU, leftSide); } - getLanesInfo(prev, t); + getLanesInfo(prev, t, leftSide); } else if (mpi < -TURN_DEGREE_MIN) { if (mpi > -60) { t = TurnType.valueOf(TurnType.TSLR, leftSide); @@ -450,7 +450,7 @@ public class RouteResultPreparation { } else { t = TurnType.valueOf(TurnType.TU, leftSide); } - getLanesInfo(prev, t); + getLanesInfo(prev, t, leftSide); } else { t = attachKeepLeftInfoAndLanes(leftSide, prev, rr, t); } @@ -461,7 +461,7 @@ public class RouteResultPreparation { return t; } - private void getLanesInfo(RouteSegmentResult prevSegm, TurnType t) { + private void getLanesInfo(RouteSegmentResult prevSegm, TurnType t, boolean leftSide) { int lanes = prevSegm.getObject().getLanes(); if (prevSegm.getObject().getOneway() == 0) { lanes = countLanes(prevSegm, lanes); @@ -485,6 +485,32 @@ public class RouteResultPreparation { t.setLanes(lanesArray); assignTurns(splitLaneOptions, t); + // In some cases (at least in the US), the rightmost lane might not have a right turn indicated as per turn:lanes, but is allowed and being used here. This section adds in that indicator. The same applies for where leftSide is true. + if (leftSide) { + if (t.getValue() == TurnType.TL + && TurnType.getPrimaryTurn(lanesArray[0]) != TurnType.TL + && TurnType.getPrimaryTurn(lanesArray[0]) != TurnType.TSLL + && TurnType.getPrimaryTurn(lanesArray[0]) != TurnType.TSHL) { + if (TurnType.getPrimaryTurn(lanesArray[0]) != 0) { + // This was just to make sure that there's no bad data. + t.setSecondaryTurn(0, TurnType.getPrimaryTurn(lanesArray[0])); + t.setPrimaryTurn(0, TurnType.TL); + } + } + } else { + int lastIndex = lanesArray.length - 1; + if (t.getValue() == TurnType.TR + && TurnType.getPrimaryTurn(lanesArray[lastIndex]) != TurnType.TR + && TurnType.getPrimaryTurn(lanesArray[lastIndex]) != TurnType.TSLR + && TurnType.getPrimaryTurn(lanesArray[lastIndex]) != TurnType.TSHR) { + if (TurnType.getPrimaryTurn(lanesArray[lastIndex]) != 0) { + // This was just to make sure that there's no bad data. + t.setSecondaryTurn(lastIndex, TurnType.getPrimaryTurn(lanesArray[lastIndex])); + t.setPrimaryTurn(lastIndex, TurnType.TR); + } + } + } + // Manually set the allowed lanes. for (int i = 0; i < lanesArray.length; i++) { if (TurnType.getPrimaryTurn(lanesArray[i]) == t.getValue()) {