Skip to content

Commit

Permalink
Document new export formats added in BRouter 1.7.0 and fix export error
Browse files Browse the repository at this point in the history
BRouter 1.7.0 implemented support for three new export formats:
"Cruiser", "BRouter internal" and "Locus(-new)".

"Cruiser" (`turnInstructionMode=8`) and "BRouter internal"
(`turnInstructionMode=9`) are not yet exposed in BRouter-Web's UI
through profiles, so we do not need to implement them at the moment.
Here we only document them by making them explicit unimplemented `cases`
in the code.

In addition, BRouter changed "locus-style" with `turnInstructionMode=2`
to emit a different format for newer releases of Locus, while the old
format is now referred to as "locus-old-style" from profiles with
`turnInstructionMode=7`. Since BRouter-Web does not know yet about the
the new id, exports will fail with "unhandled turnInstructionMode"
errors.

To fix the latter issue, we now map `turnInstructionMode=7` to the newly
renamed `LocusOldVoiceHints()`. Note that `turnInstructionMode=2` is
also currently using `LocusOldVoiceHints()`, i.e. the new format still
needs an implementation.

Test Plan:
  - `yarn test`
  - Check choosing "locus-old-style" now exports without an error.
  • Loading branch information
rkflx committed Jul 7, 2023
1 parent eeb1c5b commit 96016b7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/format/VoiceHints.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
}
}

class LocusVoiceHints extends WaypointVoiceHints {
class LocusOldVoiceHints extends WaypointVoiceHints {
_addToTransform(transform) {
transform.gpx = function (gpx, features) {
// hack to insert attribute after the other `xmlns`s
Expand Down Expand Up @@ -364,7 +364,10 @@
BR.voiceHints = function (geoJson, turnInstructionMode, transportMode) {
switch (turnInstructionMode) {
case 2:
return new LocusVoiceHints(geoJson, turnInstructionMode, transportMode);
// TODO:
// Use locus-old-style voice hints for now (same style as returned by BRouter 1.6.3
// for turnInstructionMode=2), implementation for new-style locus still missing.
return new LocusOldVoiceHints(geoJson, turnInstructionMode, transportMode);
case 3:
return new OsmAndVoiceHints(geoJson, turnInstructionMode, transportMode);
case 4:
Expand All @@ -373,6 +376,10 @@
return new GpsiesVoiceHints(geoJson, turnInstructionMode, transportMode);
case 6:
return new OruxVoiceHints(geoJson, turnInstructionMode, transportMode);
case 7:
return new LocusOldVoiceHints(geoJson, turnInstructionMode, transportMode);
case 8: // Cruiser export, not exposed in the web UI through profiles yet
case 9: // BRouter internal export, not exposed in the web UI through profiles yet
default:
console.error('unhandled turnInstructionMode: ' + turnInstructionMode);
return new VoiceHints(geoJson, turnInstructionMode, transportMode);
Expand Down

0 comments on commit 96016b7

Please sign in to comment.