fix(graph): tiles

This commit is contained in:
vl.arkhangelskii
2026-09-21 13:48:00 +03:00
parent 236c0bc754
commit 1d71e440f9
22 changed files with 1153 additions and 265 deletions
@@ -0,0 +1,34 @@
# Graph MVT tiles + web-demo overlay
Date: 2026-09-21
## What
Road graph is now served as XYZ vector tiles (MVT, layer `roads`) and wired into `web-demo` as a MapLibre vector source instead of a GeoJSON bbox fetch.
## API
- `GET /u/{slug}/graph/{source}/{z}/{x}/{y}.pbf?token=`
- `GET /u/{slug}/graph/{source}/tiles.json?token=`
- Metadata `links.tiles` / `links.tilejson`
Encoding is on-the-fly from SQLite (`QueryEdgesInBoundsAsync`): tile Web Mercator bbox + 8% buffer, no 2° JSON cap. Cache key includes `builtAt`. Empty tiles are valid empty PBF (200). Zoom < 6 or > 18 → 204.
Highway filter by zoom so a z6 tile does not pull the whole graph:
- z ≤ 8: motorway/trunk (+ links)
- z ≤ 10: + primary
- z ≤ 12: + secondary/tertiary
- z 13+: all classes, cap 8000 features (longest first)
Layer fields: `highway`, `name`, `oneway`, `length_m`. Geometry is vertex-to-vertex LineString.
JSON bbox endpoints stay for point queries.
## web-demo
«Показать граф» adds `type: "vector"` sources for each selected extract with `graphReady`, `source-layer: roads`, orange overlay, minzoom 6 / maxzoom 14. Re-attaches after `setStyle`.
## Deploy
API must be redeployed for production `tile-server.ru`. Graph sqlite still has to exist (`graphs/{id}.sqlite` after sync with `BuildRoadGraph`).
@@ -0,0 +1,9 @@
# Cabinet graph docs and examples
Date: 2026-09-21
## What
Guides (`/guides`) step 5 is a real attach-graph instruction: load/idle, `source-layer: roads`, zooms, JSON bbox vs MVT, 404 if sqlite missing. Copy blocks include MapLibre overlay, HTML+React with graph, curl of a z14 tile at extract center, JSON pagination.
Graph page (`/graph`) has a «Примеры» section with the same snippets filled from the selected extract, bbox and token (`web/src/features/graph/graphExamples.ts`).