22
22
23
23
from app .config import settings
24
24
from app .db import database
25
- from app .models .enums import FlightMode , HTTPStatus
25
+ from app .models .enums import FlightMode , HTTPStatus , DroneType
26
26
from app .projects import project_deps
27
27
from app .s3 import get_file_from_bucket
28
28
from app .tasks .task_logic import (
29
29
get_take_off_point_from_db ,
30
30
get_task_geojson ,
31
31
update_take_off_point_in_db ,
32
32
)
33
- from app .utils import merge_multipolygon
33
+ from app .utils import merge_multipolygon , calculate_flight_time_from_placemarks
34
34
from app .waypoints import waypoint_schemas
35
35
from app .waypoints .waypoint_logic import (
36
36
check_point_within_buffer ,
@@ -56,6 +56,7 @@ async def get_task_waypoint(
56
56
download : bool = True ,
57
57
mode : FlightMode = FlightMode .waylines ,
58
58
rotation_angle : float = 0 ,
59
+ drone_type : DroneType = DroneType .DJI_MINI_4_PRO ,
59
60
take_off_point : waypoint_schemas .PointField = None ,
60
61
):
61
62
"""Retrieve task waypoints and download a flight plan.
@@ -115,6 +116,7 @@ async def get_task_waypoint(
115
116
altitude ,
116
117
gsd ,
117
118
2 , # Image Interval is set to 2
119
+ drone_type ,
118
120
)
119
121
120
122
# Common parameters for create_waypoint
@@ -127,6 +129,7 @@ async def get_task_waypoint(
127
129
"rotation_angle" : rotation_angle ,
128
130
"generate_3d" : generate_3d ,
129
131
"take_off_point" : take_off_point ,
132
+ "drone_type" : drone_type ,
130
133
}
131
134
132
135
if project .is_terrain_follow :
@@ -175,7 +178,10 @@ async def get_task_waypoint(
175
178
media_type = "application/vnd.google-earth.kmz" ,
176
179
filename = f"{ task_id } _flight_plan.kmz" ,
177
180
)
178
- return {"results" : placemarks }
181
+ flight_data = calculate_flight_time_from_placemarks (placemarks )
182
+
183
+ drones = list (DroneType .__members__ .keys ())
184
+ return {"results" : placemarks , "flight_data" : flight_data , "drones" : drones }
179
185
180
186
181
187
@router .post ("/" )
@@ -221,6 +227,7 @@ async def generate_kmz(
221
227
description = "The Digital Elevation Model (DEM) file that will be used to generate the terrain follow flight plan. This file should be in GeoTIFF format" ,
222
228
),
223
229
take_off_point : waypoint_schemas .PointField = None ,
230
+ drone_type : DroneType = DroneType .DJI_MINI_4_PRO ,
224
231
):
225
232
if not (altitude or gsd ):
226
233
raise HTTPException (
@@ -264,6 +271,7 @@ async def generate_kmz(
264
271
generate_each_points = generate_each_points ,
265
272
generate_3d = generate_3d ,
266
273
take_off_point = take_off_point ,
274
+ drone_type = drone_type ,
267
275
)
268
276
return geojson .loads (points )
269
277
else :
@@ -277,6 +285,7 @@ async def generate_kmz(
277
285
dem = dem_path if dem else None ,
278
286
outfile = f"/tmp/{ uuid .uuid4 ()} " ,
279
287
take_off_point = take_off_point ,
288
+ drone_type = drone_type ,
280
289
)
281
290
282
291
return FileResponse (
0 commit comments