feat(geocode): fully offline reverse geocode via local Pi API
- Remove all Nominatim/external calls from frontend - Add /api/geocode?lat=&lon= route using reverse_geocoder (20MB offline KD-tree) - JS hits /api/geocode only — works with no internet at all - Falls back to raw coords if Pi route fails - Add reverse_geocoder to requirements.txt Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -89,6 +89,23 @@ def trip_route(trip_id):
|
||||
return jsonify(error=f"Trip not found: {trip_id}"), 404
|
||||
return jsonify(trip)
|
||||
|
||||
@app.route('/api/geocode')
|
||||
def geocode_route():
|
||||
try:
|
||||
lat = float(request.args['lat'])
|
||||
lon = float(request.args['lon'])
|
||||
except (KeyError, ValueError):
|
||||
return jsonify(error="lat and lon required"), 400
|
||||
import reverse_geocoder as rg
|
||||
results = rg.search([(lat, lon)], mode=1, verbose=False)
|
||||
if results:
|
||||
r = results[0]
|
||||
parts = [r.get('name', ''), r.get('admin1', '')]
|
||||
label = ', '.join(p for p in parts if p)
|
||||
else:
|
||||
label = f"{lat:.5f}, {lon:.5f}"
|
||||
return jsonify(label=label)
|
||||
|
||||
@app.route('/api/dash/devices')
|
||||
def dash_devices():
|
||||
devices = app_dash.list_usb_storage_partitions()
|
||||
|
||||
Reference in New Issue
Block a user