From 8a410ae685f5972b8a87c5c7b03dabb1d9d65fb2 Mon Sep 17 00:00:00 2001 From: Nathan Zimmerman Date: Wed, 18 Aug 2021 10:08:53 -0500 Subject: [PATCH] Remove 501 usage from bbox handling --- stac_fastapi/pgstac/stac_fastapi/pgstac/core.py | 5 ----- stac_fastapi/pgstac/tests/resources/test_item.py | 4 ---- .../sqlalchemy/stac_fastapi/sqlalchemy/core.py | 14 +++++++++----- .../sqlalchemy/tests/resources/test_item.py | 4 ---- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py b/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py index cfb1a767e..384388e7d 100644 --- a/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py +++ b/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py @@ -190,11 +190,6 @@ async def post_search( Returns: ItemCollection containing items which match the search criteria. """ - if search_request.bbox and len(search_request.bbox) == 6: - raise HTTPException( - status_code=501, - detail="Support for 3D bounding boxes is not yet implemented", - ) item_collection = await self._search_base(search_request, **kwargs) return ItemCollection(**item_collection) diff --git a/stac_fastapi/pgstac/tests/resources/test_item.py b/stac_fastapi/pgstac/tests/resources/test_item.py index b16377454..b1a4f0f62 100644 --- a/stac_fastapi/pgstac/tests/resources/test_item.py +++ b/stac_fastapi/pgstac/tests/resources/test_item.py @@ -940,10 +940,6 @@ async def test_search_bbox_errors(app_client): resp = await app_client.post("/search", json=body) assert resp.status_code == 400 - params = {"bbox": "0,0,0,1,1,1"} - resp = await app_client.get("/search", params=params) - assert resp.status_code == 501 - params = {"bbox": "100.0,0.0,0.0,105.0"} resp = await app_client.get("/search", params=params) assert resp.status_code == 400 diff --git a/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py b/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py index 838df9e94..fb5edb7ba 100644 --- a/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py +++ b/stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/core.py @@ -211,7 +211,7 @@ def get_search( # Do the request try: search_request = SQLAlchemySTACSearch(**base_args) - except ValidationError: + except ValidationError as ve: raise HTTPException(status_code=400, detail="Invalid parameters provided") resp = self.post_search(search_request, request=kwargs["request"]) @@ -301,10 +301,14 @@ def post_search( if len(search_request.bbox) == 4: poly = ShapelyPolygon.from_bounds(*search_request.bbox) elif len(search_request.bbox) == 6: - raise HTTPException( - status_code=501, - detail="Support for 3D bounding boxes is not yet implemented", - ) + """Shapely doesn't support 3d bounding boxes we'll just use the 2d portion""" + bbox_2d = [ + search_request.bbox[0], + search_request.bbox[1], + search_request.bbox[3], + search_request.bbox[4], + ] + poly = ShapelyPolygon.from_bounds(*bbox_2d) if poly: filter_geom = ga.shape.from_shape(poly, srid=4326) diff --git a/stac_fastapi/sqlalchemy/tests/resources/test_item.py b/stac_fastapi/sqlalchemy/tests/resources/test_item.py index 5408ed3b2..0639167e6 100644 --- a/stac_fastapi/sqlalchemy/tests/resources/test_item.py +++ b/stac_fastapi/sqlalchemy/tests/resources/test_item.py @@ -771,10 +771,6 @@ def test_search_bbox_errors(app_client): resp = app_client.post("/search", json=body) assert resp.status_code == 400 - params = {"bbox": "0,0,0,1,1,1"} - resp = app_client.get("/search", params=params) - assert resp.status_code == 501 - params = {"bbox": "100.0,0.0,0.0,105.0"} resp = app_client.get("/search", params=params) assert resp.status_code == 400