Skip to content

Commit

Permalink
improve node merging
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed Apr 29, 2024
1 parent 7d32569 commit 8a89328
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions swmmanywhere/geospatial_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,12 +946,23 @@ def merge_points(coordinates: list[tuple[float, float]],

# Merge pairs into families of points that are all nearby
families: list = []

for pair in pairs:
for family in families:
if pair[0] in family or pair[1] in family:
family.update(pair)
break
matched_families = [family for family in families
if pair[0] in family or pair[1] in family]

if matched_families:
# Merge all matched families and add the current pair
new_family = set(pair)
for family in matched_families:
new_family.update(family)

# Remove the old families and add the newly formed one
for family in matched_families:
families.remove(family)
families.append(new_family)
else:
# No matching family found, so create a new one
families.append(set(pair))

# Create a mapping of the original point to the merged point
Expand Down
2 changes: 1 addition & 1 deletion swmmanywhere/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SubcatchmentDerivation(BaseModel):
unit = "m",
description = "Distance to split streets into segments.")

node_merge_distance: float = Field(default = 30,
node_merge_distance: float = Field(default = 10,
ge = 1,
le = 40,
unit = 'm',
Expand Down

0 comments on commit 8a89328

Please sign in to comment.