Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert voice hint reindexing #594

Merged
merged 2 commits into from
Jul 17, 2023
Merged

Revert voice hint reindexing #594

merged 2 commits into from
Jul 17, 2023

Conversation

rkflx
Copy link
Collaborator

@rkflx rkflx commented Jul 17, 2023

Split out from #591 as requested.

See comments there and commit messages for why we need this.

a9e8731 made voice hints available from `formatAsGeoJson()`, which is
used both in the GeoJSON HTTP API and in the JSON Java API. To indicate
a specific type of voice hint, it was chosen to include its numeric id
in the output JSON array among other data. The full list of available
ids was defined in `class VoiceHint`, e.g. `static final int C = 1;`.

Consumers of the API now depended on the mapping from id to intended
voice hint not changing, since otherwise incorrect voice hints could be
displayed. Unfortunately that API contract was broken in c9ae7c8, where
instead of assigning unused ids to new commands, the meaning of existing
ids was changed. This broke compatibility: Clients adapted to the change
did not work with the old indexing anymore, and clients not yet adapted
would break with newer BRouter releases, e.g. they would suddenly
display "Off route" for a "right u-turn".

To restore compatibility, the indexing is reverted to its old state.

This will unbreak GeoJSON/JSON API users no yet adapted to BRouter 1.7.0
or 1.7.1, e.g. BRouter-Web as well as unmaintained clients. While API
users which already patched ids would need to undo or special-case their
changes, the impact is believed to be low, as no such users are
currently known and the breakage was released only recently.

The changed meaning of `TU` in output formats (before: `u-turn-left`,
now: `u-turn-180`) has not been reverted for now, since either that
command is mapped to fallback solutions anyway (e.g. Orux, old Locus,
Gpsies), the change has already been implemented in clients (new Locus,
Cruiser) or was only planned to be implemented in the future (OsmAnd).

Fixes #584

Test Plan:
  - `./gradlew test`
  - Run BRouter with an unpatched BRouter-Web and confirm voice hint
  ids have been restored to the same ones as emitted by BRouter 1.6.3.
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.
@rkflx rkflx temporarily deployed to BRouter July 17, 2023 09:07 — with GitHub Actions Inactive
@afischerdev afischerdev merged commit 22cf0bb into abrensch:master Jul 17, 2023
@rkflx rkflx deleted the PR/only-revert-voicehint-reindexing branch July 26, 2023 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants