feat: road-route imported GPX stops and widen the TFT camera

- Route points, waypoints and sparse tracks are joined along roads with
  multi-location Valhalla requests (chunks of 20, merged legs); failures
  offer a retry instead of straight lines.
- TFT camera: lower zoom, 45 degree pitch and rider lower in the frame;
  rider zoom offset from Settings and NaviLite zoom requests 51/52.
- Online map failures fall back to an installed offline pack for 30 s.
- Production-facing copy cleanup and docs; version 0.14.8 (25).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 16:27:51 +01:00
1 parent 694fefd98b
commit b7bf2c2b43
22 files changed
+453 -116

No files matched your search

+10 -4
View File
@@ -1,18 +1,24 @@
# Importing a GPX route
Open **☰ → Cargar ruta GPX**, then choose a `.gpx` file using Android's document picker. The app displays the name, distance and point count and previews the trace when no other navigation session is active. After a valid file is selected, navigation starts automatically with real GPS as soon as location permission and a recent accurate fix are available. No destination search is needed. A pending import leaves existing navigation running until the new trace can start. The **Iniciar navegación** button retries after a timeout or permission denial.
Open **☰ → Cargar ruta GPX**, then choose a `.gpx` file using Android's document picker. The app displays the name and distance and previews the route when no other navigation session is active. Files made of route points, waypoints or sparse tracks are first joined along roads (see below). After a valid file is selected and any road calculation succeeds, navigation starts automatically with real GPS as soon as location permission and a recent accurate fix are available. No destination search is needed. A pending import leaves existing navigation running until the new trace can start. The **Iniciar navegación** button retries after a timeout or permission denial.
Precise location permission is required to start navigation. If a recent fix with accuracy of 25 metres or better is unavailable, the app waits up to 60 seconds. Close the import panel or stop the route to cancel that wait. When the wait expires, enable location and tap **Iniciar navegación** to retry. Denying permission leaves the trace available for review.
## Supported files
GPX 1.0 and 1.1 routes (`rte/rtept`) and tracks (`trk/trkseg/trkpt`) are supported, including GPX files without a namespace. Export one route or one track containing a single nonempty continuous segment. A file containing one route plus one track is also supported: the track supplies the detailed geometry and its name; route stops are not connected or added to the trace. An empty or invalid track is rejected rather than silently following the route stops. Multiple routes, multiple tracks or multiple nonempty segments are rejected: the app must not create a fictitious connection between separate tracks. Waypoints alone do not define a route.
GPX 1.0 and 1.1 routes (`rte/rtept`) and tracks (`trk/trkseg/trkpt`) are supported, including GPX files without a namespace. Export one route or one track containing a single nonempty continuous segment. A file containing one route plus one track is also supported: the track supplies the detailed geometry and its name; route stops are not connected or added to the trace. An empty or invalid track is rejected rather than silently following the route stops. Multiple routes, multiple tracks or multiple nonempty segments are rejected: the app must not create a fictitious connection between separate tracks. A file with only waypoints (`wpt`) is treated as an ordered list of stops.
Files are limited to 5 MiB, 10,000 total route and track points and 64 XML nesting levels. Coordinates must be finite and within latitude/longitude bounds, with at least two distinct points. DTD declarations and external entities are rejected. Route names are capped at 256 characters. An invalid or inaccessible file leaves any running navigation untouched.
## Road calculation between points
Route points (`rtept`), waypoints and sparse tracks (median gap between points above 250 m, typical of planner exports with hand-placed clicks) are not drawn as straight lines. The app sends the ordered points to the configured Valhalla server with the motorcycle profile, avoiding unpaved roads; route points and waypoints also avoid motorways, while sparse tracks may use them because the recording may have. The first and last points are `break` locations and the rest are `through`, so the route passes every point without announcing an arrival at each one. Requests carry at most 20 points; longer lists are split into consecutive requests that share their boundary point and are merged into one route. At most 400 points are sent; longer lists are evenly downsampled keeping both ends.
The result has real turn instructions, voice announcements and an ETA. It is not recalculated automatically during navigation so that the planned points are respected. If the calculation fails (no connection, server busy), the panel says so and offers **Reintentar**; the app never falls back to straight lines. Dense recorded tracks are followed as they are, without contacting the routing server.
## Following a trace
The original coordinates are retained locally in memory and drawn on the phone and TFT. GPX import does not send the file or its coordinates to a routing server. It works with the installed offline map; online background tiles still require a connection when no offline map is selected. Standard trace points do not establish legal roads, surface quality, reliable turns or travel time.
Dense tracks keep their original coordinates in memory and are drawn on the phone and TFT. Following such a trace does not send the file or its coordinates to a routing server. It works with the installed offline map; online background tiles still require a connection when no offline map is selected. Standard trace points do not establish legal roads, surface quality, reliable turns or travel time.
The display says **Sigue el trazado GPX**. It shows progress, remaining distance, sustained deviations and arrival using the existing GPS guidance policy. It does not invent turn instructions, speak turn announcements, show an ETA, or automatically reroute away from the imported trace. On a deviation, return to the trace using the map and road signs. Manual recalculation also preserves the trace. After a confirmed deviation, three fresh, stable GPS fixes spanning at least two seconds automatically resume progress at the nearest point of the original trace, whether you rejoin ahead of or behind the previous position. GPS jumps and inaccurate fixes cannot confirm a rejoin.
@@ -20,4 +26,4 @@ The imported route is not persisted across process death or device reboot: reloa
## Validation
Core tests exercise standard GPX routes/tracks, namespaces, malicious XML, resource limits and trace guidance without invented turns or ETA. Android unit tests exercise the document picker, cancellation, precise-location permission denial, preview/start/stop and prevention of online recalculation with the renderer replaced to avoid device-only JNI.
Core tests exercise standard GPX routes/tracks, stop extraction for routes, waypoints and sparse tracks, multi-point Valhalla requests and leg merging, namespaces, malicious XML, resource limits and trace guidance without invented turns or ETA. Android unit tests exercise road calculation of route points and its retry on failure, the document picker, cancellation, precise-location permission denial, preview/start/stop and prevention of online recalculation with the renderer replaced to avoid device-only JNI.
+1 -1
View File
@@ -45,7 +45,7 @@ These values reproduce the observed upstream session, including scale/unit label
## Image and send cycle
Service 0, frameType 6, pointer 1, payload `03 | seq UInt16LE | JPEG`. Sequence starts at 1 and wraps to 0 after 65535. The JPEG is generated by NavFrame at baseline 480×240; it is not a phone-screen capture. Only one frame may be in flight: `sendFrame` writes the packet and waits for IMAGE_ACK service 80 before the next frame. ACK payload format/correlation is not demonstrated; as in Pillion, the implementation filters on service 80. Other services are consumed without executing commands. An ACK confirms protocol exchange acceptance, not that an image was visibly drawn on the TFT.
Service 0, frameType 6, pointer 1, payload `03 | seq UInt16LE | JPEG`. Sequence starts at 1 and wraps to 0 after 65535. The JPEG is generated by NavFrame at baseline 480×240; it is not a phone-screen capture. Only one frame may be in flight: `sendFrame` writes the packet and waits for IMAGE_ACK service 80 before the next frame. ACK payload format/correlation is not demonstrated; as in Pillion, the implementation filters on service 80. Zoom requests from the motorcycle (service 51 zoom in, 52 zoom out, as documented by Pillion) are answered with the ZOOM metadata packet and adjust NavFrame's TFT zoom offset; other incoming services are logged as `NAVILITE_REQUEST` and counted in the TFT diagnostic report without executing commands. Incoming packets are only read while waiting for an ACK, so a request is handled on the next frame. The direction of 51/52 has not been verified on the motorcycle. An ACK confirms protocol exchange acceptance, not that an image was visibly drawn on the TFT.
Connection, handshake, and ACK timeouts and cancellation close the socket, unblock I/O, and set ERROR; `disconnect` closes directly without waiting for a held mutex. The initial version required an explicit reconnect; after ERROR, transport can call `connect()` again with a new socket, full handshake, and reset sequence. Automatic pairing and additional commands are not implemented. The transport has no continuously running reader while no sends occur; it detects a remote close on the next send. Therefore the session keepalive policy needs periodic checks; without them, CONNECTED may remain visible until another send.
+12 -1
View File
@@ -8,7 +8,7 @@ Start the demo with **Start animated demo**. It supports TFT layout iteration an
Drawing uses a logical 480 × 240 `Canvas`, prioritizing the maneuver, route shape, and position marker. `RenderScheduler` keeps only the latest state and avoids repaints for small changes: initial thresholds are 2 m position, 3° bearing, 0.5 m/s speed, and 10 m for visible distance changes. Initial maximum redraw rates are 1 FPS stopped, 5 FPS moving, and 10 FPS turning. These limit redraws; NaviLite keepalive sending is a separate configurable cadence (0.5/1/2 s) that waits for ACK and never queues frames. An ACK delay must not build a frame queue or block the demo.
The accompanying camera policy keeps the marker near 72% screen height and changes simulated zoom by speed/turn distance: 17 below 30 km/h, 16 through 70 km/h, 15 above, and 17.5 within 150 m of a turn. In this phase the renderer draws an illustrative road directly on Canvas; it does not project tiles or a map. These parameters only support future map integration.
In this phase the renderer draws an illustrative road directly on Canvas; it does not project tiles or a map. The camera policy used by the later map renderer is described under [TFT camera and zoom](#tft-camera-and-zoom).
Check by starting the simulated demo and watching the preview for at least one minute. Position/bearing should change, frames should remain 480 × 240, and `DEMO` should remain visible. Stopping the demo should halt its animation and update source. This check does not test GPS or real navigation.
@@ -55,3 +55,14 @@ This phase has no turn-by-turn, active progress, live turns, off-route detection
**Start guidance for calculated route** activates the GPS tracker or DEMO simulation over route geometry. The HUD shows icon, distance to maneuver, remaining distance, and approximate ETA. NO GPS, OFF ROUTE, and RECALCULATING hide stale estimates. Arrival requires distinct position observations. The service retains continuous transport and stop controls.
Native composition is checked using `guidance.png` on a test base. This does not certify MapLibre GPU or physical navigation. See [testing](TESTING.md) and [thresholds and limitations](ROUTING.md).
## TFT camera and zoom
`TftCameraPolicy` places the rider at 78% of the frame height with a 45° pitch, so most of the 480 × 240 image shows the road ahead. Zoom depends on speed and on the next turn: 15.5 below 30 km/h or within 200 m of a turn, 15 up to 70 km/h, and 14.5 above. Earlier versions used zoom 15–17.5 with the rider at 60% and no pitch, which showed only a few hundred metres ahead.
The rider can shift the automatic zoom in 0.5 steps between −2 and +2 from **☰ → Ajustes → Zoom del mapa en la pantalla de la moto**, or with the motorcycle's zoom controls when the TFT sends NaviLite zoom requests (see [NAVILITE.md](NAVILITE.md)). The offset is saved and the next frame is redrawn immediately. Pitch and handlebar zoom still need validation on the motorcycle.
## Online map fallback
A MapLibre snapshot fails as a whole if any tile, glyph or style resource fails, which happens with patchy mobile coverage. When the online map fails, NavFrame records `MAP_ONLINE_FAILED`, renders from an installed offline pack or region covering the position if there is one, and retries the online source after 30 seconds. Without an installed pack for the area, the TFT shows `MAPA NO DISPONIBLE` as before. Installing the bundled Asturias pack (or a regional pack) keeps the TFT map available when coverage drops.