Skip to content

Commit

Permalink
feat: update outline and bbox of task in task details endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradip-p committed Oct 30, 2024
1 parent 77f45cd commit a283d04
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/backend/app/tasks/task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ async def read_task(
"""
SELECT
ST_Area(ST_Transform(tasks.outline, 3857)) / 1000000 AS task_area,
-- Construct the outline as a GeoJSON Feature
jsonb_build_object(
'type', 'Feature',
'geometry', jsonb_build_object(
'type', ST_GeometryType(tasks.outline)::text, -- Get the type of the geometry (e.g., Polygon, MultiPolygon)
'coordinates', ST_AsGeoJSON(tasks.outline, 8)::jsonb->'coordinates' -- Get the geometry coordinates
),
'properties', jsonb_build_object(
'id', tasks.id,
'bbox', jsonb_build_array( -- Build the bounding box
ST_XMin(ST_Envelope(tasks.outline)),
ST_YMin(ST_Envelope(tasks.outline)),
ST_XMax(ST_Envelope(tasks.outline)),
ST_YMax(ST_Envelope(tasks.outline))
)
),
'id', tasks.id
) AS outline,
te.created_at,
te.updated_at,
te.state,
Expand All @@ -43,6 +63,7 @@ async def read_task(
projects.side_overlap AS side_overlap,
projects.gsd_cm_px AS gsd_cm_px,
projects.gimble_angles_degrees AS gimble_angles_degrees
FROM (
SELECT DISTINCT ON (te.task_id)
te.task_id,
Expand Down

0 comments on commit a283d04

Please sign in to comment.