Reverse-engineered route-building used by the public frontend.
GdeBenz builds driving routes between the user and a station. It uses a cascade of routing providers: a first-party /api/nav/route proxy, then an optional external OSRM/Valhalla fallback. A second endpoint /api/road-route proxies OSRM for road sheets.
GET /api/nav/route?from={lat},{lon}&to={lat},{lon}
- Coordinates formatted with
.toFixed(5). - Timeout:
max(2200, round(0.6 * uv))whereuv = 7000ms (default route timeout) → ~4200 ms. - Uses
cache: "no-store".
{
"routes": [
{
"distance": 12345,
"duration": 900,
"geometry": { "coordinates": [[lon, lat], ...] },
"legs": [ { "steps": [ ... ] } ]
}
]
}Each route is parsed by bv() into:
| Field | Meaning |
|---|---|
dist |
distance (metres) |
dur |
duration (seconds) |
pts |
[lat, lon] pairs (coordinates flipped from GeoJSON [lon, lat]) |
man |
turn-by-turn maneuvers extracted from legs[].steps[] |
kv() keeps the fastest route (routes[0]) and up to 3 alternatives within 125% of its distance and duration.
wv(route, from, to) accepts a route only if the first and last points are within 2 km (Ti() haversine) of the requested endpoints.
- After 3 consecutive failures the route proxy is disabled for 5 minutes (
3e5ms,rv._pxDead). - HTTP 4xx responses reset the failure counter without disabling.
- A
700 msminimum interval is enforced between calls.
When the proxy is unavailable, the client calls OSRM directly:
https://router.project-osrm.org/route/v1/driving/{lon},{lat}[;{via_lon},{via_lat}];{to_lon},{to_lat}
?overview=full&geometries=geojson&steps=true&alternatives={3|false}[&continue_straight=false]
- With a via-point:
alternatives=false&continue_straight=false. - Without:
alternatives=3.
GET /api/road-route?from={lat},{lon}&to={lat},{lon}
- Coordinates rounded to 1/500 degree:
Math.round(500 * x) / 500. - Timeout 7 s.
- Only attempted when the direct distance ≤ 9 km.
{
"code": "Ok",
"geometry": { "coordinates": [[lon, lat], ...] },
"distance_km": 12,
"duration_s": 900
}Client processing:
codemust equal"Ok"andgeometry.coordinatesmust exist.- Coordinates flipped to
[lat, lon]; route rejected if fewer than 10 points. - Cumulative distance computed with
QI(); route rejected if total ≤ 4 km. - Produces a road object:
{
slug: "osrm", name: "", divided: "none",
len_km: Math.round(distance_km || totalKm),
pts, _cum,
milestones: [{ name: fromName || "Старт", km: 0 }],
city_zones: [], route_names: null,
_eta_s: duration_s || null,
_osrm: 1
}404→KI._osrmDead = 1(permanently disabled for the session).5xxor429→ cooldown for 60 s (KI._osrmCold).
If OSRM fails, the client falls back to a locally-computed highway route (cM() over KI.idx.highways), and shows "Между этими точками маршрут не строится" if none exists.
A secondary route builder posts to Valhalla:
POST https://valhalla1.openstreetmap.de/route
{
"locations": [...],
"costing": "auto",
"costing_options": { "auto": { "use_tolls": false } },
"directions_options": { "units": "kilometers" }
}Toll avoidance is toggled by localStorage["gb_nav_notoll"] === "1".
| Constant | Value | Meaning |
|---|---|---|
uv |
7000 ms | default nav/route timeout |
mv |
5000 ms | secondary timeout |
fv |
4000 ms | tertiary timeout |
| endpoint tolerance | 2 km | wv() endpoint acceptance |
| alternatives window | 125% | kv() distance/duration ratio |
| route proxy cooldown | 5 min | after 3 failures |
| OSRM cooldown | 60 s | on 5xx/429 |
All information was obtained from the publicly distributed JavaScript bundle. No server-side source code or private implementation details are included.