Skip to content

Commit

Permalink
Also allow LinearRings in snapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Huite committed Aug 4, 2023
1 parent df568ac commit 74ee2f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xugrid/ugrid/snapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def left_of(a: Point, p: Point, U: Vector) -> bool:
def coerce_geometry(lines: GeoDataFrameType) -> LineArray:
geometry = lines.geometry.values
geom_type = shapely.get_type_id(geometry)
if not (geom_type == 1).all():
raise ValueError("Geometry should contain only LineStrings")
if not (geom_type == 1 | geom_type == 2).all():
raise ValueError("Geometry should contain only LineStrings and/or LinearRings")
return geometry


Expand Down Expand Up @@ -384,7 +384,8 @@ def snap_to_grid(
topology = grid.ugrid.grid
else:
raise TypeError(
f"Expected xarray.DataArray or xugrid.UgridDataArray, received: {type(grid).__name__}"
"Expected xarray.DataArray or xugrid.UgridDataArray, received: "
f" {type(grid).__name__}"
)

vertices = topology.node_coordinates
Expand Down

0 comments on commit 74ee2f5

Please sign in to comment.