Files
maptool/TODO.adoc
T

170 lines
21 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
** [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
** [ ] Landuse & protections: distinct styling for national parks, nature reserves (translucent green/gray-green), military zones, and private land (important for wild camping)
** [ ] 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)
** [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)
* [ ] Side panels as an overlay/bottom sheet in portrait instead of a pinned column
== 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.
* [ ] NPS brochure maps as an overlay layer — 289 georeferenced Harpers Ferry Center park maps
(`brochure-maps.json`: pixel size + geoTransform + proj4) rendered from the NPGallery PDFs;
in MapLibre each is just an `image` source with four corners, plus an opacity slider
* [ ] Park finder panel — every park with its maps from the full NPGallery catalog (963 maps,
PDF/JPG/Illustrator ZIP each), jump to park, toggle its brochure map
* [ ] 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`:
* [ ] One MQTT subscriber in the maptool server — its own read-only broker user (ACL on just
the topics below), a thread like the gpsd client, latest state per key with an expiry, pushed
to the browser; one generic "MQTT live" layer/panel rather than one integration per source
* [ ] Car position from the LTE GNSS tracker (`mcu-tracker.yaml`, JSON on
`mcu-tracker/location`) as another source for the GNSS control — "where is the car" even when
away from it
* [ ] ITS-G5 (`mcu-its-g5.yaml`, already receiving): publish the decoded header per packet as
JSON next to the raw `its/<node>/packet` (type, station type, lat/lon, speed, heading —
`its_g5_decode::stats.last` already has them; throttle CAMs to ~1 Hz per station), so maptool
needs no ASN.1 decoding; on the map: stations by type (car, truck, roadside unit), DENM events
as warning icons that expire
* [ ] 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
* [ ] Later in the van: CANopen (or plain CAN with own IDs) to the server, a small CAN → MQTT
bridge on the host (SocketCAN; `can0` lives in the host's network namespace), maptool stays
on MQTT
=== 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
* [ ] While following a planned route: the route ahead highlighted, distance to the next
maneuver from Valhalla's directions
=== HW integration
* [ ] 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
== 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