From c07454a8ba5511be4f195b5b7dc4eabb9d484e21 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 6 Oct 2023 14:57:46 +0200 Subject: [PATCH 01/10] enable new post process on voicehints --- .../main/java/btools/router/VoiceHint.java | 1 + .../btools/router/VoiceHintProcessor.java | 114 ++++++++++-------- 2 files changed, 63 insertions(+), 52 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/VoiceHint.java b/brouter-core/src/main/java/btools/router/VoiceHint.java index 2f858beb..df399333 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHint.java +++ b/brouter-core/src/main/java/btools/router/VoiceHint.java @@ -44,6 +44,7 @@ public float getTime() { float angle = Float.MAX_VALUE; boolean turnAngleConsumed; boolean needsRealTurn; + int maxBadPrio; int roundaboutExit; diff --git a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java index 1a63a0a1..2e61c657 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java @@ -147,6 +147,7 @@ public List process(List inputs) { if (badPrio > maxPrioCandidates) { maxPrioCandidates = badPrio; + input.maxBadPrio = Math.max(input.maxBadPrio, badPrio); } if (badTurn > maxAngle) { maxAngle = badTurn; @@ -158,6 +159,7 @@ public List process(List inputs) { } boolean hasSomethingMoreStraight = (Math.abs(turnAngle) - minAbsAngeRaw) > 20.; + //boolean hasSomethingMoreStraight = (Math.abs(turnAngle - minAbsAngeRaw)) > 20.; // unconditional triggers are all junctions with // - higher detour prios than the minimum route prio (except link->highway junctions) @@ -244,80 +246,88 @@ public List postProcess(List inputs, double catchingRange, List results = new ArrayList<>(); double distance = 0; VoiceHint inputLast = null; - ArrayList tmpList = new ArrayList<>(); for (int hintIdx = 0; hintIdx < inputs.size(); hintIdx++) { VoiceHint input = inputs.get(hintIdx); + VoiceHint nextInput = null; + if (hintIdx + 1 < inputs.size()) { + nextInput = inputs.get(hintIdx + 1); + } - if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { - int badWayPrio = 0; - if (input.badWays != null) { - for (MessageData md : input.badWays) { - badWayPrio = Math.max(badWayPrio, md.getPrio()); + if (nextInput == null) { + if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { + if (input.goodWay.getPrio() < input.maxBadPrio) { + results.add(input); + } else { + if (inputLast != null) { // when drop add distance to last + inputLast.distanceToNext += input.distanceToNext; + } + continue; } - } - if (input.goodWay.getPrio() < badWayPrio) { - results.add(input); } else { - if (inputLast != null) { // when drop add distance to last - inputLast.distanceToNext += input.distanceToNext; - } - continue; + results.add(input); } } else { - if (input.distanceToNext < catchingRange) { + if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { + if (input.goodWay.getPrio() < input.maxBadPrio) { + results.add(input); + } else { + if (inputLast != null) { // when drop add distance to last + inputLast.distanceToNext += input.distanceToNext; + } + } + } else if (input.distanceToNext < catchingRange) { + int badWayPrio = 0; double dist = input.distanceToNext; float angles = input.angle; int i = 1; - boolean save = true; - tmpList.clear(); - while (dist < catchingRange && hintIdx + i < inputs.size()) { - VoiceHint h2 = inputs.get(hintIdx + i); - dist += h2.distanceToNext; - angles += h2.angle; - if (VoiceHint.is180DegAngle(input.angle) || VoiceHint.is180DegAngle(h2.angle)) { // u-turn, 180 degree - save = true; - break; - } else if (Math.abs(angles) > 180 - SIGNIFICANT_ANGLE) { // u-turn, collects e.g. two left turns in range - input.angle = angles; - input.calcCommand(); - input.distanceToNext += h2.distanceToNext; - save = true; - hintIdx++; - break; - } else if (Math.abs(angles) < SIGNIFICANT_ANGLE && input.distanceToNext < minRange) { - input.angle = angles; - input.calcCommand(); - input.distanceToNext += h2.distanceToNext; + boolean save = false; + + dist += nextInput.distanceToNext; + angles += nextInput.angle; + + if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { + if (input.goodWay.getPrio() < input.maxBadPrio) { save = true; - hintIdx++; - break; - } else if (Math.abs(input.angle) > SIGNIFICANT_ANGLE) { - tmpList.add(h2); - hintIdx++; - } else if (dist > catchingRange) { // distance reached - break; - } else { - if (inputLast != null) { // when drop add distance to last - inputLast.distanceToNext += input.distanceToNext; - } - save = false; } - i++; + } else if (VoiceHint.is180DegAngle(input.angle)) { //|| VoiceHint.is180DegAngle(nextInput.angle)) { // u-turn, 180 degree + //System.out.println("uturn < dist next!=null " + input.indexInTrack); + save = true; + } else if (Math.abs(angles) > 180 - SIGNIFICANT_ANGLE) { // u-turn, collects e.g. two left turns in range + input.angle = angles; + input.calcCommand(); + input.distanceToNext += nextInput.distanceToNext; + save = true; + hintIdx++; + } else if (Math.abs(angles) < SIGNIFICANT_ANGLE && input.distanceToNext < minRange) { + input.angle = angles; + input.calcCommand(); + input.distanceToNext += nextInput.distanceToNext; + save = true; + } else if (Math.abs(input.angle) > SIGNIFICANT_ANGLE) { + results.add(input); // add when last + save = false; + } else if (Math.abs(input.angle) < SIGNIFICANT_ANGLE) { + results.add(input); // add when last + save = false; + } else { + if (inputLast != null) { // when drop add distance to last + inputLast.distanceToNext += input.distanceToNext; + } + save = false; } + if (save) { results.add(input); // add when last - if (tmpList.size() > 0) { // add when something in stock - results.addAll(tmpList); - hintIdx += tmpList.size() - 1; - } } } else { results.add(input); } - inputLast = input; } + inputLast = input; } + return results; } + } From f405b0e16ea4b036c224e1f08cb4fcfdc76801cb Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 22 Dec 2023 17:51:04 +0100 Subject: [PATCH 02/10] switch to numeric transport mode --- .../main/java/btools/router/VoiceHint.java | 2 +- .../java/btools/router/VoiceHintList.java | 29 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/VoiceHint.java b/brouter-core/src/main/java/btools/router/VoiceHint.java index df399333..3d0b425c 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHint.java +++ b/brouter-core/src/main/java/btools/router/VoiceHint.java @@ -44,7 +44,7 @@ public float getTime() { float angle = Float.MAX_VALUE; boolean turnAngleConsumed; boolean needsRealTurn; - int maxBadPrio; + int maxBadPrio = -1; int roundaboutExit; diff --git a/brouter-core/src/main/java/btools/router/VoiceHintList.java b/brouter-core/src/main/java/btools/router/VoiceHintList.java index 229f4abd..215d2f79 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintList.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintList.java @@ -10,23 +10,44 @@ import java.util.List; public class VoiceHintList { - private String transportMode; + + static final int TRANS_MODE_NONE = 0; + static final int TRANS_MODE_FOOT = 1; + static final int TRANS_MODE_BIKE = 2; + static final int TRANS_MODE_CAR = 3; + + private int transportMode = TRANS_MODE_BIKE; int turnInstructionMode; List list = new ArrayList<>(); public void setTransportMode(boolean isCar, boolean isBike) { - transportMode = isCar ? "car" : (isBike ? "bike" : "foot"); + transportMode = isCar ? TRANS_MODE_CAR : (isBike ? TRANS_MODE_BIKE : TRANS_MODE_FOOT); + } + + public void setTransportMode(int mode) { + transportMode = mode; } public String getTransportMode() { + String ret; + switch(transportMode) { + case TRANS_MODE_FOOT: ret = "foot"; break; + case TRANS_MODE_CAR : ret = "car"; break; + case TRANS_MODE_BIKE: + default: ret = "bike"; + } + return ret; + } + + public int transportMode() { return transportMode; } public int getLocusRouteType() { - if ("car".equals(transportMode)) { + if (transportMode == TRANS_MODE_CAR) { return 0; } - if ("bike".equals(transportMode)) { + if (transportMode == TRANS_MODE_BIKE) { return 5; } return 3; // foot From 0f8bdfee6cbdc8d7bf4cef8d29115f93cdbcbf49 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 22 Dec 2023 17:52:15 +0100 Subject: [PATCH 03/10] switch gpx name to point name - temp only --- brouter-core/src/main/java/btools/router/FormatGpx.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/brouter-core/src/main/java/btools/router/FormatGpx.java b/brouter-core/src/main/java/btools/router/FormatGpx.java index 0ed6cc5b..39bb0de2 100644 --- a/brouter-core/src/main/java/btools/router/FormatGpx.java +++ b/brouter-core/src/main/java/btools/router/FormatGpx.java @@ -153,7 +153,10 @@ public String formatAsGpx(BufferedWriter sb, OsmTrack t) throws IOException { sb.append(" ") .append(hint.selev == Short.MIN_VALUE ? "" : "" + (hint.selev / 4.) + "") - .append("").append(hint.getMessageString()).append("") + .append("P") + .append(""+hint.indexInTrack+"_") + .append(hint.getMessageString()) + .append("") .append("").append("" + hint.distanceToNext).append(""); float rteTime = t.getVoiceHintTime(i + 1); if (rteTime != lastRteTime) { // add timing only if available From c31c38a5d63e0aecb24849420aa58351ea1aaf23 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 22 Dec 2023 17:56:48 +0100 Subject: [PATCH 04/10] added transport mode param, switch morestraight logic --- .../src/main/java/btools/router/VoiceHintProcessor.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java index 2e61c657..d11a923c 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java @@ -15,10 +15,12 @@ public final class VoiceHintProcessor { // private double catchingRange; // range to catch angles and merge turns private boolean explicitRoundabouts; + private int transportMode; - public VoiceHintProcessor(double catchingRange, boolean explicitRoundabouts) { + public VoiceHintProcessor(double catchingRange, boolean explicitRoundabouts, int transportMode) { // this.catchingRange = catchingRange; this.explicitRoundabouts = explicitRoundabouts; + this.transportMode = transportMode; } private float sumNonConsumedWithinCatchingRange(List inputs, int offset) { @@ -158,8 +160,8 @@ public List process(List inputs) { } } - boolean hasSomethingMoreStraight = (Math.abs(turnAngle) - minAbsAngeRaw) > 20.; - //boolean hasSomethingMoreStraight = (Math.abs(turnAngle - minAbsAngeRaw)) > 20.; + // boolean hasSomethingMoreStraight = (Math.abs(turnAngle) - minAbsAngeRaw) > 20.; + boolean hasSomethingMoreStraight = (Math.abs(turnAngle - minAbsAngeRaw)) > 20. && input.badWays != null; // && !ignoreBadway; // unconditional triggers are all junctions with // - higher detour prios than the minimum route prio (except link->highway junctions) From c5f158ec4319960f890fb7b7a355465a8f952eab Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 22 Dec 2023 18:05:07 +0100 Subject: [PATCH 05/10] calls with transport mode --- .../src/main/java/btools/router/OsmTrack.java | 12 ++++++------ .../src/main/java/btools/router/VoiceHintList.java | 14 ++++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/OsmTrack.java b/brouter-core/src/main/java/btools/router/OsmTrack.java index 9ccff98e..c336c380 100644 --- a/brouter-core/src/main/java/btools/router/OsmTrack.java +++ b/brouter-core/src/main/java/btools/router/OsmTrack.java @@ -498,7 +498,8 @@ public void processVoiceHints(RoutingContext rc) { node = node.origin; } - VoiceHintProcessor vproc = new VoiceHintProcessor(rc.turnInstructionCatchingRange, rc.turnInstructionRoundabouts); + int transportMode = voiceHints.transportMode(); + VoiceHintProcessor vproc = new VoiceHintProcessor(rc.turnInstructionCatchingRange, rc.turnInstructionRoundabouts, transportMode); List results = vproc.process(inputs); double minDistance = getMinDistance(); @@ -511,13 +512,12 @@ public void processVoiceHints(RoutingContext rc) { int getMinDistance() { if (voiceHints != null) { - switch (voiceHints.getTransportMode()) { - case "car": + switch (voiceHints.transportMode()) { + case VoiceHintList.TRANS_MODE_CAR: return 20; - case "bike": - return 5; - case "foot": + case VoiceHintList.TRANS_MODE_FOOT: return 3; + case VoiceHintList.TRANS_MODE_BIKE: default: return 5; } diff --git a/brouter-core/src/main/java/btools/router/VoiceHintList.java b/brouter-core/src/main/java/btools/router/VoiceHintList.java index 215d2f79..e377e24a 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintList.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintList.java @@ -30,11 +30,17 @@ public void setTransportMode(int mode) { public String getTransportMode() { String ret; - switch(transportMode) { - case TRANS_MODE_FOOT: ret = "foot"; break; - case TRANS_MODE_CAR : ret = "car"; break; + switch (transportMode) { + case TRANS_MODE_FOOT: + ret = "foot"; + break; + case TRANS_MODE_CAR: + ret = "car"; + break; case TRANS_MODE_BIKE: - default: ret = "bike"; + default: + ret = "bike"; + break; } return ret; } From 01ac57a929abf17a7a74d0274a8cafd388288e9f Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 22 Dec 2023 18:09:44 +0100 Subject: [PATCH 06/10] change for voicehint list first step --- .../src/main/java/btools/router/VoiceHintProcessor.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java index d11a923c..b31e6dc2 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java @@ -129,10 +129,7 @@ public List process(List inputs) { if (badPrio > maxPrioAll && !isBadHighway2Link) { maxPrioAll = badPrio; - } - - if (badWay.costfactor < 20.f && Math.abs(badTurn) < minAbsAngeRaw) { - minAbsAngeRaw = Math.abs(badTurn); + input.maxBadPrio = Math.max(input.maxBadPrio, badPrio); } if (badPrio < minPrio) { @@ -147,6 +144,10 @@ public List process(List inputs) { continue; // ways from the back should not trigger a slight turn } + if (badWay.costfactor < 20.f && Math.abs(badTurn) < minAbsAngeRaw) { + minAbsAngeRaw = Math.abs(badTurn); + } + if (badPrio > maxPrioCandidates) { maxPrioCandidates = badPrio; input.maxBadPrio = Math.max(input.maxBadPrio, badPrio); From e73d0e8001cf3a589364e39f2ee3c27aa54b8ecd Mon Sep 17 00:00:00 2001 From: afischerdev Date: Fri, 22 Dec 2023 18:25:09 +0100 Subject: [PATCH 07/10] change for voicehint list second step --- .../btools/router/VoiceHintProcessor.java | 82 +++++++++++++++---- 1 file changed, 64 insertions(+), 18 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java index b31e6dc2..4aaa230a 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java @@ -249,6 +249,7 @@ public List postProcess(List inputs, double catchingRange, List results = new ArrayList<>(); double distance = 0; VoiceHint inputLast = null; + VoiceHint inputLastSaved = null; for (int hintIdx = 0; hintIdx < inputs.size(); hintIdx++) { VoiceHint input = inputs.get(hintIdx); VoiceHint nextInput = null; @@ -258,7 +259,7 @@ public List postProcess(List inputs, double catchingRange, if (nextInput == null) { if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { - if (input.goodWay.getPrio() < input.maxBadPrio) { + if (input.goodWay.getPrio() < input.maxBadPrio && (inputLastSaved != null && inputLastSaved.distanceToNext > catchingRange)) { results.add(input); } else { if (inputLast != null) { // when drop add distance to last @@ -270,16 +271,37 @@ public List postProcess(List inputs, double catchingRange, results.add(input); } } else { - if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { - if (input.goodWay.getPrio() < input.maxBadPrio) { - results.add(input); - } else { - if (inputLast != null) { // when drop add distance to last - inputLast.distanceToNext += input.distanceToNext; + if ((inputLastSaved != null && inputLastSaved.distanceToNext > catchingRange) || input.distanceToNext > catchingRange) { + if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { + if (input.goodWay.getPrio() < input.maxBadPrio + && (inputLastSaved != null && inputLastSaved.distanceToNext > minRange) + && (input.distanceToNext > minRange)) { + // add only on prio + results.add(input); + inputLastSaved = input; + } else { + if (inputLastSaved != null) { // when drop add distance to last + inputLastSaved.distanceToNext += input.distanceToNext; + } + } + } + else { + // add all others + // ignore motorway / primary continue + if ( + ((input.goodWay.getPrio() != 28) && + (input.goodWay.getPrio() != 30) && + (input.goodWay.getPrio() != 26)) + || Math.abs(input.angle) > 5.f) { // motorway / primary exit + results.add(input); + inputLastSaved = input; + } else { + if (inputLastSaved != null) { // when drop add distance to last + inputLastSaved.distanceToNext += input.distanceToNext; + } } } } else if (input.distanceToNext < catchingRange) { - int badWayPrio = 0; double dist = input.distanceToNext; float angles = input.angle; int i = 1; @@ -290,12 +312,32 @@ public List postProcess(List inputs, double catchingRange, if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { if (input.goodWay.getPrio() < input.maxBadPrio) { - save = true; + if (inputLastSaved != null && inputLastSaved.cmd != VoiceHint.C + && (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()) { + input.distanceToNext += nextInput.distanceToNext; + hintIdx++; + } + } + + } else { + if (inputLastSaved != null) { // when drop add distance to last + inputLastSaved.distanceToNext += input.distanceToNext; + } } - } else if (VoiceHint.is180DegAngle(input.angle)) { //|| VoiceHint.is180DegAngle(nextInput.angle)) { // u-turn, 180 degree - //System.out.println("uturn < dist next!=null " + input.indexInTrack); + } else if (VoiceHint.is180DegAngle(input.angle)) { + // add u-turn, 180 degree save = true; - } else if (Math.abs(angles) > 180 - SIGNIFICANT_ANGLE) { // u-turn, collects e.g. two left turns in range + } else if (transportMode == VoiceHintList.TRANS_MODE_CAR && Math.abs(angles) > 180 - SIGNIFICANT_ANGLE) { + // add when inc car mode and u-turn, collects e.g. two left turns in range input.angle = angles; input.calcCommand(); input.distanceToNext += nextInput.distanceToNext; @@ -306,24 +348,28 @@ public List postProcess(List inputs, double catchingRange, input.calcCommand(); input.distanceToNext += nextInput.distanceToNext; save = true; + hintIdx++; } else if (Math.abs(input.angle) > SIGNIFICANT_ANGLE) { - results.add(input); // add when last - save = false; + // add when angle above 22.5 deg + save = true; } else if (Math.abs(input.angle) < SIGNIFICANT_ANGLE) { - results.add(input); // add when last - save = false; + // add when angle below 22.5 deg + save = true; } else { - if (inputLast != null) { // when drop add distance to last - inputLast.distanceToNext += input.distanceToNext; + // otherwise ignore but add distance to next + if (nextInput != null) { // when drop add distance to last + nextInput.distanceToNext += input.distanceToNext; } save = false; } if (save) { results.add(input); // add when last + inputLastSaved = input; } } else { results.add(input); + inputLastSaved = input; } } inputLast = input; From b3002a78e3e4937ac8ec5be27b1d0c3a90b1cdea Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 30 Jan 2024 18:12:51 +0100 Subject: [PATCH 08/10] rework for vh on roundabouts #664 --- .../btools/router/VoiceHintProcessor.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java index 4aaa230a..33b607ae 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java @@ -98,10 +98,10 @@ public List process(List inputs) { } if (roundaboutExit > 0) { roundAboutTurnAngle += sumNonConsumedWithinCatchingRange(inputs, hintIdx); - double startTurn = (roundaboudStartIdx != -1 ? inputs.get(roundaboudStartIdx).goodWay.turnangle : turnAngle); + double startTurn = (roundaboudStartIdx != -1 ? inputs.get(roundaboudStartIdx + 1).goodWay.turnangle : turnAngle); input.angle = roundAboutTurnAngle; input.distanceToNext = distance; - input.roundaboutExit = startTurn < 0 ? -roundaboutExit : roundaboutExit; + input.roundaboutExit = startTurn < 0 ? roundaboutExit : -roundaboutExit; distance = 0.; results.add(input); roundAboutTurnAngle = 0.f; @@ -284,15 +284,14 @@ public List postProcess(List inputs, double catchingRange, inputLastSaved.distanceToNext += input.distanceToNext; } } - } - else { + } else { // add all others // ignore motorway / primary continue - if ( - ((input.goodWay.getPrio() != 28) && - (input.goodWay.getPrio() != 30) && - (input.goodWay.getPrio() != 26)) - || Math.abs(input.angle) > 5.f) { // motorway / primary exit + if (((input.goodWay.getPrio() != 28) && + (input.goodWay.getPrio() != 30) && + (input.goodWay.getPrio() != 26)) + || input.isRoundabout() + || Math.abs(input.angle) > 21.f) { results.add(input); inputLastSaved = input; } else { @@ -314,8 +313,7 @@ public List postProcess(List inputs, double catchingRange, if (input.goodWay.getPrio() < input.maxBadPrio) { if (inputLastSaved != null && inputLastSaved.cmd != VoiceHint.C && (inputLastSaved != null && inputLastSaved.distanceToNext > minRange) - && transportMode != VoiceHintList.TRANS_MODE_CAR) - { + && transportMode != VoiceHintList.TRANS_MODE_CAR) { // add when straight and not linktype // and last vh not straight save = true; @@ -353,8 +351,8 @@ public List postProcess(List inputs, double catchingRange, // add when angle above 22.5 deg save = true; } else if (Math.abs(input.angle) < SIGNIFICANT_ANGLE) { - // add when angle below 22.5 deg - save = true; + // add when angle below 22.5 deg ??? + // save = true; } else { // otherwise ignore but add distance to next if (nextInput != null) { // when drop add distance to last From 91ccb858dd80da8395128e8bc8265c9f2df7bf6e Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 30 Jan 2024 18:31:34 +0100 Subject: [PATCH 09/10] undo tmp gpx name --- brouter-core/src/main/java/btools/router/FormatGpx.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/FormatGpx.java b/brouter-core/src/main/java/btools/router/FormatGpx.java index 39bb0de2..8a6f7618 100644 --- a/brouter-core/src/main/java/btools/router/FormatGpx.java +++ b/brouter-core/src/main/java/btools/router/FormatGpx.java @@ -153,8 +153,7 @@ public String formatAsGpx(BufferedWriter sb, OsmTrack t) throws IOException { sb.append(" ") .append(hint.selev == Short.MIN_VALUE ? "" : "" + (hint.selev / 4.) + "") - .append("P") - .append(""+hint.indexInTrack+"_") + .append("") .append(hint.getMessageString()) .append("") .append("").append("" + hint.distanceToNext).append(""); From b2009cf7e84fd9fafb2186e4d5f602bf64f75337 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Tue, 20 Feb 2024 12:00:59 +0100 Subject: [PATCH 10/10] more on roundabout #664 --- .../btools/router/VoiceHintProcessor.java | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java index 33b607ae..cb603907 100644 --- a/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java +++ b/brouter-core/src/main/java/btools/router/VoiceHintProcessor.java @@ -83,10 +83,21 @@ public List process(List inputs) { if (explicitRoundabouts && input.oldWay.isRoundabout()) { if (roundaboudStartIdx == -1) roundaboudStartIdx = hintIdx; roundAboutTurnAngle += sumNonConsumedWithinCatchingRange(inputs, hintIdx); + if (roundaboudStartIdx == hintIdx) { + if (input.badWays != null) { + // remove goodWay + roundAboutTurnAngle -= input.goodWay.turnangle; + // add a badWay + for (MessageData badWay : input.badWays) { + if (!badWay.isBadOneway()) roundAboutTurnAngle += badWay.turnangle; + } + } + } boolean isExit = roundaboutExit == 0; // exit point is always exit if (input.badWays != null) { for (MessageData badWay : input.badWays) { - if (!badWay.isBadOneway() && badWay.isGoodForCars() && Math.abs(badWay.turnangle) < 120.) { + if (!badWay.isBadOneway() && + badWay.isGoodForCars()) { isExit = true; } } @@ -97,12 +108,35 @@ public List process(List inputs) { continue; } if (roundaboutExit > 0) { - roundAboutTurnAngle += sumNonConsumedWithinCatchingRange(inputs, hintIdx); - double startTurn = (roundaboudStartIdx != -1 ? inputs.get(roundaboudStartIdx + 1).goodWay.turnangle : turnAngle); + //roundAboutTurnAngle += sumNonConsumedWithinCatchingRange(inputs, hintIdx); + //double startTurn = (roundaboudStartIdx != -1 ? inputs.get(roundaboudStartIdx + 1).goodWay.turnangle : turnAngle); input.angle = roundAboutTurnAngle; + input.goodWay.turnangle = roundAboutTurnAngle; input.distanceToNext = distance; - input.roundaboutExit = startTurn < 0 ? roundaboutExit : -roundaboutExit; + //input.roundaboutExit = startTurn < 0 ? roundaboutExit : -roundaboutExit; + input.roundaboutExit = roundAboutTurnAngle < 0 ? roundaboutExit : -roundaboutExit; + float tmpangle = 0; + VoiceHint tmpRndAbt = new VoiceHint(); + tmpRndAbt.badWays = new ArrayList<>(); + for (int i = hintIdx-1; i > roundaboudStartIdx; i--) { + VoiceHint vh = inputs.get(i); + tmpangle += inputs.get(i).goodWay.turnangle; + if (vh.badWays != null) { + for (MessageData badWay : vh.badWays) { + if (!badWay.isBadOneway()) { + MessageData md = new MessageData(); + md.linkdist = vh.goodWay.linkdist; + md.priorityclassifier = vh.goodWay.priorityclassifier; + md.turnangle = tmpangle; + tmpRndAbt.badWays.add(md); + } + } + } + } distance = 0.; + + input.badWays = tmpRndAbt.badWays; + results.add(input); roundAboutTurnAngle = 0.f; roundaboutExit = 0;