Files
maptool/TODO.adoc
T

473 lines
47 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
= TODO — implementation ideas
Ideas for offline use in a camper van. Implement incrementally, grouped by topic.
The local server has access to both the vehicle's hardware and offline data — the
vision is to grow it into a complete offline control center: resources, data, and
independence from connectivity.
== Offline data and cartography
* [x] Offline vector tiles (PMTiles/MBTiles) for Europe/world via Planetiler or MapTiler — Geofabrik per-country extracts, `osmium merge`, Planetiler's default OpenMapTiles profile straight to PMTiles (`lib/maptool/pmtiles_builder.rb`); offline now shares the exact same style/palette as online (`ONLINE_STYLE_PATCH`) instead of a separate protomaps-schema theme
* [x] Shaded relief / DEM layer — hillshade toggle in the sidebar, sourced from public Terrarium tiles online; reads `data/terrain.pmtiles` for offline if one's been generated (see docs/development.adoc), otherwise the toggle is online-only for now
** [ ] Terrain slope readout for parking (numeric, not just visual shading)
* [ ] Contour lines from OSM for hikes and mountain passes
* [x] Hiking trail overlay — Waymarked Trails raster tiles online (`public/js/hiking_trails.js`), colored per-route by the OSM `colour` tag they already render (the KST/KČT paint-blaze colors in Slovakia/Czechia, plain red elsewhere). Click queries a one-off Overpass `around` search (racing 3 public mirrors) for the route's name/colour/network/operator/distance
** [x] Offline copy wired in for real, no custom Planetiler profile needed — `Maptool::HikingTrails` (`lib/maptool/hiking_trails.rb`) runs `osmium tags-filter r/route=hiking` + `add-locations-to-ways` + `cat -f opl` against the *same* per-country Geofabrik `.osm.pbf` already downloaded for `offline.pmtiles`, no new download. One `data/hiking_trails/<CODE>.geojson` per country (not one combined file), generated as the last step of every offline build and cached like `geofabrik_cache` (skipped once already newer than its source PBF) — a many-country selection no longer means one giant file, since `GET /api/hiking-trails` lists available countries and the Overlays panel's own checklist only fetches `GET /tiles/hiking_trails/<CODE>.geojson` for whichever ones get ticked. Offline click uses a local `queryRenderedFeatures` hit-test instead of Overpass — instant, no network. See docs/development.adoc
* [x] Overpass/OSM scripts to extract POIs (drinking water, dump stations, LPG, public toilets, laundromats, shops, springs) — `rake overpass:pois`, see docs/development.adoc; writes a `.geojson` to drop in `data/gpx/` or upload. Also runnable from inside the app itself now, see the import plugins entry below (`plugins/overpass-pois` wraps this same query). Each category now carries a real `POI_ICONS` glyph and color (not p4n2gpx's plain red marker) plus a popup description built from opening_hours/operator/website tags
* [x] Import plugins: a pluggable way to add more data sources (Park4Night, iOverlander, Freecampsites, ...) without their scrapers necessarily living in this (public) repo — sidebar icon (logged in only) lists whatever's under `plugins/`, "Run for this area" uses the current map viewport as the bbox, no separate area-picker needed. Contract: a `plugin.json` manifest + a script that reads `--south`/`--west`/`--north`/`--east` and prints a GeoJSON `FeatureCollection` to stdout (`lib/maptool/plugins.rb`, `GET /api/plugins`, `POST /api/plugins/:name/run`) — output saved the same way an upload would be. `plugins/overpass-pois` ships as the reference example; a private/ToS-sensitive scraper just drops its own directory in locally and is never `git add`ed
** [x] Park4Night — private plugin (`data/plugins/p4n2gpx/`, outside this repo per the "ToS-sensitive scraper" note above); iOverlander/Freecampsites still open, same story
** [ ] Along the planned route (2026-12-01): Park4Night and overpass-pois fetch the whole
viewport/bbox today — a second mode for a corridor around the route (a few km either side):
the plugin contract gains the route (a polyline / buffered boxes, not one big bbox), the
results into the trip's folder
** [x] A private plugin's own dependencies now have somewhere to live too: `data/plugins/` is under the persistent `data/` bind mount (survives a redeploy, unlike `build/`), and `docs/deployment.adoc` documents the convention
* [x] Kiwix/ZIM offline Wikipedia linked to POI GPS coordinates — proxied through this app (`GET /kiwix/*` in app.rb) rather than a direct link to kiwix-serve — production sits behind a reverse proxy that only forwards to this app, so no address exists for a browser to reach kiwix-serve at directly; kiwix-serve runs with `--urlRootLocation=/kiwix` so its own emitted links already match. `KIWIX_URL` + `GET /api/kiwix` reachability check, same optional-integration pattern as offline.pmtiles/terrain.pmtiles; `docker-compose.yaml` now runs a `kiwix` service, ZIM not included (see docs/development.adoc for where to get one)
** [x] Replaced the old per-popup "Nearby on Wikipedia" link (one POI at a time, easy to miss) with a standalone "Wikipedia" layer under Tracks & Points — a live `GET /api/kiwix/nearby` refetch on every pan/zoom, not a saved file. kiwix-serve's own geo search never echoes back a result's coordinates, so `Maptool::Kiwix.nearby` fetches each matching article's own page too and reads its `<meta name="geo.position">` tag — verified against the real production ZIM (~1.6s for a 30-result page; tried parallelizing those fetches with threads, no measured gain, kept sequential)
* [x] Cache weather forecast when temporarily connected — Open-Meteo 3-day forecast in the Radar flyout, last successful fetch cached in localStorage as a fallback when offline
** [x] Cache the radar tile *images* too — `public/sw.js`, network-falling-back-to-cache for RainViewer tile requests, registered from layout.erb
== NPS visual style
* [x] Map Park4Night/OSM place types to NPS pictograms (campground, primitive camp, drinking water, dump station, viewpoint, picnic table) for instant recognition without reading text — verified against real p4n2gpx exports (`data/gpx/p4n_*.gpx`, ~5000 waypoints, 15 distinct `<type>` values): every one already resolves to a registered `POI_ICONS` key, 0 waypoints fall back iconless. Drinking water/dump station aren't standalone p4n place types (they're description tags on a camping spot, already shown via `PARK4NIGHT_TAGS`); viewpoint doesn't appear in these exports but has an icon (`tourism_viewpoint`) ready if it ever does
* [ ] Restyle popovers, side panels, and point detail views after the NPS Unigrid layout system (Massimo Vignelli) with Frutiger/Rawlinson Roadside-style typography
** [x] Top black banner (full width): "MAPTOOL" on the left, live map-center coordinates in the center, offline-data status dot on the right, white sans-serif type — DEM elevation and a hamburger menu skipped (no DEM layer yet; sidebar isn't mobile-collapsed, so nothing for a hamburger to reveal)
** [ ] Point detail/sidepanel: black header banner with white location name and an NPS pictogram in the corner; amenities (water, waste, power, slope) shown as a pictogram grid, no extra text; action buttons for "route here" (Valhalla), "start leveling", "save offline"
** [x] Filter panel as a "Unigrid Matrix" — an icon grid to toggle categories on/off, styled like the legend on an official NPS paper map, instead of plain dropdowns
* [ ] Custom vector style (MVT/MapLibre) using the NPS color palette — muted natural tones for forests, water, and contours — so POIs and routes stand out at high zoom
** [x] Landuse & protections: national parks keep the flat Park Tiles sage, other protected areas (nature reserves, landscape areas, …) a translucent gray-green with a dashed edge, strict reserves / natural monuments a step darker than landscape areas (substring of the class again, `STRICT_RESERVE`), military areas red-hatched (`protectedAreasAndTextures` in `public/js/map_themes.js`). National parks are told apart by substring of OpenMapTiles' park `class` (the OSM protection_title when there is one, so it's per-language)
*** [ ] Private land — not in the OpenMapTiles schema (no access tags on landuse); needs our own Planetiler layer or an Overpass overlay
** [x] OpenTopoMap-style `fill-pattern` texture for forest (tree icons) and meadow/pasture (grass texture) landcover, instead of flat fill colors — Liberty's own sprite (`public/vendor/liberty-sprite/`) only has a `wetland` dot pattern, no tree/grass, so this needs custom pattern images added to the sprite sheet; works offline and online alike since it's just a style/sprite change, unlike pulling in OpenTopoMap's own raster tiles (online-only, restrictive tile-usage policy, wouldn't match the NPS palette) — done without touching the sprite: the patterns are drawn on a canvas on MapLibre's `styleimagemissing` (`patternImage`), grass from 13, scrub / dwarf pine (kosodrevina, `subclass=scrub`) its own tint + bushes from 11, with night variants. Forest texture dropped after a field test: too busy, and OSM rarely says broadleaf/needleleaf anyway
** [x] Elevation-tinted terrain — a `color-relief` layer (hypsometric tint, this app's own green→brown→gray palette) under the hillshade layer, same "Terrain shading" toggle
** [x] Road hierarchy: clearly distinguish paved roads from unpaved/gravel/track — critical for knowing if the camper can get there
** [x] Park Tiles "Standard" look as the base map — `PARK_TILES_PATCH` in `public/js/map_themes.js`, colors sampled from the Park Tiles legend swatches (values in `docs/nps-resources.adoc`): flat sage park areas above landcover with a tint band inside the boundary, cream land, Park Tiles road colors. Replaced the looser `ONLINE_STYLE_PATCH` palette (briefly both, switchable, to compare); map legend at `/symbols.html`
== Main menu reorganization (4 modules)
* [ ] Explorer: place filters (Park4Night + OSM layers: water, waste, LPG, showers); map layers (contours, hillshade, satellite cache)
* [ ] Navigation & route: offline router (Valhalla) with vehicle dimensions (height, weight, width); route elevation profile and isochrones
* [ ] Offline hub: manager for downloaded PMTiles (country vector maps); downloaded Wikipedia archives; cached radar and weather
* [ ] Camper & HW: level gauge (wheel-chock leveling); solar calculator (sun path on the map); telemetry (Victron / Home Assistant)
== Custom layers & data
* [x] GPX/GeoJSON drag-and-drop import (Wikiloc, Komoot, own GPX tracks — also FIT), auto-styled by category with a generated elevation profile — KML not supported (only GPX/FIT/GeoJSON/.zip)
* [x] User overlay: offline drawing of custom points with notes (e.g. "turning space for a long vehicle", "narrow gate", "good swimming spot") — one click on the map, pick or name a `.geojson` layer, saved into the same GpxStore the Tracks panel already reads (so visibility/popup come for free)
** [x] Save a distance/area shape as a note too — Measure already draws these by hand, so a "Save" button there (not a second click-to-draw UI in the notes tool) reuses that instead of duplicating it; both share one `NoteSaveForm` (notes.js). `gpx.js`'s `_addLayers` now renders Polygon and note-flagged LineString features (fill/outline, dashed line), not just points
** [x] Edit/delete individual notes from their popup (logged-in only) — targets a feature by a client-generated `properties.id` (`GpxStore#update_feature`/`#delete_feature`), not array position
** [x] Measure's vertices are draggable (mousedown + move, `event.preventDefault()` to stop the map's own drag-pan) and deletable (click to select — shown in yellow — then Delete/Backspace)
** [x] Fixed: a note saved before `properties.id` existed (the earliest test notes) had no Edit/Delete-able target — the popup no longer offers them without an id, and `rake gpx:backfill_note_ids` assigns one to any pre-existing Note feature missing it
** [x] Title + body split (name in the black header, body in a separate field) with light self-authored markdown (`**bold**`, `*italic*`, auto-linked URLs) in the body — a *new*, separate `formatNoteBody` (not `formatDescription`, which stays plain/untrusted-safe for uploaded GPX/park4night content per docs/nps-resources.adoc's earlier markdown-rendering call)
** [x] Gated behind login: NotesControl isn't added to the map at all when logged out, Measure's "Save as note" button is hidden (Measure itself stays usable either way)
** [x] The clicked point stays marked on the map while the note form is open (a plain `Marker`, removed on save/cancel/deactivate) — it was disappearing back into the flat map with nothing showing where the note would land
** [x] Icon picker for point notes (a grid in the save form) — extends `POI_ICONS` with more of the symbols `PARK4NIGHT_TAGS` already vendors (water, dump station, toilets, playground, viewpoint, swimming, fishing, climbing, hiking, …), reusable as real marker-badge glyphs, not just inline tag icons. Hidden for a Measure-drawn line/polygon note — no single spot for a badge to sit at
** [x] Fixed: the Save button's own blue background was losing to `.notes-panel__actions button`'s gray — same class-vs-class+element specificity trap as `.gpx-panel__action[hidden]` already has a comment about elsewhere in this file, just not yet applied here
** [x] Fixed: the Unigrid Matrix category filter only re-sliced the *points* source (`_applyCategoryFilter`) — toggling the "Note" category off hid point notes but not polygon/line ones sharing that category. `_linesByPath` now tracks those alongside `_pointsByPath`, re-sliced/scanned the same way
* [ ] Offline satellite tile caching (e.g. ESRI) for a selected route area — key for judging surface quality and obstacles when wild camping
== Search
* [x] Unified search box — one query across every data source, not just what's currently on the map. `GET /api/search` (`lib/maptool/search.rb`) for local sources, online ones queried from the browser (`public/js/search.js`)
** [x] Every layer under Tracks & Points (GPX, FIT, GeoJSON, notes, plugin output) and offline hiking trails — shown *and* hidden ones. Matches name + description, case/diacritics-insensitive ("kosice" finds "Košice"); parsed features cached in memory per file by mtime
** [x] Offline vector data — every named OSM object in each country's Geofabrik `.osm.pbf` (`osmium tags-filter nwr/name` + `osmium export -f geojsonseq`) into a SQLite FTS5 index, `data/places/<CODE>.sqlite` (`lib/maptool/places.rb`), built as the last offline-build step ("indexing places") and cached by mtime like hiking trails. Prefix + diacritics-insensitive matching, street segments merged per ~2 km cell; named buildings, land-use areas, `place=locality`/`isolated_dwelling` and objects with no recognized kind dropped (a shop in a building stays), names searchable without their apostrophes ("mcdonalds") and by `brand`. `Places::SCHEMA_VERSION` makes `rake places:index` rebuild older indexes by itself
** [x] Every result shows where it was found (layer file / "Hiking trails SK" / "Online · Nominatim"); clicking one zooms to it (fitBounds for a track) and switches its layer on if it was off
** [x] Source checklist in the search panel (all on by default), re-runs the search on change
** [x] Online sources pluggable — one more entry in search.js's `SOURCES`; Nominatim already in, its failure only adds a "no connection" line under the local results
** [x] Kiwix as a source — full-text search of the ZIM (`Kiwix.search`), each hit's coordinates read from its page like the Wikipedia layer does; clicking opens the article (and jumps to it when it has coordinates)
** [x] Nearest first — every result carries its distance from the map center and the list is sorted by it across all sources; settlements count as closer (city x0.01 … suburb x0.3, `Places::DISTANCE_WEIGHT`) so a town's name still finds the town. Nominatim gets the visible area as a (non-restricting) `viewbox`
== Sync with OsmAnd / Locus / mapy.com
* [x] Installable PWA with a share target — `public/manifest.webmanifest`, `public/sw.js` parks files shared from Android's share sheet (OsmAnd, Locus, mapy.com — the last has no API at all), `public/js/share_import.js` offers to import them into a Tracks & Points folder (login required, files wait until then)
* [x] Item-based library replacing the file-based `GpxStore`, phase 1 — `lib/maptool/library.rb`, design in `docs/library-design.adoc`; old files migrated as layers in subfolders
* [x] Library phase 2 — rename/recolor tracks, routes and layers, rename and move (drag) folders, split a migrated layer into items (its notes become items, keeping their ids)
* [x] Change feed + GPX export flavors for OsmAnd/Locus — `/api/library/changes`, folder menu → Export for Locus (GPX) / OsmAnd (zip)
* [ ] Android sync client (MapTool → apps first; apps → MapTool only if their APIs can list data)
== Tablet-friendly planning UI
The app is already reachable from the internet behind login, so a tablet is enough to
plan from — the server does the heavy lifting. The UI is built for a mouse today.
* [ ] Touch targets ≥ 44 px (tree rows, panel buttons, icon grids)
** [x] Route markers: an invisible 48px grab area around the dot (a finger missed the 26px dot and panned the map)
** [x] Tracks & Points open/close arrows: a 24×28 px hit area, 36×40 on touch screens
** [x] Notes can be moved (Move in the popup: drag the marker or tap the new spot), and new/edited points get an icon, a color and B/I buttons
* [ ] Nothing reachable only by hover — tooltips and flyouts must open on tap too
* [ ] A touch substitute for the Alt+click debug inspector (e.g. long-press)
* [x] Side panels as an overlay in portrait instead of a pinned column — under 640 px the pin is ignored and the panel floats over the map at full width (a pinned 300 px panel left the phone a sliver of map); a real bottom sheet still open
* [x] Driving mode (field test in the car, 2026-11): tiny icons and lists can't be hit while driving — a separate big-button UI for the few things needed on the road (navigate/follow, night mode, zoom, layer presets) rather than enlarging every planning panel. Done: "Drive" in the topbar (`driving.js`), per device — Follow, zoom, 2D/3D, night, route overview, exit down the left side; the sidebar and panels hidden
** [ ] Layer presets on the driving bar
** [x] The bar after the research (docs/design.adoc, "Buttons while driving"): four buttons
(zoom ±, view, overview), Follow and "Back to the position" one button shown only when not
following, 76×76 px; night and exit off the bar
** [ ] Softkeys: the CAN keypad's labels on the screen edge next to its keys (G1000 style)
** [x] The Trip menu beside the map, not over it (Android Auto's side panel, seen again in
signalk-pypilot-newui): the map narrower, its buttons kept, its center (follow, crosshair,
overview) in what's seen — the car was hidden under the panel before (2026-12-02)
** [x] Driving menu, Trip: the stops as 76 px rows (tap to look, ↑ ↓ ✕), a stop at the
crosshair, the start moved to the car (`driving.js`, `RoutePanelControl#stops` & co.)
Then: search (saved points + offline places, nearest the crosshair first, + adds), each
leg's km and time and the total; passed stops dimmed and still editable — a reroute marks
them `passed` (kept in the trip, not routed) instead of dropping them, ✓ marks one by
hand (a stop missed out: add it, move it up with ↑, ✓)
** [ ] The trip as plan + log (2026-12-01): start → the server records the trip log (GNSS,
no screen needed) → stops added on or off the route (on foot: not routed, still the
trip's) → end → one library item: the planned route, the driven track, the points with
their visit times. A point's two properties apart: routed or not, and planned / visited
(at) / skipped — `passed` splits into them; visited by the track passing near or by hand
The car's GNSS stays in the car: on foot the log is the car standing. The walk from
whatever else carried a position — a Garmin LiveTrack session (already in), the MQTT
tracker, a LoRa/Meshtastic node later — or the watch's FIT imported afterwards (the
library reads FIT); else just the point, visited by hand
** [x] A trip is a library folder (Trips/<date name>): routes per activity, points, tracks (the
car's log, a watch's FIT, LiveTrack) in it; "Start trip" makes it the active one and
records the car's GNSS into it (saved as it goes), "End trip" closes it. Its pictogram:
the folder's `icon` — by hand (the notes' icon picker, POI_ICONS / NPS) or, unset, from its
points (the destination's, else the most common)
Done: `lib/maptool/trip_log.rb`, `GET/POST/DELETE /api/trip/log`, the Trip menu's
Start / End, the line really driven (`--route-driven`). Stored crash-safe like a FIT: an
append-only journal per trip (`data/trip_log/<started>.ndjson`, fsynced every 5 s, a torn
last line skipped), a restart picks the running trip up from it; the library's track built
from it every 5 min and at the end. Still to do: the pictogram, the
planned route dashed behind, a walk from another device shown with it, visited points
** [ ] Colors: planned vs really driven — the planned route (magenta ahead, the part behind
thin and dashed) and the recorded track solid on top (`--route-driven`), docs/design.adoc
** [ ] The menu while driving: showing routes and points, editing the trip — all of it on the
road, so simple: a few big tiles (Trip, Points, Layers, Search), one level deep, rows
≥ 76 px, a handful per screen, the action a big button (add a stop here / at a point,
skip the next one, move one up/down, show / hide a layer) — no drag, no hover, no small
text fields. Who: the navigator (co-driver) runs the whole UI and the trip's points on the
16" display; the driver only looks at a finished map on Android Auto, touching the 16"
only now and then — so it's simple for a moving car, not driver-distraction rules
* [ ] Desktop (the Design canvas' Desktop, 2026-12-03): copy the position under the cursor
to the clipboard (a key or the right-click menu) — today only the map's center copies,
from the status bar, so the way around it is to put the center on the point first
* [ ] Desktop: the scale back over the map, not in the status bar
* [x] Night mode — topbar button cycles auto (sun below the horizon at the map center) / on / off. The map has its own night palette (`NightMap` in `public/js/map_themes.js`, switched live with setPaintProperty): dark blue-gray ground, roads a step lighter, muted ochre motorways, light-gray labels on dark halos; raster overlays dimmed, our own track/point colors kept
** [x] The rest of the UI is still one invert+dim filter — CSS color tokens and a real dark set instead
* [x] Tracker as a top-down vehicle (car / motorbike / bicycle from its icon) rotated by the GNSS course, kept while standing still; "Navigate" (tracker card or Overlays status) follows it heading-up, tilted 60°, vehicle in the lower third — panning by hand ends it
== NPS parks & maps
Prototype outside this repo in `~/Projects/NPS_Maps/` (`nps-maps.py` + a standalone map
finder `index.html`); background in `docs/nps-resources.adoc` ("The NPS mobile app's offline
downloads"). Data and features move here once settled.
* [x] NPS brochure maps as an overlay layer — "NPS park maps" in Overlays (`public/js/nps.js`):
park points and map footprints, a park search, a park's popup lists its maps; a georeferenced
one (289 of them) goes over the base map as an `image` source with four corners, with an
opacity slider. Data in `data/nps/` (`nps.json` index from `nps-maps.py web`, `overlay/`
JPEGs, `geotiff/`, `pdf/` — all 947 PDFs), served by `/api/nps` and `/nps/…`
* [x] Park finder — the overlay's park search + the popup's links (local PDF/GeoTIFF, NPS JPG)
* [ ] NPS campgrounds (and alerts) as points with our NPS icons — via the home NPS MCP server,
no API key of our own (its API key only lives in home-gitops' Gitea secrets)
* [ ] Export brochure maps as MBTiles (`gdal_translate -of MBTILES` + `gdaladdo`) for Locus /
OsmAnd — the official park map offline on the phone, with GPS position, no NPS app needed
== Nice to have (later)
Deprioritized for now — revisit after the sections above land.
=== Vanlife features
* [ ] Offline routing with vehicle parameters (height, weight, width) — Valhalla in its own container, design in `docs/routing-design.adoc`
** [x] Phase 1: `valhalla` compose service (`bin/routing-service.sh`), builds from the offline map's extracts, "Offline routing" row in the Offline data panel
** [x] Phase 2: `/api/route`, vehicle profile, route panel, save a route to the library
** [x] Route points from search / GPS / a library point, reordering, re-editing a saved route
** [x] Phase 3: elevation profile from terrain.pmtiles, isochrones
* [ ] Solar calculator — sun path for location/date, shadows from surroundings, camper orientation
=== Vehicle dashboard & live data
maptool as the dashboard for the car/van too, not only the map. Idea stage. Most of the data
already reaches the home MQTT broker (`mqtt_ext`) from ESPHome nodes in `~/esphome`:
* [x] One MQTT subscriber in the maptool server — `lib/maptool/mqtt_client.rb` (stdlib MQTT
3.1.1, QoS 0, reconnects), `MQTT_URL`/`MQTT_USERNAME`/`MQTT_PASSWORD` (read-only broker
user), latest state in app.rb's `LIVE`, `GET /api/live`; the "Vehicle & ITS-G5" overlay
(`public/js/live.js`) polls it
* [x] Car position from the LTE GNSS tracker (`mcu-tracker/location`) — a badge with its age
and details; the last position stays (a parked tracker reports rarely)
** [x] Own "Tracker" overlay (ITS-G5 separate, Overlays grouped by category); name, icon and color
set in the overlay (server-side, `data/live/settings.json`); USB power / charging from
`mcu-tracker/binary_sensor/usb_power/state`; a floating info card (per-device on/off + opacity);
the trail of the last 1/2/4/8/24 h; optional logging to `data/live/tracker.jsonl`, which also
restores the trail after a restart (`lib/maptool/live_store.rb`)
** [ ] Export the logged trail (GPX / into the library)
* [ ] … also as a source for the GNSS control ("where is the car" / follow it)
* [x] ITS-G5: `mcu-its-g5.yaml` publishes the decoded header as JSON on `mcu-its-g5/decoded`
(1 Hz per station); stations on the map colored by type, DENM bigger and red, gone after 60 s
* [ ] Meshtastic nodes (each has GNSS) — incl. a running tracker to follow on the map. Not in
the broker today: the HA Meshtastic integration only makes `device_tracker` entities and
doesn't republish them. Options: read HA's REST API (`/api/states`, `device_tracker` with
coordinates; needs `HA_URL` + a read-only long-lived `HA_TOKEN`, and covers any other HA
tracker too), HA's `mqtt_statestream` (one topic per attribute — awkward), or MQTT with JSON
output on `rpi-meshtastic` itself (fights the HA integration over the single TCP API while
configuring, see home-gitops docs/embedded-services.adoc)
* [ ] Car CAN data (`mcu-car-can.yaml`, today over the native API to HA): add `mqtt:` like the
tracker; RPM, doors, parking brake, … in a dashboard panel
* [ ] IMU shocks along a drive as a map layer — road roughness / potholes colored by intensity
* [x] Native CAN in maptool (the van's final setup, MQTT is the stopgap): SocketCAN on any
number of interfaces (USB adapter, the board's own controller, `vcan0` for tests),
CANopen frame roles + heartbeat states, NMT start, signals decoded by `data/can.json`
(COB-ID/mask, byte/bit, type, scale/offset — `lib/maptool/can.rb`), `gnss.*` signals feed
the GNSS control, `GET /api/can`
** [ ] The container on the CAN bus: `can0` lives in the host's network namespace — either
`network_mode: host` for maptool (then kiwix/valhalla by localhost ports, not service
names) or a vxcan pair moved into the container's namespace by a host script
** [ ] The car-CAN → CANopen bridge's mapping (not decided yet) as signals in `data/can.json`;
a dashboard panel for the `car.*` signals
** [x] The GNSS node's PDO layout as `gnss.*` signals — `mcu-stm32-xiao-c5-2` (node 0x21,
esphome-canopen), `data/can.json` in docs/deployment.adoc
** [x] `/can.html` diagnostics: interfaces, nodes (heartbeat, last EMCY, what they send),
decoded signals, every COB-ID (role, count, rate, last data)
** [x] The bus recorded on the server into ASAM MDF4 (`/trace.html`, `can-recorder/` in Rust,
`lib/maptool/can_recorder.rb`): every interface, a finished `.mf4` every 5 min in
`data/can_rec/` (a power cut loses at most the last segment), the CANedge `CAN_DataFrame`
layout — asammdf decodes it with a DBC (checked against candump: every frame, < 0.002 ms)
*** [ ] Checked with CSS Electronics' converters (mdf2csv) too, and in CANalyzer if at hand
*** [ ] Old recordings cleaned up (data/can_rec grows ~85 MB an hour at 1000 frames/s)
** [ ] Nodes describing themselves — no hand-written signals for our own nodes:
*** [x] esphome-canopen nodes over SDO: on a node's first heartbeat read its TPDOs
(`0x1800+n`:1 COB-ID, `0x1A00+n` mapping), each mapped entity's type (`0x2001`:N) and
metadata (`0x2000+0x10·N`: name, unit, min/max → the scale), the decoder built from that,
cached by the TPDO layout hash (`0x3002`:1, read again when it changes — after an OTA);
`can.json` keeps only aliases (a node's "Latitude" → `gnss.lat`) and foreign devices
(`lib/maptool/can_discovery.rb`, `Can::Sdo`; aliases with a unit conversion; node 0x21
reads in 2 s, its 14 signals match the hand-written scales)
*** [ ] `/can.html`: each described node's entities (name, unit, range, TPDO), from the cache
*** [ ] EDS (CiA 306) read from a node (`0x1021`) or a file, the same decoder from it — once the
ESPHome side generates EDS (proposal for mrk in home-gitops `docs/canopen-nodes.adoc`); the
car bridge's frames described the same way
**** [x] Meanwhile one EDS for all of them: esphome-canopen's generic one (from can2mqtt) in
`public/can/esphome.eds`, names the SDO objects in `/trace.html` (plus the entity objects);
a node's own EDS (`0x1021`) to take its place per node
*** [ ] 0x1008/0x1018 identity for any CANopen device in `/can.html`
** [x] A node that stops its heartbeat (3 missed) is flagged: one journal line when it goes
silent and when it's back (`can: node 2 silent, last heartbeat …`), red in `/can.html`
** [x] Dashboard overlay (Overlays → Live → Dashboard, `public/js/dashboard.js`): one combined
inclinometer (Pajero style, but one instrument, not three) — compass ring around a rear view
(roll) and a side view (pitch), amber past 20° roll / 25° pitch, red past 1.5× — and the
speed; widgets on/off per device. Heading: driving (≥ 1.5 m/s) the GNSS course from fixes
≥ 5 m apart, standing still the compass (`imu.heading`), else the last course, dimmed
*** [ ] Widgets placed per screen and bound to any signal — turn signals, brake, … once the
car's bridge puts them on the bus
*** [x] The compass (HMC5883L on node 0x21, TPDO 0x221) as `imu.heading` + `mag.x/y/z` in
`can.json` — for orienting while standing; driving uses the GNSS course
*** [ ] Tilt compensation (pitch/roll from the IMU) and hard-/soft-iron calibration of the
heading — ESPHome's is a plain `atan2(-x, y)`; in the node, like the levelling
*** [x] The node sent the heading encoded 0..360 but ESPHome's is −180..180, negatives arrived
as 0 — fixed in the node (`x < 0 ? x + 360 : x` filter on `heading:`, 2026-11-30)
*** [ ] IMU every 100–200 ms (the node reads it every 5 s today) and levelling done by the
node itself, set by an SDO write from a button in `/can.html` — design in home-gitops
`docs/canopen-nodes.adoc` ("Nulovanie náklonu a rýchlosť IMU")
* [x] Dead reckoning in a tunnel (`App.gnss_position`): no fix for 3 s (or `mode` < 2) on the
trip's route — the position carried along it, `estimated: true`, a grey arrow; by the CAN
signal `vehicle.speed` (m/s) when there is one, the average speed of the last ~20 s before
otherwise; up to 10 min (2026-12-01). The SIM7600E's GNSS has no DR of its own
** [ ] `vehicle.speed` off the car (OBD/CAN) into `can.json`; its scale calibrated against GNSS
** [ ] Off the route: the gyro's yaw rate (the IMU node) or the compass, with map matching
** [ ] Back out of the tunnel: the first fixes taken only once consistent (HDOP, the jump from
the estimate); the trip log keeps a straight line through the tunnel for now
=== 3D navigation mode
* [x] A "follow" mode like a car navigation: camera locked to the GNSS position, rotated to the
heading, pitched ~60°, smooth easing — the tracker's "Navigate" (see the Tablet-friendly
section); follows the MQTT tracker, not the browser's own GNSS control yet
** [ ] Real 3D relief from the raster-dem terrain and Liberty's `building-3d` extrusions while navigating
* [ ] Full navigation (the car's main screen while driving; everything from our own Valhalla
tiles, no online service — Valhalla has OSM `maxspeed`, `traffic_signals` and turn lanes)
** [x] Basics on the dashboard (`public/js/dashboard.js`): the speed limit as a sign and a red
warning over it (+3 km/h); on the route panel's route (≤ 50 m off it): the next limit
change and its distance, the distance to the next traffic signal, the next maneuver and
its lanes (from 1 km, the lanes to take highlighted). `/api/route` gains `speed_limits`
(km → limit, per change), `signals` ([lon, lat, km]) and `maneuvers[].lanes`
(`turn_lanes`), from the same `trace_attributes` pass as the countries; the route's
signals drawn on the map from z14. Off the route / with none: `POST /api/road`
(map-matched last fixes → the road's name and limit), every 4 s while moving
** [ ] Speed limits that aren't on the edge: `maxspeed:conditional` (time, wet), variable
signs, `zone:maxspeed` defaults per country (Valhalla leaves untagged roads empty — show
the country's default by road class?), the vehicle's own limits (a camper > 3.5 t: 80/100)
** [x] Rerouting (after Ferrostar's split of deviation detection and recalculation): off the
route = over 30 m from its line for 3 fixes in a row (fixes with HDOP > 5 don't count), then
the route panel routes from the position to the points not reached yet (via points passed
by km along the route, `legs_km`), at most every 15 s and only moving
*** [ ] Step advance like Ferrostar's DistanceEntryExit (30 m to the step's end, 5 m past it)
instead of "the first maneuver ahead by km"; arrival at 30 m. Done: progress only forward —
the position looked for near the last one first (`locate`, 0.1 km back to 3 km ahead), so a
route along the same road twice or crossing itself doesn't jump; the step still advances 5 m
past the maneuver. Arrival still to do
** [x] The navigation banner across the top (Dashboard widget, on by default): the next
maneuver's arrow (Valhalla's maneuver type), distance and street, "then …" when the next one
follows within 300 m, its lanes from 1 km, the street being driven; `/api/route` maneuvers
gain `type`, `street`, `exit`
** [x] The driving view decluttered: tilted to 3D (≥ 30°), route numbers and minor roads' /
paths' names hidden; road labels 1.5× further apart, past z15 the same ground distance
** [ ] Turn-by-turn voice (`speechSynthesis`), the route ahead highlighted / the driven part
greyed
** [x] Lanes as SVG arrows, one per direction bit, the lanes to take (Valhalla's `active`) blue
with that direction bold
*** [ ] Lane guidance before motorway exits (lanes several maneuvers ahead), bigger on the
driving screen
** [ ] Traffic signals with no route: around the position (Valhalla `locate` or the offline
PBF), and only for the direction driven (`traffic_signals:direction`)
** [ ] The "Navigate" follow mode for the CAN GNSS position (today the MQTT tracker and the
browser's GNSS control), the dashboard as part of the driving-mode UI
** [x] `locate()` scans the whole route each fix — a window around the last hit on long routes
** [ ] Shared trip — one itinerary per server for every screen (the cab's display, the tablet
or display in the back, phones): the co-driver adds a stop, the driver's view reroutes on the
fly without losing the map (no stop / reload / start like Android Auto between two phones)
*** [x] `TripStore` (`lib/maptool/trip.rb`, `data/trip.json`): points, vehicle, avoids, the
library route being edited and the route, versioned; `GET /api/trip?version=N` (204 while
unchanged), `PUT /api/trip` routes it on the server (not again when only names/nav
changed). Logged in, the route panel edits it and polls it every 2 s — other screens'
changes swapped in, the camera untouched, the old route shown until the new one is in
*** [x] Rerouting on the server: it has the GNSS (CAN), so off-route detection and the new
route once for all screens, not per screen with a dashboard. Done: `TripStore#follow` on
every fix (3 fixes > 30 m off while moving, at most every 15 s), the browser's own reroute
only without the shared trip
*** [ ] An itinerary view: stops by day/night, notes, planned arrival times (Valhalla's leg
times), "Add to the trip" from search, the library, park4night and other sources
*** [ ] Brick ↔ the car: a trip planned at home on brick handed to the car's server (with
the library sync, or "send to the car")
*** [ ] Push instead of polling (SSE) if 2 s ever feels slow
** [ ] Android Auto: the browser can't be cast there, only a native app — a small one with
the Car App Library's NavigationTemplate drawing its own map surface (MapLibre Native) off
the car server's trip and position (`/api/trip`, `/api/gnss/position`); only the map and
the next maneuver, planning stays on the web. Testable without the car: the tablet runs the
Android Auto head unit emulation (DHU)
*** [ ] Views by who's driving off which screen: no Android Auto connected → the 16" display
shows the 3D follow view (heading-up, pitched) for the driver; Android Auto connected → it
streams the 3D navigation to the driver, and the co-driver's display stays 2D (north-up
overview, planning). Needs the app to report connected/disconnected to the server (e.g.
next to `/api/gnss/position`) and the driving view to switch on it
** [ ] A native Android app on Ferrostar (rerouting, Valhalla speed limits, TTS built in) over
our Valhalla (`format: osrm`) — only if navigation is wanted on a phone outside the car; the
car's 16" display is the Pi's browser either way. Ferrostar's web components are beta: no
rerouting or annotations on the web, bundler + WASM, its own map element
** [x] GNSS simulation for trying it without the car (`lib/maptool/gnss_sim.rb`, Dashboard
settings → "Simulate driving from the map center", `POST/DELETE /api/sim/gnss`): random
trips over our Valhalla (2–8 km each, one after another) at 90 % of the road's limit, a fix
a second into the same `gnss.*` signals / GNSS_LATEST as the node's (ignored meanwhile)
*** [x] The dashboard's tilt from the terrain's slope while simulating
*** [ ] Replay a library track (GPX/FIT with times) instead, at its own speed
** [x] Free look while following: moving the map by hand pauses the follow, "Back to the
position" or 15 s untouched resumes it
* [ ] While following a planned route: the route ahead highlighted, distance to the next
maneuver from Valhalla's directions
=== Design: the park brochure and the cockpit
Planning in the NPS look, driving in the cockpit look, joined by the Unigrid black band —
`docs/design.adoc`. Action plan:
. [x] Colors: tokens on `:root` (`--band`, `--inst-*`: ok / caution / warning, magenta = what
navigation follows, cyan = set by hand); the dashboard in them — a see-through black bezel,
light values, inverted back in night mode
. [x] The route line magenta while it's navigated (follow mode), blue while planning; the next
waypoint and maneuver magenta on the map too. Done for the line (the driven part dimmed,
while the dashboard is on the route); the waypoint / maneuver marks still to do
. [ ] The rest of the hard-coded colors → tokens (route, warnings, panel states), one place to tune
. [ ] Panel headers as the Unigrid band: black, white title in National Park (headings weight
to vendor), the same band as the topbar
. [ ] `/can.html` in the cockpit style: dark, the node / signal states in `--inst-*`
. [ ] The navigation strip: the next maneuver big at the top (arrow, distance, street, lanes) —
with the driving mode's big-button UI
. [ ] The PDM switch panel in the cockpit style (tiles: `--inst-ok` on, muted off,
`--inst-warning` fault)
. [x] Palettes after IHO S-52: the same tokens in Day / Dusk / Night (`data-palette` on
`<html>`), night dim with low blue and no white areas, the speed limit sign dimmed too
. [x] Switch them: by the sun (the night mode's auto) and by hand (the topbar button cycles
day / dusk / night / auto), replacing the inverting `html.night`; the planning UI's
hard-coded colors onto `--ui-*` first, or a dark palette leaves light panels. Done: the
greys on `--ui-*` (MapLibre's controls too), `color-scheme: dark`, the controls lifted off
the dark map; night mode sets Night, "◑" Dusk (the day map)
. [ ] A Dusk map (between Park Tiles and `NightMap`), the map's palette following the UI's
. [ ] Daylight: a full-opacity bezel preset for sun on the screen
. [ ] The display's backlight apart from the palette (as G1000/GPSMAP): the car's screen dimmed
for Night (DDC/CI or its own dimmer), the palette only picks the colors
. [ ] Auto night by the headlights (car CAN) or a light sensor on a node, with hysteresis
(not flipping in a tunnel) — the sun only as the fallback
. [ ] A red/black night palette (Garmin marine / Raymarine) for the darkest roads
. [ ] One night mode for every screen in the car (the server's, like Garmin over NMEA 2000)
. [ ] No flash back to Day at night: the palette switch eased in
=== HW integration
Inspired by Garmin Tread / zūmo, but open and over CANopen — the nodes' side and the options
are in home-gitops `docs/canopen-nodes.adoc` ("Inšpirácia: Garmin Tread / zūmo"):
* [ ] Hardware buttons (a CANopen keypad / a steering-wheel controller, read off `can0`):
actions in `data/can.json` — pan, zoom ±, add a point (the position into the library or the
trip), mark a place, switch views (navigation / overview / dashboard), mute / volume, the
trip's next stop, night mode; a long press for a second action, the keypad's LEDs showing state
* [ ] A virtual switch panel for the PDM node (like Garmin's PowerSwitch: tiles with icon,
label, state and current, groups) + rules: by speed, sun/time of day, geofence (the trip's
camp), ignition and battery voltage
* [ ] The group over LoRa (Meshtastic / MeshCore through a node on the Pi): the others' positions
as a live layer with trails, short messages, "come here" into the trip
* [ ] Audio: volume / mute from the keypad and the app, navigation prompts ducking the music
* [ ] Level gauge from IMU (ESP32/RPi) — camper tilt, wheel-chock leveling calculation
* [ ] Victron/Home Assistant via MQTT or WebSocket — battery SoC, tank levels, temperatures
* [ ] Plot GPS track with historical battery/speed data
== Server in the car (RPi CM5, 8 GB)
The tablet talks to a server far away today, so without internet nothing loads. Moving the
server into the car (on the car's Wi-Fi, next to the MQTT broker) makes everything that's
already offline work on the road. The Pi only serves; heavy builds stay on brick.
* [ ] Run the existing docker-compose stack on the CM5 (arm64: our image handles it, check
that the Valhalla and kiwix-serve images have arm64 builds); data on NVMe, not the SD card
* [ ] Build on brick, ship to the Pi: `offline.pmtiles`, `terrain.pmtiles`, Valhalla
`tiles.tar`, `places/*.sqlite`, `hiking_trails/*.geojson`, the ZIM — an rsync (only when
refreshed, which is rare) instead of the Pi's own build buttons; hide/disable those there
* [x] Login without internet: Gitea OAuth can't run offline — let the car's LAN through
without login (e.g. `TRUSTED_NETWORKS` CIDR list), or a local fallback account. Done: the
session cookie is checked locally (90 days, no Gitea after the login), and rpi-dev has
`TRUSTED_NETWORKS=connected` — whatever is on the Pi's own networks counts as logged in
* [ ] HTTPS on the LAN (the secure session cookie, the PWA and the service worker need it):
the same hostname resolved to the Pi by the car router's DNS, Let's Encrypt cert via DNS-01
* [ ] A touch display on the Pi itself (a portable ~16" USB touchscreen, the co-driver's —
the navigator plans on it while driving; Chromium in kiosk mode on
`http://localhost`) as the car display — solves a lot at once: localhost is a secure
context (no certificate needed for the PWA/service worker) and can skip login, it doesn't
depend on the car's Wi-Fi, buttons plug straight into the Pi (a USB/BLE keypad is just a
keyboard to Chromium, a CAN keypad via SocketCAN on the Pi). The tablet/phone stay optional
* [ ] Sync home ⇄ car — two servers, each fully usable on its own:
** Bulk data (pmtiles, Valhalla tiles, places, hiking trails, ZIM) only on the home network
(the car joining the home Wi-Fi as the trigger), never over LTE
** User data (library: folders/items/notes, tracker settings, logged trail) whenever both
ends are reachable, LTE included — small, incremental
** Builds on the library's existing pieces (docs/library-design.adoc): `rev` change counter,
`GET /api/library/changes?since=<rev>`, tombstones, `item_history` for the losing version.
Missing for two servers: per-peer high-water marks (my rev on your side and vice versa),
ids that never collide (UUIDs, already for items), and a base version per item so a real
conflict (both sides changed since the last sync) is told apart from a plain update
** Conflicts: per item, newer `updated_at` wins (clocks: the Pi needs NTP/GNSS time), the
other version into `item_history` and flagged in the UI so it can be restored; a delete vs.
an edit keeps the edit
** Logged tracker positions: append-only, merged by timestamp, no conflicts
* [ ] Hardware buttons: keyboard shortcuts in the page (zoom, Navigate, night mode, …) — the
cheap way with any BLE/USB keypad that sends plain keys
* [ ] … and the full way: a CANopen keypad (Blink Marine style) on the CAN bus wired straight
to the Pi, read by maptool's native CAN (see "Native CAN" above; NMT start, key bitmap
from `0x180+node` as `bit` signals, LEDs via `0x200+node` still to send) → the
browser over Server-Sent Events; the page's state (navigating, night) back the same way to
light the keypad's LEDs. Server needs to know which browser is "the car display" (a
per-device switch — or simply the Pi's own kiosk display)
== Admin / ops tooling
* [ ] Offline build log readability — a failed pmtiles/terrain build currently surfaces as one
~500k-character line; format it for the web UI instead (e.g. per-country/state name + status,
not the raw combined stdout/stderr dump)
* [ ] Expose the build log via an API endpoint, not just embedded in the admin page
* [ ] Document all API endpoints somewhere and make them easy to browse (status of each) —
maybe a status page, login-gated
** [x] The status page: `/status.html`, every read-only status endpoint's JSON, full width,
refreshed every 5 s, filter and pause (the Status / debug panel links it)