From fb1daf83dd21a879be8a2b6be1a40e55d89ba0be Mon Sep 17 00:00:00 2001 From: Dobson Date: Thu, 28 Nov 2024 15:19:00 +0000 Subject: [PATCH] osmnx bug --- src/swmmanywhere/prepare_data.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/swmmanywhere/prepare_data.py b/src/swmmanywhere/prepare_data.py index e98359a0..b8451263 100644 --- a/src/swmmanywhere/prepare_data.py +++ b/src/swmmanywhere/prepare_data.py @@ -6,6 +6,7 @@ from __future__ import annotations from pathlib import Path +from packaging.version import Version from typing import cast import cdsapi @@ -153,8 +154,9 @@ def download_street( nx.MultiDiGraph: Street network with type drive and ``truncate_by_edge set`` to True. """ - west, south, east, north = bbox - bbox = (north, south, east, west) # not sure why osmnx uses this order + if Version(ox.__version__) < Version("2.0.0b1"): + west, south, east, north = bbox + bbox = (north, south, east, west) graph = ox.graph_from_bbox( bbox=bbox, network_type=network_type, truncate_by_edge=True ) @@ -172,10 +174,12 @@ def download_river(bbox: tuple[float, float, float, float]) -> nx.MultiDiGraph: nx.MultiDiGraph: River network with type waterway and ``truncate_by_edge set`` to True. """ - west, south, east, north = bbox try: + if Version(ox.__version__) < Version("2.0.0"): + west, south, east, north = bbox + bbox = (north, south, east, west) graph = ox.graph_from_bbox( - bbox=(north, south, east, west), + bbox=bbox, truncate_by_edge=True, custom_filter='["waterway"]', retain_all=True,