Skip to content

Commit

Permalink
Remove Z coordinate on constructing Node
Browse files Browse the repository at this point in the history
Fix #1854
  • Loading branch information
visr committed Dec 23, 2024
1 parent 13340f8 commit 8b5578a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/ribasim/ribasim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ def __init__(
) -> None:
if geometry.is_empty:
raise (ValueError("Node geometry must be a valid Point"))
elif geometry.has_z:
# Remove any Z coordinate, this will cause issues connecting 2D and 3D nodes
geometry = Point(geometry.x, geometry.y)
super().__init__(node_id=node_id, geometry=geometry, **kwargs)

def into_geodataframe(self, node_type: str, node_id: int) -> GeoDataFrame:
Expand Down
4 changes: 3 additions & 1 deletion python/ribasim/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ def test_extra_spatial_columns():
Node(1, Point(0, 0), meta_id=1),
[basin.Profile(area=1000.0, level=[0.0, 1.0]), basin.State(level=[1.0])],
)
node = Node(2, Point(1, 0.5, 3.0), meta_id=2)
assert not node.geometry.has_z
model.user_demand.add(
Node(2, Point(1, 0.5), meta_id=2),
node,
[
user_demand.Static(
demand=[1e-4], return_factor=0.9, min_level=0.9, priority=1
Expand Down

0 comments on commit 8b5578a

Please sign in to comment.