Skip to content

Commit c36407a

Browse files
committed
fix bbox validation
1 parent 567dd44 commit c36407a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Diff for: stac_pydantic/api/search.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,14 @@ def validate_bbox(cls, v: BBox) -> BBox:
7979
raise ValueError(
8080
"Maximum elevation must greater than minimum elevation"
8181
)
82+
# Validate against WGS84
83+
if xmin < -180 or ymin < -90 or xmax > 180 or ymax > 90:
84+
raise ValueError("Bounding box must be within (-180, -90, 180, 90)")
8285

8386
if xmax < xmin:
8487
# xmin > xmax is permitted when crossing the antimeridian
8588
# https://datatracker.ietf.org/doc/html/rfc7946#section-5.2
86-
if not ((xmin < 0) and (xmax > 0)):
89+
if not ((xmax < 0) and (xmin > 0)):
8790
raise ValueError(
8891
"Maximum longitude must be greater than minimum longitude"
8992
)
@@ -93,10 +96,6 @@ def validate_bbox(cls, v: BBox) -> BBox:
9396
"Maximum longitude must be greater than minimum longitude"
9497
)
9598

96-
# Validate against WGS84
97-
if xmin < -180 or ymin < -90 or xmax > 180 or ymax > 90:
98-
raise ValueError("Bounding box must be within (-180, -90, 180, 90)")
99-
10099
return v
101100

102101
@field_validator("datetime")

0 commit comments

Comments
 (0)