Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 16752 #21190

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2457,30 +2457,29 @@ private boolean hasAllowedLanes(int mainTurnType, int[] lanesArray, int startAct
if (lanesArray.length == 0 || startActiveIndex > endActiveIndex) {
return false;
}
int[] activeLines = new int[endActiveIndex - startActiveIndex + 1];
int[] activeLanes = new int[endActiveIndex - startActiveIndex + 1];
for (int i = startActiveIndex, j = 0; i <= endActiveIndex; i++, j++) {
activeLines[j] = lanesArray[i];
activeLanes[j] = lanesArray[i];
}
boolean possibleSharpLeftOrUTurn = startActiveIndex == 0;
boolean possibleSharpRightOrUTurn = endActiveIndex == lanesArray.length - 1;
for (int i = 0; i < activeLines.length; i++) {
int turnType = TurnType.getPrimaryTurn(activeLines[i]);
if (turnType == mainTurnType) {
for (int i = 0; i < activeLanes.length; i++) {
int primaryTurn = TurnType.getPrimaryTurn(activeLanes[i]);
if (primaryTurn == mainTurnType) {
return true;
}
if (TurnType.isLeftTurnNoUTurn(mainTurnType) && TurnType.isLeftTurnNoUTurn(turnType)) {
} else if (mainTurnType == TurnType.C && TurnType.isSlightTurn(primaryTurn)) {
return true;
}
if (TurnType.isRightTurnNoUTurn(mainTurnType) && TurnType.isRightTurnNoUTurn(turnType)) {
} else if (TurnType.isLeftTurnNoUTurn(primaryTurn) && TurnType.isLeftTurnNoUTurn(mainTurnType)) {
return true;
}
if (mainTurnType == TurnType.C && TurnType.isSlightTurn(turnType)) {
} else if (TurnType.isLeftTurnNoUTurn(primaryTurn) && possibleSharpLeftOrUTurn && mainTurnType == TurnType.C) {
return true;
}
if (possibleSharpLeftOrUTurn && TurnType.isSharpLeftOrUTurn(mainTurnType) && TurnType.isSharpLeftOrUTurn(turnType)) {
} else if (TurnType.isRightTurnNoUTurn(primaryTurn) && TurnType.isRightTurnNoUTurn(mainTurnType)) {
return true;
}
if (possibleSharpRightOrUTurn && TurnType.isSharpRightOrUTurn(mainTurnType) && TurnType.isSharpRightOrUTurn(turnType)) {
} else if (TurnType.isRightTurnNoUTurn(primaryTurn) && possibleSharpRightOrUTurn && mainTurnType == TurnType.C) {
return true;
} else if (TurnType.isSharpLeftOrUTurn(primaryTurn) && possibleSharpLeftOrUTurn && TurnType.isSharpLeftOrUTurn(mainTurnType)) {
return true;
} else if (TurnType.isSharpRightOrUTurn(primaryTurn) && possibleSharpRightOrUTurn && TurnType.isSharpRightOrUTurn(mainTurnType)) {
return true;
}
}
Expand All @@ -2492,20 +2491,27 @@ private TurnType getActiveTurnType(int[] lanes, boolean leftSide, TurnType oldTu
return oldTurnType;
}
int tp = oldTurnType.getValue();
int cnt = 0;
for (int k = 0; k < lanes.length; k++) {
int ln = lanes[k];
if ((ln & 1) > 0) {
if ((lanes[k] & 1) > 0) {
if (TurnType.hasAnyTurnLane(lanes[k], oldTurnType.getValue())) {
tp = oldTurnType.getValue();
break;
}
int[] oneActiveLane = {lanes[k]};
if (hasAllowedLanes(oldTurnType.getValue(), oneActiveLane, 0, 0)) {
tp = TurnType.getPrimaryTurn(lanes[k]);
}
cnt++;
}
}
int cntActiveLanes = 0;
for (int k = 0; k < lanes.length; k++) {
if ((lanes[k] & 1) > 0) {
cntActiveLanes++;
}
}
TurnType t = TurnType.valueOf(tp, leftSide);
// mute when most lanes have a straight/slight direction
if (cnt >= 3 && TurnType.isSlightTurn(t.getValue())) {
if (cntActiveLanes >= 3 && TurnType.isSlightTurn(t.getValue())) {
t.setSkipToSpeak(true);
}
return t;
Expand Down
3 changes: 2 additions & 1 deletion OsmAnd-java/src/main/java/net/osmand/router/TurnType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class TurnType {
public static final int OFFR = 12; // Off route //$NON-NLS-1$
public static final int RNDB = 13; // Roundabout
public static final int RNLB = 14; // Roundabout left
public static final int NONE = 15; // U-turn //$NON-NLS-1$
private static final int[] TURNS_ORDER = {TU, TSHL, TL, TSLL, C, TSLR, TR, TSHR, TRU};

public static TurnType straight() {
Expand Down Expand Up @@ -587,7 +588,7 @@ public static int convertType(String lane) {
turn = TurnType.TU;
} else {
// Unknown string
turn = TurnType.C;
turn = TurnType.NONE;
// continue;
}
return turn;
Expand Down
Loading