Skip to content

fix bbox validation #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions stac_pydantic/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,15 @@ def validate_bbox(cls, v: BBox) -> BBox:
raise ValueError(
"Maximum elevation must greater than minimum elevation"
)

if xmax < xmin:
raise ValueError(
"Maximum longitude must be greater than minimum longitude"
)
# Validate against WGS84
if xmin < -180 or ymin < -90 or xmax > 180 or ymax > 90:
raise ValueError("Bounding box must be within (-180, -90, 180, 90)")

if ymax < ymin:
raise ValueError(
"Maximum longitude must be greater than minimum longitude"
)

# Validate against WGS84
if xmin < -180 or ymin < -90 or xmax > 180 or ymax > 90:
raise ValueError("Bounding box must be within (-180, -90, 180, 90)")

return v

@field_validator("datetime")
Expand Down
1 change: 0 additions & 1 deletion tests/api/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def test_search_geometry_bbox():
"bbox",
[
(100.0, 1.0, 105.0, 0.0), # ymin greater than ymax
(100.0, 0.0, 95.0, 1.0), # xmin greater than xmax
(100.0, 0.0, 5.0, 105.0, 1.0, 4.0), # min elev greater than max elev
(-200.0, 0.0, 105.0, 1.0), # xmin is invalid WGS84
(100.0, -100, 105.0, 1.0), # ymin is invalid WGS84
Expand Down