Skip to content

Commit

Permalink
fix extract points
Browse files Browse the repository at this point in the history
  • Loading branch information
floriscalkoen committed Jul 26, 2024
1 parent 9e904a4 commit 451f9ac
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/coastpy/geo/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,16 @@ def extract_coordinates(pt: Point | tuple[float, float]) -> tuple[float, float]:
Tuple[float, float]: The x and y coordinates of the point.
"""
if isinstance(pt, Point):
return pt[0], pt[1]
return pt
return pt.x, pt.y
elif (
isinstance(pt, tuple)
and len(pt) == 2
and all(isinstance(coord, (float, int)) for coord in pt)
):
return float(pt[0]), float(pt[1])
else:
msg = f"Invalid point provided. Expected a Point object or a tuple of two floats. Received: {pt}"
raise ValueError(msg)


def extract_endpoints(line: LineString) -> tuple[Point, Point]:
Expand Down

0 comments on commit 451f9ac

Please sign in to comment.