From 7febda0e9423d156a4216fa08286ad8ae4327876 Mon Sep 17 00:00:00 2001 From: Sujan Adhikari <109404840+Sujanadh@users.noreply.github.com> Date: Mon, 13 May 2024 15:48:49 +0545 Subject: [PATCH] fix: populate task_id correctly in feature properties (#1515) --- src/backend/app/db/postgis_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/app/db/postgis_utils.py b/src/backend/app/db/postgis_utils.py index 38e07ea814..965da63caa 100644 --- a/src/backend/app/db/postgis_utils.py +++ b/src/backend/app/db/postgis_utils.py @@ -304,8 +304,11 @@ async def split_geojson_by_task_areas( SELECT jsonb_array_elements(CAST(:geojson_featcol AS jsonb)->'features') AS feature ) AS features - CROSS JOIN tasks - WHERE tasks.project_id = :project_id; + JOIN tasks ON tasks.project_id = :project_id + WHERE + ST_Within( + ST_Centroid(ST_SetSRID(ST_GeomFromGeoJSON(feature->>'geometry'), 4326) + ), tasks.outline); -- Retrieve task outlines based on the provided project_id SELECT