From 48d04fe290aa62969e1221a2db2577d6944be77a Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Wed, 7 Aug 2024 14:04:50 +0545 Subject: [PATCH] get dem from s3 when generating flightplan for individual tasks --- src/backend/app/waypoints/waypoint_routes.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/backend/app/waypoints/waypoint_routes.py b/src/backend/app/waypoints/waypoint_routes.py index 0ca56581..ea7de1ef 100644 --- a/src/backend/app/waypoints/waypoint_routes.py +++ b/src/backend/app/waypoints/waypoint_routes.py @@ -10,6 +10,7 @@ from app.projects.project_crud import get_project_by_id from app.db import database from app.utils import merge_multipolygon +from app.s3 import get_file_from_bucket from databases import Database @@ -57,10 +58,11 @@ async def get_task_waypoint( generate_3d, ) else: - # dem_path = f"/tmp/{dem.filename}" - # with open(dem_path, "wb") as buffer: - # shutil.copyfileobj(dem.file, buffer) - + if project.is_terrain_follow: + dem_path = f"/tmp/{uuid.uuid4()}/dem.tif" + get_file_from_bucket( + settings.S3_BUCKET_NAME, f"dem/{project_id}/dem.tif", dem_path + ) output_file = flightplan.generate_flightplan( features, altitude, @@ -70,7 +72,7 @@ async def get_task_waypoint( generate_each_points, generate_3d, project.is_terrain_follow, - # dem_path if dem else None, + dem_path if project.is_terrain_follow else None, f"/tmp/{uuid.uuid4()}", )