fix(phase26): batch geocode endpoint for faster server trip scrubber
This commit is contained in:
@@ -193,6 +193,26 @@ def geocode_route():
|
||||
label = _geocode_cached(int(round(lat, 4) * 10000), int(round(lon, 4) * 10000))
|
||||
return jsonify(label=label)
|
||||
|
||||
@app.route('/api/geocode/batch', methods=['POST'])
|
||||
def geocode_batch_route():
|
||||
body = request.get_json(silent=True) or {}
|
||||
coords = body.get("coords")
|
||||
if not isinstance(coords, list) or not coords:
|
||||
return jsonify(error="expected {coords: [{lat, lon}, ...]}"), 400
|
||||
result = {}
|
||||
for item in coords:
|
||||
try:
|
||||
lat = float(item["lat"])
|
||||
lon = float(item["lon"])
|
||||
except (KeyError, ValueError, TypeError):
|
||||
continue
|
||||
lat4 = int(round(lat, 4) * 10000)
|
||||
lon4 = int(round(lon, 4) * 10000)
|
||||
label = _geocode_cached(lat4, lon4)
|
||||
if label:
|
||||
result[f"{lat:.3f},{lon:.3f}"] = label
|
||||
return jsonify(result)
|
||||
|
||||
@app.route('/api/dash/devices')
|
||||
def dash_devices():
|
||||
devices = app_dash.list_usb_storage_partitions()
|
||||
|
||||
Reference in New Issue
Block a user