refactor from disgusting monolith

This commit is contained in:
2026-01-24 17:20:00 -05:00
parent 22c6c01007
commit b4728e3dde
12 changed files with 390 additions and 165 deletions

17
utils/geocode.py Normal file
View File

@@ -0,0 +1,17 @@
import requests
def get_city_name(lat, lon):
try:
r = requests.get(
"https://nominatim.openstreetmap.org/reverse",
params={"lat": lat, "lon": lon, "format": "json", "zoom": 10, "addressdetails": 1},
headers={"User-Agent": "AreWeBuriedApp/1.0"}
)
r.raise_for_status()
data = r.json()
address = data.get("address", {})
city = address.get("city") or address.get("town") or address.get("village") or address.get("county") or f"{lat:.2f},{lon:.2f}"
return city
except Exception as e:
print("Reverse geocoding error:", e)
return f"{lat:.2f},{lon:.2f}"