From e6433eb5a1a34e7d61717ed26925c8b1a1dcfa19 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Wed, 1 May 2024 15:08:49 -0700 Subject: [PATCH] GTC-2027 (part 2) - give useful error when input geometry is not Polygon/MultiPolygon This is to fix some more "tuple index out of range" 500 errors. My previous fix was for usual queries. This fix is for zonal statistics calls. (which have been deprecated for quite a while - should we just disable zonal statistics queries sometime soon?) --- app/routes/analysis/analysis.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/routes/analysis/analysis.py b/app/routes/analysis/analysis.py index 989f72fc1..c49c17c1f 100644 --- a/app/routes/analysis/analysis.py +++ b/app/routes/analysis/analysis.py @@ -101,6 +101,12 @@ async def _zonal_statistics( start_date: Optional[str], end_date: Optional[str], ): + if geometry.type != "Polygon" and geometry.type != "MultiPolygon": + raise HTTPException( + status_code=400, + detail=f"Geometry must be a Polygon or MultiPolygon for raster analysis" + ) + # OTF will just not apply a base filter base = "data"