enable new post process on voicehints

This commit is contained in:
afischerdev 2023-10-06 14:57:46 +02:00
parent 90fbe8345a
commit c07454a8ba
2 changed files with 63 additions and 52 deletions

View file

@ -44,6 +44,7 @@ public class VoiceHint {
float angle = Float.MAX_VALUE; float angle = Float.MAX_VALUE;
boolean turnAngleConsumed; boolean turnAngleConsumed;
boolean needsRealTurn; boolean needsRealTurn;
int maxBadPrio;
int roundaboutExit; int roundaboutExit;

View file

@ -147,6 +147,7 @@ public final class VoiceHintProcessor {
if (badPrio > maxPrioCandidates) { if (badPrio > maxPrioCandidates) {
maxPrioCandidates = badPrio; maxPrioCandidates = badPrio;
input.maxBadPrio = Math.max(input.maxBadPrio, badPrio);
} }
if (badTurn > maxAngle) { if (badTurn > maxAngle) {
maxAngle = badTurn; maxAngle = badTurn;
@ -158,6 +159,7 @@ public final class VoiceHintProcessor {
} }
boolean hasSomethingMoreStraight = (Math.abs(turnAngle) - minAbsAngeRaw) > 20.; boolean hasSomethingMoreStraight = (Math.abs(turnAngle) - minAbsAngeRaw) > 20.;
//boolean hasSomethingMoreStraight = (Math.abs(turnAngle - minAbsAngeRaw)) > 20.;
// unconditional triggers are all junctions with // unconditional triggers are all junctions with
// - higher detour prios than the minimum route prio (except link->highway junctions) // - higher detour prios than the minimum route prio (except link->highway junctions)
@ -244,18 +246,16 @@ public final class VoiceHintProcessor {
List<VoiceHint> results = new ArrayList<>(); List<VoiceHint> results = new ArrayList<>();
double distance = 0; double distance = 0;
VoiceHint inputLast = null; VoiceHint inputLast = null;
ArrayList<VoiceHint> tmpList = new ArrayList<>();
for (int hintIdx = 0; hintIdx < inputs.size(); hintIdx++) { for (int hintIdx = 0; hintIdx < inputs.size(); hintIdx++) {
VoiceHint input = inputs.get(hintIdx); VoiceHint input = inputs.get(hintIdx);
VoiceHint nextInput = null;
if (hintIdx + 1 < inputs.size()) {
nextInput = inputs.get(hintIdx + 1);
}
if (nextInput == null) {
if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) {
int badWayPrio = 0; if (input.goodWay.getPrio() < input.maxBadPrio) {
if (input.badWays != null) {
for (MessageData md : input.badWays) {
badWayPrio = Math.max(badWayPrio, md.getPrio());
}
}
if (input.goodWay.getPrio() < badWayPrio) {
results.add(input); results.add(input);
} else { } else {
if (inputLast != null) { // when drop add distance to last if (inputLast != null) { // when drop add distance to last
@ -264,60 +264,70 @@ public final class VoiceHintProcessor {
continue; continue;
} }
} else { } else {
if (input.distanceToNext < 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;
}
}
} else if (input.distanceToNext < catchingRange) {
int badWayPrio = 0;
double dist = input.distanceToNext; double dist = input.distanceToNext;
float angles = input.angle; float angles = input.angle;
int i = 1; int i = 1;
boolean save = true; boolean save = false;
tmpList.clear();
while (dist < catchingRange && hintIdx + i < inputs.size()) { dist += nextInput.distanceToNext;
VoiceHint h2 = inputs.get(hintIdx + i); angles += nextInput.angle;
dist += h2.distanceToNext;
angles += h2.angle; if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) {
if (VoiceHint.is180DegAngle(input.angle) || VoiceHint.is180DegAngle(h2.angle)) { // u-turn, 180 degree if (input.goodWay.getPrio() < input.maxBadPrio) {
save = true;
}
} 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; save = true;
break;
} else if (Math.abs(angles) > 180 - SIGNIFICANT_ANGLE) { // u-turn, collects e.g. two left turns in range } else if (Math.abs(angles) > 180 - SIGNIFICANT_ANGLE) { // u-turn, collects e.g. two left turns in range
input.angle = angles; input.angle = angles;
input.calcCommand(); input.calcCommand();
input.distanceToNext += h2.distanceToNext; input.distanceToNext += nextInput.distanceToNext;
save = true; save = true;
hintIdx++; hintIdx++;
break;
} else if (Math.abs(angles) < SIGNIFICANT_ANGLE && input.distanceToNext < minRange) { } else if (Math.abs(angles) < SIGNIFICANT_ANGLE && input.distanceToNext < minRange) {
input.angle = angles; input.angle = angles;
input.calcCommand(); input.calcCommand();
input.distanceToNext += h2.distanceToNext; input.distanceToNext += nextInput.distanceToNext;
save = true; save = true;
hintIdx++;
break;
} else if (Math.abs(input.angle) > SIGNIFICANT_ANGLE) { } else if (Math.abs(input.angle) > SIGNIFICANT_ANGLE) {
tmpList.add(h2); results.add(input); // add when last
hintIdx++; save = false;
} else if (dist > catchingRange) { // distance reached } else if (Math.abs(input.angle) < SIGNIFICANT_ANGLE) {
break; results.add(input); // add when last
save = false;
} else { } else {
if (inputLast != null) { // when drop add distance to last if (inputLast != null) { // when drop add distance to last
inputLast.distanceToNext += input.distanceToNext; inputLast.distanceToNext += input.distanceToNext;
} }
save = false; save = false;
} }
i++;
}
if (save) { if (save) {
results.add(input); // add when last results.add(input); // add when last
if (tmpList.size() > 0) { // add when something in stock
results.addAll(tmpList);
hintIdx += tmpList.size() - 1;
}
} }
} else { } else {
results.add(input); results.add(input);
} }
}
inputLast = input; inputLast = input;
} }
}
return results; return results;
} }
} }