Skip to content

Commit

Permalink
make sure polygon is valid and not empty, otherwise, raise an error
Browse files Browse the repository at this point in the history
  • Loading branch information
gshiroma committed Mar 14, 2024
1 parent ddc0be5 commit 2e6eebb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/rtc/h5_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,15 @@ def get_polygon_wkt(burst_in: Sentinel1BurstSlc):
'''

if len(burst_in.border) == 1:
geometry_polygon = burst_in.border[0]
geometry_polygon = shapely.geometry.Polygon(burst_in.border[0])
else:
geometry_polygon = shapely.geometry.MultiPolygon(burst_in.border)

if geometry_polygon.is_empty:
error_msg = f'empty bouding polygon for burst ID {burst_in.burst_id}'
raise RuntimeError(error_msg)
if not geometry_polygon.is_valid:
error_msg = f'invalid bounding polygon for burst ID {burst_in.burst_id}'
raise RuntimeError(error_msg)
return geometry_polygon.wkt


Expand Down

0 comments on commit 2e6eebb

Please sign in to comment.