diff --git a/brouter-core/src/main/java/btools/router/VoiceHint.java b/brouter-core/src/main/java/btools/router/VoiceHint.java index 1fae285..691453c 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHint.java +++ b/brouter-core/src/main/java/btools/router/VoiceHint.java @@ -29,6 +29,8 @@ public class VoiceHint { static final int EL = 17; // exit left static final int ER = 18; // exit right + static final int END = 100; // end point + int ilon; int ilat; short selev; @@ -155,6 +157,8 @@ public class VoiceHint { return timode == 2 || timode == 9 ? "ER" : "KR"; case OFFR: return "OFFR"; + case END: + return "END"; default: throw new IllegalArgumentException("unknown command: " + cmd); } diff --git a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java index ee2d905..e8526a2 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java @@ -72,6 +72,12 @@ public final class VoiceHintProcessor { results.add(input); continue; } + if (hintIdx == 0) { + input.cmd = VoiceHint.END; + results.add(input); + continue; + } + float turnAngle = input.goodWay.turnangle; distance += input.goodWay.linkdist; int currentPrio = input.goodWay.getPrio(); @@ -119,7 +125,7 @@ public final class VoiceHintProcessor { float tmpangle = 0; VoiceHint tmpRndAbt = new VoiceHint(); tmpRndAbt.badWays = new ArrayList<>(); - for (int i = hintIdx-1; i > roundaboudStartIdx; i--) { + for (int i = hintIdx - 1; i > roundaboudStartIdx; i--) { VoiceHint vh = inputs.get(i); tmpangle += inputs.get(i).goodWay.turnangle; if (vh.badWays != null) { @@ -172,12 +178,14 @@ public final class VoiceHintProcessor { } if (badWay.isBadOneway()) { - if (minAbsAngeRaw == 180f) minAbsAngeRaw = turnAngle; // disable hasSomethingMoreStraight + if (minAbsAngeRaw == 180f) + minAbsAngeRaw = turnAngle; // disable hasSomethingMoreStraight continue; // ignore wrong oneways } if (Math.abs(badTurn) - Math.abs(turnAngle) > 80.f) { - if (minAbsAngeRaw == 180f) minAbsAngeRaw = turnAngle; // disable hasSomethingMoreStraight + if (minAbsAngeRaw == 180f) + minAbsAngeRaw = turnAngle; // disable hasSomethingMoreStraight continue; // ways from the back should not trigger a slight turn } @@ -300,10 +308,12 @@ public final class VoiceHintProcessor { } if (nextInput == null) { - if ((input.cmd == VoiceHint.C || - input.cmd == VoiceHint.KR || - input.cmd == VoiceHint.KL) - && !input.goodWay.isLinktType()) { + if (input.cmd == VoiceHint.END) { + continue; + } else if ((input.cmd == VoiceHint.C || + input.cmd == VoiceHint.KR || + input.cmd == VoiceHint.KL) + && !input.goodWay.isLinktType()) { if (input.goodWay.getPrio() < input.maxBadPrio && (inputLastSaved != null && inputLastSaved.distanceToNext > catchingRange)) { results.add(input); } else { @@ -318,14 +328,14 @@ public final class VoiceHintProcessor { } else { if ((inputLastSaved != null && inputLastSaved.distanceToNext > catchingRange) || input.distanceToNext > catchingRange) { if ((input.cmd == VoiceHint.C || - input.cmd == VoiceHint.KR || - input.cmd == VoiceHint.KL) - && !input.goodWay.isLinktType()) { + input.cmd == VoiceHint.KR || + input.cmd == VoiceHint.KL) + && !input.goodWay.isLinktType()) { if (((Math.abs(input.lowerBadWayAngle) < 35.f || - input.higherBadWayAngle < 35.f) - || input.goodWay.getPrio() < input.maxBadPrio) - && (inputLastSaved != null && inputLastSaved.distanceToNext > minRange) - && (input.distanceToNext > minRange)) { + input.higherBadWayAngle < 35.f) + || input.goodWay.getPrio() < input.maxBadPrio) + && (inputLastSaved != null && inputLastSaved.distanceToNext > minRange) + && (input.distanceToNext > minRange)) { // add only on prio results.add(input); inputLastSaved = input; @@ -335,8 +345,8 @@ public final class VoiceHintProcessor { } } } else if ((input.goodWay.getPrio() == 29 && input.maxBadPrio == 30) && - ((hintIdx + 1 < inputs.size() && inputs.get(hintIdx+1).goodWay.getPrio() < 29) || - (hintIdx + 2 < inputs.size() && inputs.get(hintIdx+2).goodWay.getPrio() < 29))) { + checkForNextNoneMotorway(inputs, hintIdx, 3) + ) { // leave motorway if (input.cmd == VoiceHint.KR || input.cmd == VoiceHint.TSLR) { input.cmd = VoiceHint.ER; @@ -349,10 +359,10 @@ public final class VoiceHintProcessor { // add all others // ignore motorway / primary continue if (((input.goodWay.getPrio() != 28) && - (input.goodWay.getPrio() != 30) && - (input.goodWay.getPrio() != 26)) - || input.isRoundabout() - || Math.abs(input.angle) > 21.f) { + (input.goodWay.getPrio() != 30) && + (input.goodWay.getPrio() != 26)) + || input.isRoundabout() + || Math.abs(input.angle) > 21.f) { results.add(input); inputLastSaved = input; } else { @@ -371,20 +381,20 @@ public final class VoiceHintProcessor { angles += nextInput.angle; if ((input.cmd == VoiceHint.C || - input.cmd == VoiceHint.KR || - input.cmd == VoiceHint.KL) - && !input.goodWay.isLinktType()) { + input.cmd == VoiceHint.KR || + input.cmd == VoiceHint.KL) + && !input.goodWay.isLinktType()) { if (input.goodWay.getPrio() < input.maxBadPrio) { if (inputLastSaved != null && inputLastSaved.cmd != VoiceHint.C - && (inputLastSaved != null && inputLastSaved.distanceToNext > minRange) - && transportMode != VoiceHintList.TRANS_MODE_CAR) { + && (inputLastSaved != null && inputLastSaved.distanceToNext > minRange) + && transportMode != VoiceHintList.TRANS_MODE_CAR) { // add when straight and not linktype // and last vh not straight save = true; // remove when next straight and not linktype if (nextInput != null && - nextInput.cmd == VoiceHint.C && - !nextInput.goodWay.isLinktType()) { + nextInput.cmd == VoiceHint.C && + !nextInput.goodWay.isLinktType()) { input.distanceToNext += nextInput.distanceToNext; hintIdx++; } @@ -448,5 +458,14 @@ public final class VoiceHintProcessor { return results; } + boolean checkForNextNoneMotorway(List inputs, int offset, int testsize) { + for (int i = 1; i < testsize + 1 && offset + i < inputs.size(); i++) { + int prio = inputs.get(offset + i).goodWay.getPrio(); + if (prio < 29) return true; + if (prio == 30) return false; + } + return false; + } + }