Explicitly map internal voice hint ids to external JSON API ids
As c9ae7c8
showed, changing internal ids without being aware of the
possible impact might easily lead to break the external API.
While ids could be fixated by adding respective tests, an even more
elegant solution is to make the mapping from internal ids to external
ids explicit, similar how it is already done for other voice hint
formats.
To underline the purpose of the mapping even more, the
respective method is renamed appropriately.
Test Plan:
- `./gradlew test`
- Export a complex route in BRouter-Web and check voice hints have not
been changed.
This commit is contained in:
parent
82fecf95f6
commit
d98b1060d4
2 changed files with 38 additions and 3 deletions
|
@ -1000,7 +1000,7 @@ public final class OsmTrack {
|
||||||
for (VoiceHint hint : voiceHints.list) {
|
for (VoiceHint hint : voiceHints.list) {
|
||||||
sb.append(" [");
|
sb.append(" [");
|
||||||
sb.append(hint.indexInTrack);
|
sb.append(hint.indexInTrack);
|
||||||
sb.append(',').append(hint.getCommand());
|
sb.append(',').append(hint.getJsonCommandIndex());
|
||||||
sb.append(',').append(hint.getExitNumber());
|
sb.append(',').append(hint.getExitNumber());
|
||||||
sb.append(',').append(hint.distanceToNext);
|
sb.append(',').append(hint.distanceToNext);
|
||||||
sb.append(',').append((int) hint.angle);
|
sb.append(',').append((int) hint.angle);
|
||||||
|
|
|
@ -61,8 +61,43 @@ public class VoiceHint {
|
||||||
badWays.add(badWay);
|
badWays.add(badWay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCommand() {
|
public int getJsonCommandIndex() {
|
||||||
return cmd;
|
switch (cmd) {
|
||||||
|
case TLU:
|
||||||
|
return 10;
|
||||||
|
case TU:
|
||||||
|
return 15;
|
||||||
|
case TSHL:
|
||||||
|
return 4;
|
||||||
|
case TL:
|
||||||
|
return 2;
|
||||||
|
case TSLL:
|
||||||
|
return 3;
|
||||||
|
case KL:
|
||||||
|
return 8;
|
||||||
|
case C:
|
||||||
|
return 1;
|
||||||
|
case KR:
|
||||||
|
return 9;
|
||||||
|
case TSLR:
|
||||||
|
return 6;
|
||||||
|
case TR:
|
||||||
|
return 5;
|
||||||
|
case TSHR:
|
||||||
|
return 7;
|
||||||
|
case TRU:
|
||||||
|
return 11;
|
||||||
|
case RNDB:
|
||||||
|
return 13;
|
||||||
|
case RNLB:
|
||||||
|
return 14;
|
||||||
|
case BL:
|
||||||
|
return 16;
|
||||||
|
case OFFR:
|
||||||
|
return 12;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("unknown command: " + cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExitNumber() {
|
public int getExitNumber() {
|
||||||
|
|
Loading…
Reference in a new issue