From 005aa87d149751b6c1f466e2ce91cb9306567b09 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 7 Jul 2020 22:09:00 +0200 Subject: [PATCH] Fix #9336 --- .../osmand/router/RouteResultPreparation.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index 3de09af9d1..b0c32de648 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -1476,32 +1476,39 @@ public class RouteResultPreparation { protected TurnType createSimpleKeepLeftRightTurn(boolean leftSide, RouteSegmentResult prevSegm, RouteSegmentResult currentSegm, RoadSplitStructure rs) { + double devation = Math.abs(MapUtils.degreesDiff(prevSegm.getBearingEnd(), currentSegm.getBearingBegin())); + boolean makeSlightTurn = devation > 5 && (!isMotorway(prevSegm) || !isMotorway(currentSegm)); + TurnType t = null; + int laneType = TurnType.C; + if (rs.keepLeft && rs.keepRight) { + t = TurnType.valueOf(TurnType.C, leftSide); + } else if (rs.keepLeft) { + t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLL : TurnType.KL, leftSide); + if (makeSlightTurn) { + laneType = TurnType.TSLL; + } + } else if (rs.keepRight) { + t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLR : TurnType.KR, leftSide); + if (makeSlightTurn) { + laneType = TurnType.TSLR; + } + } else { + return null; + } int current = countLanesMinOne(currentSegm); int ls = current + rs.leftLanes + rs.rightLanes; int[] lanes = new int[ls]; for (int it = 0; it < ls; it++) { if (it < rs.leftLanes || it >= rs.leftLanes + current) { - lanes[it] = 0; + lanes[it] = TurnType.C << 1; } else { - lanes[it] = 1; + lanes[it] = (laneType << 1) + 1; } } // sometimes links are if ((current <= rs.leftLanes + rs.rightLanes) && (rs.leftLanes > 1 || rs.rightLanes > 1)) { rs.speak = true; } - double devation = Math.abs(MapUtils.degreesDiff(prevSegm.getBearingEnd(), currentSegm.getBearingBegin())); - boolean makeSlightTurn = devation > 5 && (!isMotorway(prevSegm) || !isMotorway(currentSegm)); - TurnType t = null; - if (rs.keepLeft && rs.keepRight) { - t = TurnType.valueOf(TurnType.C, leftSide); - } else if (rs.keepLeft) { - t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLL : TurnType.KL, leftSide); - } else if (rs.keepRight) { - t = TurnType.valueOf(makeSlightTurn ? TurnType.TSLR : TurnType.KR, leftSide); - } else { - return t; - } t.setSkipToSpeak(!rs.speak); t.setLanes(lanes); return t;