From fdd77986c1a82b6306b299fb34c9b936a1943c2a Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Mon, 23 Nov 2026 15:56:20 +0100 Subject: [PATCH] =?UTF-8?q?Offline=20hiking=20trails=20drawn=20only=20from?= =?UTF-8?q?=20zoom=2010=20(a=20whole=20country's=20lanes=20rebuilt=20per?= =?UTF-8?q?=20zoom=20froze=20the=20zoomed-out=20map);=20TODO:=20server=20i?= =?UTF-8?q?n=20the=20car=20(RPi=20CM5)=20=E2=80=94=20builds=20on=20brick,?= =?UTF-8?q?=20offline=20login,=20HTTPS,=20Pi=20kiosk=20display,=20home=20?= =?UTF-8?q?=E2=87=84=20car=20sync=20with=20conflict=20handling,=20hardware?= =?UTF-8?q?=20buttons=20over=20CAN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.adoc | 51 +++++++++++++++++++++++++++++++++++--- public/js/hiking_trails.js | 6 ++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/TODO.adoc b/TODO.adoc index 5974cb7..38082b3 100644 --- a/TODO.adoc +++ b/TODO.adoc @@ -161,10 +161,10 @@ already reaches the home MQTT broker (`mqtt_ext`) from ESPHome nodes in `~/espho === 3D navigation mode -* [ ] A "follow" mode like a car navigation: camera locked to the GNSS position, rotated to the - heading, pitched ~60°, smooth easing; the rotation lock released while it's on. The pieces - exist: pitch toggle, raster-dem terrain (MapLibre can also do real 3D relief from it), - Liberty's `building-3d` extrusions +* [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 * [ ] While following a planned route: the route ahead highlighted, distance to the next maneuver from Valhalla's directions @@ -174,6 +174,49 @@ already reaches the home MQTT broker (`mqtt_ext`) from ESPHome nodes in `~/espho * [ ] 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 +* [ ] 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 +* [ ] 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 (USB touchscreen, 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=`, 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 (SocketCAN `can0`) → the small CAN → MQTT bridge on the host (see "Later in the + van" above; NMT start, key bitmap from `0x180+node`, LEDs via `0x200+node`) → maptool → 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 diff --git a/public/js/hiking_trails.js b/public/js/hiking_trails.js index cf63eb5..ff142cc 100644 --- a/public/js/hiking_trails.js +++ b/public/js/hiking_trails.js @@ -62,6 +62,9 @@ const OPACITY = 0.85; // 3D terrain (sinks under raised ground, warns on the console) — a known // limitation of the library, not worth working around for an overlay. const LANES_LAYER_ID = "hiking-trails-lanes"; +// Zoomed out further, a whole country's lanes took seconds per frame/zoom +// build and froze the map — and a trail line at that scale tells nothing. +const LANES_MIN_ZOOM = 10; const LANE_SIZES = () => ({ spacing: 3.5, width: 3, casingWidth: 0.5 }); function offlineUrl(code) { return `/tiles/hiking_trails/${code}.geojson`; @@ -332,6 +335,7 @@ export class HikingTrailsControl { // Below labels (same firstSymbolLayerId spot contour.js/radar.js use), // so place names/POI icons stay readable on top of the trail lines. this._map.addLayer(this._lanes, firstSymbolLayerId(this._map)); + this._map.setLayerZoomRange(LANES_LAYER_ID, LANES_MIN_ZOOM, 24); } _handleClick(event) { @@ -345,7 +349,7 @@ export class HikingTrailsControl { // miss just closes an already-open panel rather than showing a "not // found" message, same as clicking empty space anywhere else on the map. _handleOfflineClick(event) { - const hit = this._lanes?.queryLane(event.point, 8); + const hit = this._map.getZoom() >= LANES_MIN_ZOOM && this._lanes?.queryLane(event.point, 8); const info = hit && this._routeInfo.get(String(hit.route)); if (!info) { this._hidePanel();