Skip to content

Commit

Permalink
osmnx bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed Nov 28, 2024
1 parent 446fd2b commit fb1daf8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/swmmanywhere/prepare_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

from pathlib import Path
from packaging.version import Version
from typing import cast

import cdsapi
Expand Down Expand Up @@ -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
)
Expand All @@ -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,
Expand Down

0 comments on commit fb1daf8

Please sign in to comment.