App 2.39.1, server 2.8.0: map roads from OpenFreeMap, on demand
The public Overpass answered 429/502 and needs ~40 s a tile while the car gives up after 8 s, so the server cancelled its queries and the car's retries added load. Now the server fetches only the tiles a car asks for, as OpenStreetMap vector tiles from OpenFreeMap (MAP_TILES_URL), decodes the transportation layer with a small reader of its own, and keeps each tile 30 days on a volume (MAP_CACHE_DIR). A fetch finishes even after the car has stopped waiting; the car hears 503 with Retry-After and gets the tile on its next try. App: OpenFreeMap/OpenMapTiles attribution on the map, retry after 15 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
+18
-12
@@ -23,7 +23,8 @@ Environment only; the server refuses to start when a required value is missing.
|
||||
| `APPROVAL_PASSWORD` | optional, at least 12 characters; switches pairing on (see below) |
|
||||
| `PUBLIC_URL` | the address a phone uses, for the pairing QR code; derived from the request if empty |
|
||||
| `FORGE_URL`, `FORGE_REPO`, `FORGE_TOKEN` | optional; app updates (below). The token only needs to read the repository |
|
||||
| `OVERPASS_URL` | the Overpass API the map's roads come from; default `https://overpass-api.de/api/interpreter`, `off` switches maps off, otherwise https only |
|
||||
| `MAP_TILES_URL` | a TileJSON naming the vector tiles the map's roads come from; default OpenFreeMap's `https://tiles.openfreemap.org/planet`, `off` switches maps off, otherwise https only |
|
||||
| `MAP_CACHE_DIR` | where fetched map tiles are kept across restarts (the manifest mounts a volume there); empty keeps them in memory only |
|
||||
| `LISTEN_ADDR` | default `:8080` |
|
||||
|
||||
## Endpoints
|
||||
@@ -60,18 +61,23 @@ download cut short`. The forge's address and token never appear in the log.
|
||||
|
||||
## Map roads
|
||||
|
||||
`POST /v1/map/roads` `{z, x, y}`, with the car's token: the drivable roads (motorway to
|
||||
residential) of one web-mercator tile at zoom 14, for the app's "Grid with map" style. The car
|
||||
names the tile, not its position, and in the body, so it stays out of access logs. The answer is
|
||||
`POST /v1/map/roads` `{z, x, y}`, with the car's token: the drivable roads (motorway to minor
|
||||
streets) of one web-mercator tile at zoom 14, for the app's "Grid with map" style. The car names
|
||||
the tile, not its position, and in the body, so it stays out of access logs. The answer is
|
||||
`{z, x, y, extent: 4096, ways: [{c, p: [x, y, …]}]}`: per road its class (0 motorway and trunk,
|
||||
1 primary and secondary, 2 tertiary and unclassified, 3 residential and living streets) and its
|
||||
points in tile units, simplified to about 1.5 m; gzipped when the car accepts it (20–30 KB a tile
|
||||
in a city before that). The roads come from OpenStreetMap through `OVERPASS_URL`, one request at
|
||||
a time and at most one a second, with a User-Agent naming this service, and are kept in memory
|
||||
for 30 days (up to 3000 tiles); the car keeps its own copy too. 400 for anything but zoom 14 or
|
||||
a tile outside it, 503 when Overpass is busy or unreachable (not cached, the car tries again a
|
||||
minute later), 404 when maps are off. The log says `map tile fetched` with the car's installation
|
||||
and the size, never the tile. Map data © OpenStreetMap contributors, ODbL.
|
||||
1 primary and secondary, 2 tertiary, 3 minor streets) and its points in tile units, simplified to
|
||||
about 1.5 m; gzipped when the car accepts it (10–15 KB a tile in a city before that).
|
||||
|
||||
The roads are fetched **only for the tiles a car asks for**: the OpenStreetMap vector tile
|
||||
(OpenMapTiles schema) of that square from the TileJSON at `MAP_TILES_URL` (by default
|
||||
OpenFreeMap: free, no key, no request limits; its template moves with each weekly build and is
|
||||
looked up every 6 hours), decoded by a small reader of our own (`mvt.go`, the `transportation`
|
||||
layer only). Each tile is fetched once and kept for 30 days in `MAP_CACHE_DIR` (and the last 300
|
||||
in memory); at most two fetches run at once. A request waits up to 6 s; a slower fetch goes on
|
||||
and is kept, and the car hears 503 with `Retry-After: 10` and gets the tile on its next try.
|
||||
400 for anything but zoom 14 or a tile outside it, 503 when the tile host fails (not cached),
|
||||
404 when maps are off. The log says `map tile fetched` with the size, never the tile.
|
||||
Map data © OpenStreetMap contributors (ODbL), tiles © OpenMapTiles, served by OpenFreeMap.
|
||||
|
||||
## Settings from a phone
|
||||
|
||||
|
||||
Reference in New Issue
Block a user