Data: Stations and pumping (the tracked stations, their position, pump.sh from the app); the weather of the station at Load

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-17 08:51:48 +01:00
1 parent eaa124f9f5
commit c8c8c1587a
8 files changed
+261 -14

No files matched your search

+7 -3
View File
@@ -19,6 +19,7 @@ import csv
import io
import json
import math
import re
import sys
import urllib.parse
import urllib.request
@@ -70,9 +71,9 @@ def locate(place):
query = urllib.parse.urlencode({"searchText": place, "type": "locations", "limit": 1, "sr": 4326})
results = json.loads(fetch(f"{GEOCODER}?{query}"))["results"]
if not results:
sys.exit(f"place not found: {place}")
raise LookupError(f"place not found: {place}")
attrs = results[0]["attrs"]
label = attrs["label"].replace("<b>", "").replace("</b>", "").split("\n")[0].strip()
label = re.sub(r"<[^>]+>", "", attrs["label"]).split("\n")[0].strip()
return attrs["lat"], attrs["lon"], label
@@ -137,7 +138,10 @@ def main():
if args.start >= datetime.now(timezone.utc):
sys.exit("the range must be in the past")
lat, lon, label = locate(args.place)
try:
lat, lon, label = locate(args.place)
except LookupError as e:
sys.exit(str(e))
station = nearest_station(lat, lon)
abbr = station["station_abbr"]
print(f"{label} ({lat:.4f}, {lon:.4f}) -> station {abbr} {station['station_name']}, "