overpass/main.py

43 lines
1.3 KiB
Python

from overpass import load_pois, OverpassApiError
from models import POI
# ---------------------------------------------------------------------------
# Konfiguration
# ---------------------------------------------------------------------------
BBOXEN = {
"davos": (46.72, 9.70, 46.92, 10.00),
"schweiz": (45.8, 5.9, 47.8, 10.5),
}
QUERY = """
[out:json][timeout:2][maxsize:500000];
(
node["aerialway"="station"]({bbox});
way["aerialway"="station"]({bbox});
node["railway"="funicular"]({bbox});
way["railway"="funicular"]({bbox});
node["railway"="station"]["funicular"="yes"]({bbox});
);
out center body;
"""
# ---------------------------------------------------------------------------
# Hauptlogik
# ---------------------------------------------------------------------------
def main() -> None:
for name, bbox in BBOXEN.items():
try:
pois: list[POI] = load_pois(overpass_query=QUERY, bbox=bbox)
except OverpassApiError as exc:
print(f"Fehler bei '{name}': {exc}")
continue
print(f"\n{name}: {len(pois)} POIs gefunden")
for poi in pois:
print(f" {poi.id}: ({poi.lat}, {poi.lon})")
if __name__ == "__main__":
main()