Add BL and TLU to VoiceHints as contained in BRouter 1.7.2

abrensch/brouter@c9ae7c8681 added support for two new voice hints: A
hint for beelines (`BL`), and a hint for 180 degree u-turns (`TU`). By
adding support for both, we now know about all types of voice hints as
defined in BRouter again.

What makes things confusing is that the `TU` name for the respective
`static final int` constant in BRouter's `VoiceHint.java` was repurposed
for 180 degree u-turns, with left u-turns now being mapped to the new
`TLU` constant name. Also note that originally the indexing of voice
hints as used in BRouter's GeoJSON API has been changed as well due to
inserting new commands in the middle of the numbering scheme instead of
at the end. This API break has been fixed only in
abrensch/brouter@82fecf9. Here we will rely on the fixed indexing,
BRouter versions 1.7.0 and 1.7.1 without the re-indexing revert will not
be supported.

In addition, the voice hint mapping table has been checked to be
identical to BRouter (this led to adding a missing `OFFR` symbol), and
clarifying comments for planned future changes (e.g. changing the `TU`
output token to `TLU` for OsmAnd) have been added.

Note that beelines and 180 degree u-turns are only added to the mapping
table for completeness. As BRouter-Web is handling straight lines on the
client-side exclusively (which makes sense performance-wise when loading
a route from a pasted URL with lots of them tracing an unmapped path),
they are not expected to be in any GeoJSON response from BRouter, at
least as of now. The same is true for 180 degree u-turn voice hints at
cul-de-sac-style vias. If and when to emit voice hints for both cases in
BRouter-Web itself is a different question, though it could likely also
use the table for lookup.

Test Plan:
  - `yarn test`
  - Confirm voice hints for routes with roundabouts and u-turns are
  unchanged.
This commit is contained in:
Henrik Fehlauer 2023-07-05 06:26:07 +00:00
parent b64b3c6910
commit 3f241c9180
No known key found for this signature in database
GPG key ID: 177EECC0FF03B880

View file

@ -116,6 +116,7 @@
// from BRouter btools.router.VoiceHint
VoiceHints.commands = (function () {
return {
// Command(name, locus, orux, symbol, fit, message)
1: new Command('C', 1, 1002, 'Straight', 'straight', 'straight'),
2: new Command('TL', 4, 1000, 'Left', 'left', 'left'),
3: new Command('TSLL', 3, 1017, 'TSLL', 'slight_left', 'slight left'),
@ -125,11 +126,19 @@
7: new Command('TSHR', 8, 1018, 'TSHR', 'sharp_right', 'sharp right'),
8: new Command('KL', 9, 1015, 'TSLL', 'left_fork', 'keep left'),
9: new Command('KR', 10, 1014, 'TSLR', 'right_fork', 'keep right'),
10: new Command('TU', 13, 1003, 'TU', 'u_turn', 'u-turn'),
// According to getCommandString() in BRouter, Command.name==TU for index TLU
// "should be changed to TLU when osmand uses new voice hint constants"
// According to getMessageString() in BRouter, Command.message==u-turn for index TLU
// "should be changed to u-turn-left when osmand uses new voice hint constants"
10: new Command('TU', 13, 1003, 'TU', 'u_turn', 'u-turn'), // Left U-turn
// According to getMessageString() in BRouter, Command.message==u-turn for index TRU
// "should be changed to u-turn-right when osmand uses new voice hint constants"
11: new Command('TRU', 14, 1003, 'TU', 'u_turn', 'u-turn'), // Right U-turn
12: new Command('OFFR', undefined, undefined, undefined, 'danger', undefined), // Off route
12: new Command('OFFR', undefined, undefined, 'OFFR', 'danger', undefined), // Off route
13: new Command('RNDB', 26, 1008, 'RNDB', 'generic', 'Take exit '), // Roundabout
14: new Command('RNLB', 26, 1008, 'RNLB', 'generic', 'Take exit '), // Roundabout left
15: new Command('TU', 12, 1003, 'TU', 'u_turn', 'u-turn'), // 180 degree u-turn
16: new Command('BL', undefined, undefined, 'BL', 'danger', undefined), // Beeline
};
})();