repair vh END problems

This commit is contained in:
afischerdev 2024-12-12 13:52:35 +01:00
parent 60b7cf658d
commit b9b0e21cb6
2 changed files with 22 additions and 8 deletions

View File

@ -469,6 +469,17 @@ public final class OsmTrack {
List<VoiceHint> inputs = new ArrayList<>();
while (node != null) {
if (node.origin != null) {
if (nodeNr == nodes.size() - 1) {
VoiceHint input = new VoiceHint();
inputs.add(0, input);
input.ilat = node.getILat();
input.ilon = node.getILon();
input.selev = node.getSElev();
input.goodWay = node.message;
input.oldWay = node.message;
input.indexInTrack = nodes.size() - 1;
input.cmd = VoiceHint.END;
}
VoiceHint input = new VoiceHint();
inputs.add(input);
input.ilat = node.origin.getILat();

View File

@ -29,7 +29,7 @@ public final class VoiceHintProcessor {
float angle = 0.f;
while (offset >= 0 && distance < range) {
VoiceHint input = inputs.get(offset--);
if (input.turnAngleConsumed) {
if (input.turnAngleConsumed || input.cmd == VoiceHint.BL || input.cmd == VoiceHint.END) {
break;
}
angle += input.goodWay.turnangle;
@ -72,15 +72,10 @@ public final class VoiceHintProcessor {
results.add(input);
continue;
}
if (hintIdx == 0) {
input.cmd = VoiceHint.END;
input.distanceToNext = input.goodWay.linkdist;
results.add(input);
continue;
}
float turnAngle = input.goodWay.turnangle;
distance += input.goodWay.linkdist;
if (hintIdx != 0) distance += input.goodWay.linkdist;
// System.out.println("range " + distance);
int currentPrio = input.goodWay.getPrio();
int oldPrio = input.oldWay.getPrio();
int minPrio = Math.min(oldPrio, currentPrio);
@ -260,6 +255,10 @@ public final class VoiceHintProcessor {
if (hint.cmd == 0) {
hint.calcCommand();
}
if (hint.cmd == VoiceHint.END) {
results2.add(hint);
continue;
}
if (!(hint.needsRealTurn && (hint.cmd == VoiceHint.C || hint.cmd == VoiceHint.BL))) {
double dist = hint.distanceToNext;
// sum up other hints within the catching range (e.g. 40m)
@ -455,6 +454,10 @@ public final class VoiceHintProcessor {
}
inputLast = input;
}
if (results.size() > 0) {
// don't use END tag
if (results.get(results.size()-1).cmd == VoiceHint.END) results.remove(results.size()-1);
}
return results;
}