Files
tile-server/context/2026-09-21_13-45-00_graph-mvt-tiles.md
2026-09-21 13:48:00 +03:00

1.3 KiB

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).