Revert voice hint indexing change in JSON API to restore compatibility

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.
This commit is contained in:
Henrik Fehlauer 2023-07-11 17:57:14 +00:00
parent 2762744a84
commit 82fecf95f6
No known key found for this signature in database
GPG key ID: 177EECC0FF03B880

View file

@ -20,11 +20,11 @@ public class VoiceHint {
static final int KL = 8; // keep left
static final int KR = 9; // keep right
static final int TLU = 10; // U-turn
static final int TU = 11; // 180 degree u-turn
static final int TRU = 12; // Right U-turn
static final int OFFR = 13; // Off route
static final int RNDB = 14; // Roundabout
static final int RNLB = 15; // Roundabout left
static final int TRU = 11; // Right U-turn
static final int OFFR = 12; // Off route
static final int RNDB = 13; // Roundabout
static final int RNLB = 14; // Roundabout left
static final int TU = 15; // 180 degree u-turn
static final int BL = 16; // Beeline routing
int ilon;