overpass/main.py

40 lines
1.2 KiB
Python

from overpass import fetch_overpass, OverpassApiError
# ---------------------------------------------------------------------------
# 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:
result = fetch_overpass(overpass_query=QUERY, bbox=bbox)
except OverpassApiError as exc:
print(f" Fehler : {exc}")
continue
elements = result.get("elements", [])
print(elements)
if __name__ == "__main__":
main()