From 0953abda864d025b4256b959abff5e6e5fbff79f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Mar 2026 18:27:41 +0000 Subject: [PATCH] Add GPS location column to plan Browser captures GPS coords on step 1, server reverse-geocodes via Nominatim, and location is stored in session + written to both Excel rows. https://claude.ai/code/session_015myTTMs6yDsAGarATe5ePZ --- PLAN.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/PLAN.md b/PLAN.md index e753665..1f026a8 100644 --- a/PLAN.md +++ b/PLAN.md @@ -20,16 +20,17 @@ | Backend | Rust + Axum | | AI / OCR | Claude API (vision) | | Spreadsheet | rust_xlsxwriter (Excel) | +| Geocoding | browser Geolocation API + reverse-geocode REST API | | Frontend | Mobile-friendly HTML | --- ## Excel sheet columns -| Date | Time | Odometer start (km) | Odometer end (km) | Trip (km) | Notes | -|------------|-------|---------------------|-------------------|-----------|-------| -| 2026-03-18 | 08:14 | 84 273 | 84 320 | 47 | Ride 1 | -| 2026-03-18 | 09:05 | 84 320 | 84 391 | 71 | Ride 2 | +| Date | Time | Odometer start (km) | Odometer end (km) | Trip (km) | Location | Notes | +|------------|-------|---------------------|-------------------|-----------|-----------------|--------| +| 2026-03-18 | 08:14 | 84 273 | 84 320 | 47 | Amsterdam, NL | Ride 1 | +| 2026-03-18 | 09:05 | 84 320 | 84 391 | 71 | Haarlem, NL | Ride 2 | --- @@ -58,6 +59,7 @@ session { reading_1: Option # start of ride 1 reading_2: Option # end of ride 1 / start of ride 2 reading_3: Option # end of ride 2 + location: Option # reverse-geocoded from GPS at step 1 } ``` @@ -70,8 +72,9 @@ session is cleared. ``` Step 1: "Take photo of odometer — START of ride 1" - [Camera button] → upload + [Camera button] → upload (browser also sends GPS coords) ↓ server reads: 84 273 ✓ + ↓ GPS reverse-geocoded: "Amsterdam, NL" ✓ Step 2: "Take photo of odometer — END of ride 1 / START of ride 2" [Camera button] → upload @@ -92,10 +95,11 @@ Done screen: summary + [Download Excel] + [Start new session] ## Flow (technical) ``` -POST /upload?step=1 → read photo → store reading_1 in session +POST /upload?step=1 → read photo + GPS coords → reverse-geocode location + → store reading_1 + location in session POST /upload?step=2 → read photo → store reading_2 → calc ride1 delta → show POST /upload?step=3 → read photo → store reading_3 → calc ride2 delta - → write 2 rows to Excel → return summary + → write 2 rows to Excel (both with same location) → return summary GET /download → serve mileage_log.xlsx ``` @@ -104,10 +108,11 @@ GET /download → serve mileage_log.xlsx ## Implementation steps 1. Set up Axum server with in-memory session state (DashMap or Mutex) -2. Create a single `/upload` endpoint that accepts `step=1|2|3` + multipart image +2. Create a single `/upload` endpoint that accepts `step=1|2|3` + multipart image + optional lat/lon form fields 3. Send each uploaded image (base64) to Claude Vision API: "What is the odometer reading in km? Reply with only the number." 4. Parse the integer from the response and store it in the session -5. After step 2: calculate ride 1 km, return intermediate confirmation -6. After step 3: calculate ride 2 km, append both rows to the Excel file, clear session -7. Mobile-friendly step-by-step HTML UI (progress indicator, camera capture) -8. `GET /download` endpoint to serve the Excel file +5. At step 1: reverse-geocode lat/lon via a free API (e.g. nominatim.openstreetmap.org) → store city/address in session +6. After step 2: calculate ride 1 km, return intermediate confirmation +7. After step 3: calculate ride 2 km, append both rows (with location) to the Excel file, clear session +8. Mobile-friendly step-by-step HTML UI: request GPS on load, attach coords to each upload, progress indicator +9. `GET /download` endpoint to serve the Excel file