Commit graph

19 commits

Author SHA1 Message Date
Simon Legner
76f31aeb2b refact: use shorthand method and property syntax 2024-10-19 13:44:15 +02:00
Henrik Fehlauer
8809fa94cf
Prevent Gpsies-style export from throwing for undefined symbols
While abrensch/brouter@82fecf9 fixed the export already by avoiding the
problematic `OFFR` voice hint, we would still throw in case we
encountered an `undefined` symbol entry:

> Uncaught TypeError: Cannot read properties of undefined (reading
> 'toLowerCase')

This can be prevented by not calling `toLowerCase()` on `undefined`
objects.

Fixes #751

Test Plan:
  - Change `VoiceHints.commands` to contain `undefined` entries for a
  particular voice hint.
  - Create a route with that voice hint.
  - Test that exporting for each `turnInstructionMode` does not throw.
2023-07-08 09:50:13 +00:00
Henrik Fehlauer
96016b7fd0
Document new export formats added in BRouter 1.7.0 and fix export error
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.
2023-07-07 16:44:21 +00:00
Henrik Fehlauer
3f241c9180
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.
2023-07-05 06:26:07 +00:00
Tobias
3e81d80cc5 Added new export as FIT file format fixes #322
Actual FIT encoding logic created as a new repo "fit-file-writer"
2022-09-14 21:02:50 +02:00
Norbert Renner
393a3fa129 Cleanup and credits 2021-04-09 11:52:51 +02:00
Norbert Renner
7caa7aeba6 Keep trkpt and wpt on single line
to better match BRouter output
2021-03-27 15:19:03 +01:00
Norbert Renner
7fc2f6bee5 Format route points as waypoints 2021-03-18 18:04:57 +01:00
Norbert Renner
449a24e5ce Refactor VoiceHints to ES6 classes 2021-03-17 10:25:02 +01:00
Norbert Renner
2189d68af9 Parse voicehint modes form profile 2021-03-16 19:56:02 +01:00
Norbert Renner
25f8828ae7 Concatenate total track
+ handle server voicehint time removed, times with 3 digits
2021-03-12 21:20:35 +01:00
Norbert Renner
954812cf52 Use togpx fork for now
- with PR 11 merged
- referencing jxon fork with namespace prefixes fixed
2021-03-09 08:15:52 +01:00
Norbert Renner
4c27f5894c Handle missing voicehints and times 2021-03-09 07:53:26 +01:00
Norbert Renner
819d0fbf22 Format OruxMaps voice hints 2021-03-01 21:01:16 +01:00
Norbert Renner
8f2261037c Format OsmAnd voice hints 2021-03-01 21:01:16 +01:00
Norbert Renner
ea564006e9 Format comment style voice hints 2021-03-01 21:01:16 +01:00
Norbert Renner
e34e6a4cb0 Refactor voice hints into subclasses 2021-03-01 21:01:16 +01:00
Norbert Renner
fd0ece0d31 Format Locus voice hint, with additional hint data 2021-03-01 21:01:16 +01:00
Norbert Renner
a9d27b4674 Format basic voice hint
Use togpx fork for now (outdated), see PR:
https://github.com/tyrasd/togpx/pull/11
2021-03-01 21:01:16 +01:00