From 8a4bc64a1b354698ad52e4efc8cf49ec8b5f5fe6 Mon Sep 17 00:00:00 2001 From: Lars Falk-Petersen Date: Thu, 4 Jan 2024 15:16:38 +0100 Subject: [PATCH] Detect missing coords. --- app/routes/collections_page.py | 2 +- app/routes/position_page.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/routes/collections_page.py b/app/routes/collections_page.py index 70037a5..ba3a6fa 100644 --- a/app/routes/collections_page.py +++ b/app/routes/collections_page.py @@ -105,7 +105,7 @@ def create_collection(collection_id: str = "", instance_id: str = "") -> dict: # Get posision in default instance position=edr_pydantic.data_queries.EDRQuery( link=edr_pydantic.data_queries.EDRQueryLink( - href=f"{collection_url}position/", + href=f"{collection_url}position", rel="data", variables=edr_pydantic.variables.Variables( query_type="position", diff --git a/app/routes/position_page.py b/app/routes/position_page.py index eb5a21d..a023c5b 100644 --- a/app/routes/position_page.py +++ b/app/routes/position_page.py @@ -216,13 +216,17 @@ def check_coords_within_bounds(ds: xr.Dataset, point: Point) -> Tuple[bool, str] return True, "" -@router.get("/collections/isobaric/position") -async def create_isobaric_page(coords: str) -> dict: +@router.get("/collections/isobaric/position/") +async def create_isobaric_page(request: Request, coords: str = "") -> dict: """Position. This is the main function of this API. Needs a string with the coordinates, and will return data for the nearest point. """ + if len(coords) == 0: + return { + "body": f'Error: No coordinates provided. Example: {str(request.base_url)[0:-1]}{request.scope["path"]}?coords=POINT(11 59)' + } return create_point(coords=coords)