fix(phase26): geocode pre-caching (BUG-09) + gate trips on OBD presence (BUG-10)

This commit is contained in:
Mathieu Moran
2026-08-11 02:38:00 -04:00
parent a709517973
commit 7e913558f6
4 changed files with 107 additions and 3 deletions
+41
View File
@@ -157,6 +157,47 @@ the authoritative, issue-by-issue record lives **here**.
---
### BUG-09 — Server trip scrubber geocoding is slow on each step
- **Status**: `OPEN`
- **Severity**: Medium (UX)
- **Area**: `static/js/history.js` `showReplayPoint()` / `scheduleGeocode()`
- **Phase**: Phase 26
- **Symptom**: Scrubbing through the trip timeline on the server portal is sluggish — the location
name takes a long time to appear because each scrub step fires a fresh `/api/geocode` HTTP
request (debounced 600ms). On the Pi this is fast (offline reverse_geocoder), but the server
calls Nominatim which adds latency.
- **Root cause**: Every `showReplayPoint()` call triggers `scheduleGeocode()` → debounced
`fetch(/api/geocode...)`. No pre-caching or batch loading.
- **Fix scope / actions**: Pre-fetch geocode results for ALL trip points when the route is first
loaded. Store in a local JS map keyed by rounded coordinate. Show cached label instantly during
scrubbing. Only fall back to live fetch for uncached points. Optionally batch-geocode at the
server API level too (accept multiple lat/lon pairs).
- **Acceptance**: Scrubbing through trip replay shows location names near-instantly.
### BUG-10 — GPS-only false trips generated when car is not connected
- **Status**: `OPEN`
- **Severity**: Medium (data quality)
- **Area**: `modules/app_trip.py` `build_trip_summaries()`, `modules/app_sql.py` `refresh_trips()`
- **Phase**: Phase 26
- **Symptom**: The Pi generates trips from GPS data alone (GPS jitter/drift) even when the car
isn't connected. Since the Pi bench-tests with no OBD, GPS displacement fallback creates
phantom "trips" from stationary GPS noise.
- **Root cause**: The GPS motion fallback (3+ consecutive 8m displacements) can be satisfied by
GPS jitter over time, especially indoors or in weak-signal areas. The system doesn't gate trip
detection on whether OBD was ever present.
- **Fix scope / actions**:
- **Option A (strict)**: Only start trips when OBD wheel speed has been detected at least once
since the app started (a `car_was_connected` flag). No OBD ever = no trips, even with GPS.
- **Option B (lenient)**: Increase GPS motion requirements when OBD has never been seen (e.g.
require 10+ consecutive displacements of 20m+ instead of 3×8m).
- **Recommend Option A** — it matches the real-world use case: the Pi is powered by the car's
ignition, so OBD should always be reachable when the car is running. No OBD = bench test,
don't generate trips.
- **Acceptance**: Bench-testing the Pi (no car connected) produces zero trips. Real driving with
OBD connected still produces correct trips.
---
## Resolved bugs
### BUG-03 — DTC/MIL codes are never persisted; lost on OBD disconnect or reboot