Skip to content

Commit

Permalink
Revert "Update graph_utilities.py"
Browse files Browse the repository at this point in the history
This reverts commit b347dbf.
  • Loading branch information
Dobson committed May 8, 2024
1 parent b347dbf commit 7485b79
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions swmmanywhere/graph_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,28 @@ def __call__(self,
# Copy graph to run shortest path on
G_ = G.copy()

if not matched_outlets:
# In cases of e.g., an area with no rivers to discharge into or too
# small a buffer

# Identify the lowest elevation node
lowest_elevation_node = min(G.nodes,
key = lambda x: G.nodes[x]['surface_elevation'])

# Create a dummy river to discharge into
dummy_river = {'id' : 'dummy_river',
'x' : G.nodes[lowest_elevation_node]['x'] + 1,
'y' : G.nodes[lowest_elevation_node]['y'] + 1}
G_.add_node('dummy_river')
nx.set_node_attributes(G_, {'dummy_river' : dummy_river})

# Update function's dicts
matched_outlets = {'dummy_river' : lowest_elevation_node}
river_points['dummy_river'] = shapely.Point(dummy_river['x'],
dummy_river['y'])

logger.warning('No outlets found, using lowest elevation node as outlet')

# Add edges between the paired river and street nodes
for river_id, street_id in matched_outlets.items():
# TODO instead use a weight based on the distance between the two nodes
Expand Down

0 comments on commit 7485b79

Please sign in to comment.