fix: BUG-13 — server geocode returns raw coords instead of location names

Root cause: server _geocode_cached() returned None → /api/geocode
returned HTTP 204 with no body. JS frontend treated 204 as success,
r.json() on empty body threw → showed raw-coordinate fallback.

Server fixes:
- _geocode_cached() now always returns a non-empty string (coordinate
  fallback when both Nominatim and reverse_geocoder fail)
- /api/geocode always returns HTTP 200 with {label: '...'} (never 204)
- /api/geocode/batch always includes every coord key in result dict
- Nominatim call: jsonv2 + accept-language=en (aligned with Pi)
- reverse_geocoder: mode=1 (aligned with Pi)

Pi alignment:
- _geocode_cached() now checks for empty reverse_geocoder label before
  returning, falling through to coordinate string (same guard as server)
This commit is contained in:
Mathieu Moran
2026-08-12 02:53:44 -04:00
parent 81a0bfebd5
commit 830981934f
3 changed files with 40 additions and 22 deletions
+15 -6
View File
@@ -9,16 +9,25 @@ When CLOSED, move the entire entry to Resolved — don't duplicate.
## Open bugs
### BUG-13 — Server Web UI shows raw coordinates instead of geocoded location on trips
- **Status**: `OPEN`
- **Status**: `IN PROGRESS`
- **Reported**: 2026-08-12
- **Affected trips**: 18517, 18516 (and possibly others)
- **Symptom**: The trip detail/replay page shows raw (x, y) coordinates instead of
reverse-geocoded location names (street/city/address).
- **Likely cause**: Geocoding pipeline is either not running, failing silently, or
the cache lookup isn't populating for these coordinates. Could be a regression
from the BUG-09 geocode preloading changes or a server-side cache issue.
- **Plan**: Rework the location/geocoding pipeline primarily on the server side.
If simple enough, also backport the fix to the Pi (local dash) for consistency.
- **Root cause**: Server `_geocode_cached()` returned `None` when both Nominatim and
reverse_geocoder failed to produce a label. The `/api/geocode` endpoint then returned
HTTP 204 with no body. The frontend JS treated 204 as success, called `r.json()` on
empty body → threw → showed raw-coordinate fallback. The Pi version always returned
a label string (with coordinate fallback) and never 204.
- **Fix**:
- Server `_geocode_cached()` now always returns a non-empty string — coordinate
fallback (`lat, lon`) when both geocoders fail, matching Pi behavior.
- Server `/api/geocode` always returns HTTP 200 with `{label: "..."}` (never 204).
- Server `/api/geocode/batch` always includes every coord key in the result dict.
- Server Nominatim call now uses `jsonv2` + `accept-language=en` (aligned with Pi).
- Server reverse_geocoder now uses `mode=1` (aligned with Pi).
- Pi `_geocode_cached()` now checks for empty reverse_geocoder label before
returning (same guard the server has), falling through to coordinate string.
---