fix(traffic): fall back to TomTom Orbis flow tiles when the key is refused

TomTom keys are assigned products. A key without the TomTom Maps Traffic
product gets HTTP 403 on traffic/map/4/tile/flow, the only endpoint the
proxy called, so live traffic never loaded and the layer reported
"TomTom upstream unreachable".

- Proxy: on 403, ask the Orbis Maps flow endpoint (apiVersion 2) and keep
  whichever endpoint answered until the key changes.
- Decoder: read Orbis relative_speed and road_category into the existing
  segment shape.
- When both endpoints refuse the key, answer 403 key_rejected, report
  keyRejected on /api/tomtom/status, show "TomTom key rejected" and leave
  upstream alone for five minutes instead of spending the tile budget.

Fixes #1809
This commit is contained in:
Said Turksever committed 2026-11-20 14:33:47 +00:00
1 parent 98a26787a4
commit b711e9e412
24 files changed
+427 -12

No files matched your search

+8
View File
@@ -4027,6 +4027,14 @@ The TomTom `/api/tomtom/*` routes run the shared same-site admission gate before
status, cache or upstream work, refusing cross-site browser requests while
preserving same-origin app requests and non-browser local callers. The browser
layers and their rendering remain in their existing modules.
The proxy asks the TomTom Maps flow endpoint (`traffic/map/4/tile/flow/relative`)
first. On HTTP 403, which TomTom answers when a key is not assigned that
product, it asks the Orbis Maps one (`maps/orbis/traffic/flow/vector/tile`,
`apiVersion=2`) and keeps whichever answered until the key changes or the
process restarts; `flowDecode.js` reads both tile schemas into one segment
shape. When both refuse the key, tiles answer `403 {error:'key_rejected'}`
(shown as "TomTom key rejected"), `/api/tomtom/status` reports
`keyRejected: true`, and upstream is left alone for five minutes.
Past the daily tile budget, or while TomTom fails, the proxy answers with its
last copy of a tile (`x-tomtom-cache: STALE-BUDGET` / `STALE-ERROR`) however old
it is, and every tile carries `x-tomtom-fetched-at`, the proxy fetch time