change for voicehint list second step

This commit is contained in:
afischerdev 2023-12-22 18:25:09 +01:00
parent 01ac57a929
commit e73d0e8001

View file

@ -249,6 +249,7 @@ 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;
VoiceHint inputLastSaved = null;
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; VoiceHint nextInput = null;
@ -258,7 +259,7 @@ public final class VoiceHintProcessor {
if (nextInput == null) { if (nextInput == null) {
if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { 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); results.add(input);
} else { } else {
if (inputLast != null) { // when drop add distance to last if (inputLast != null) { // when drop add distance to last
@ -270,16 +271,37 @@ public final class VoiceHintProcessor {
results.add(input); results.add(input);
} }
} else { } else {
if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { if ((inputLastSaved != null && inputLastSaved.distanceToNext > catchingRange) || input.distanceToNext > catchingRange) {
if (input.goodWay.getPrio() < input.maxBadPrio) { if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) {
results.add(input); if (input.goodWay.getPrio() < input.maxBadPrio
} else { && (inputLastSaved != null && inputLastSaved.distanceToNext > minRange)
if (inputLast != null) { // when drop add distance to last && (input.distanceToNext > minRange)) {
inputLast.distanceToNext += input.distanceToNext; // 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) { } 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;
@ -290,12 +312,32 @@ public final class VoiceHintProcessor {
if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) { if (input.cmd == VoiceHint.C && !input.goodWay.isLinktType()) {
if (input.goodWay.getPrio() < input.maxBadPrio) { 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 } else if (VoiceHint.is180DegAngle(input.angle)) {
//System.out.println("uturn < dist next!=null " + input.indexInTrack); // add u-turn, 180 degree
save = true; 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.angle = angles;
input.calcCommand(); input.calcCommand();
input.distanceToNext += nextInput.distanceToNext; input.distanceToNext += nextInput.distanceToNext;
@ -306,24 +348,28 @@ public final class VoiceHintProcessor {
input.calcCommand(); input.calcCommand();
input.distanceToNext += nextInput.distanceToNext; input.distanceToNext += nextInput.distanceToNext;
save = true; save = true;
hintIdx++;
} else if (Math.abs(input.angle) > SIGNIFICANT_ANGLE) { } else if (Math.abs(input.angle) > SIGNIFICANT_ANGLE) {
results.add(input); // add when last // add when angle above 22.5 deg
save = false; save = true;
} else if (Math.abs(input.angle) < SIGNIFICANT_ANGLE) { } else if (Math.abs(input.angle) < SIGNIFICANT_ANGLE) {
results.add(input); // add when last // add when angle below 22.5 deg
save = false; save = true;
} else { } else {
if (inputLast != null) { // when drop add distance to last // otherwise ignore but add distance to next
inputLast.distanceToNext += input.distanceToNext; if (nextInput != null) { // when drop add distance to last
nextInput.distanceToNext += input.distanceToNext;
} }
save = false; save = false;
} }
if (save) { if (save) {
results.add(input); // add when last results.add(input); // add when last
inputLastSaved = input;
} }
} else { } else {
results.add(input); results.add(input);
inputLastSaved = input;
} }
} }
inputLast = input; inputLast = input;