Add GPS nearby locations endpoint with Overpass API (OpenStreetMap) #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lineage
plan-mcd-tracker→ Phase 5 → Phase 5c: GPS Nearby LocationsRepo
forgejo_admin/mcd-tracker-apiUser Story
auto-location: I want the app to know which McDonald's I'm at without typingArchitecture
arch-dataflow-mcd-tracker#flow-5-auto-detect-location— GPS coords → Overpass API → nearest McDonald's listContext
Phase 5a shipped the Receipt model. The scan flow needs GPS auto-detection to pre-fill the location when a user scans a receipt. This endpoint queries OpenStreetMap's Overpass API to find nearby McDonald's — free, no API key, well-mapped for US chain restaurants.
File Targets
Files to create:
src/mcd_tracker_api/services/__init__.py— emptysrc/mcd_tracker_api/services/overpass.py— Overpass API client using httpx. Query:[out:json]; node["brand"="McDonald's"](around:{radius},{lat},{lng}); out;. Parse response into location list.src/mcd_tracker_api/services/geo.py— Haversine distance calculation (lat/lng → meters/miles)src/mcd_tracker_api/routes/nearby.py—GET /locations/nearbyendpointtests/test_nearby.py— tests with mocked Overpass responsesFiles to modify:
src/mcd_tracker_api/main.py— register nearby routersrc/mcd_tracker_api/schemas.py— add NearbyLocation response schemasrc/mcd_tracker_api/config.py— addoverpass_urlsetting (default:https://overpass-api.de/api/interpreter)Files NOT to touch:
Acceptance Criteria
GET /locations/nearby?lat=39.74&lng=-104.99returns list of nearby McDonald'ssaved_location_idand slot availabilityTest Expectations
pytest tests/ -vConstraints
brand=McDonald'sspecifically (notamenity=fast_foodwhich returns all fast food)addr:street,addr:citytags may be missing on some nodes. Handle gracefully — return coords even if address is incompleteChecklist
Closes #9Related
phase-mcd-tracker-5c-gps-nearby— phase notearch-dataflow-mcd-tracker#flow-5-auto-detect-location— data flowplan-mcd-tracker— parent plan