From fa66a91747f1dcdf4d64f4f7c60275927dce8fea Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Fri, 24 Oct 2025 17:18:05 +0800
Subject: [PATCH] feat:更新返航高度

---
 src/hooks/common.js |   52 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/src/hooks/common.js b/src/hooks/common.js
index aeb93be..4b32129 100644
--- a/src/hooks/common.js
+++ b/src/hooks/common.js
@@ -26,14 +26,17 @@
 	if (!placemark?.length) return []
 	const isWGS84 = execute_height_mode === 'WGS84'
 	const list = placemark.map(item => {
-		const [longitude, latitude] = item.point.coordinates.trim().split(',')
+		const [longitude, latitude] = item.point.coordinates.trim().split(',').map(i => _.round(i, 6))
+		const [latitude1, longitude1] = (item?.waypoint_heading_param?.waypoint_poi_point?.trim()?.split(',') || [])
+			.map(i => _.round(i, 6))
 		let action_modes = item?.action_group?.action || []
 		action_modes = Array.isArray(action_modes) ? action_modes : [action_modes]
 		return {
-			longitude: _.round(longitude, 8),
-			latitude: _.round(latitude, 8),
-			height: isWGS84 ? item.execute_height : item.execute_height + startPoint.height,
+			longitude,
+			latitude,
+			height: _.round(item.execute_height,2),
 			waypoint_speed: item.waypoint_speed,
+			waypoint_poi_point: longitude1 ? { longitude: longitude1, latitude: latitude1 } : undefined,//兴趣点
 			action_modes,
 		}
 	})
@@ -42,9 +45,6 @@
 		flyRotateYaw: 0,
 		pointType: 'start',
 		waypoint_speed: auto_flight_speed,
-		heading: 0, // 椎体 heading
-		arrowHeading: 0, // 飞行器 heading
-		pitch: 0, //椎体俯仰角
 		fov: 19.5, // 这个是椎体的展示截面大小
 	}
 	list.forEach(item => {
@@ -56,7 +56,6 @@
 				item1.action_actuator_func_param.focal_length = Number(focal_length) / 24
 			}
 		})
-		item.arrowHeading = 0
 	})
 	return [pointStart, ...list]
 }
@@ -69,6 +68,7 @@
 	const waylinesXMLJSON = XMLToJSON(waylinesXML)?.['Document']
 	const templateXMLObj = camelToSnake(removeTextKey(templateXMLJSON))
 	const waylinesXMLObj = camelToSnake(removeTextKey(waylinesXMLJSON))
+
 	const {
 		mission_config: {
 			take_off_ref_point,
@@ -77,12 +77,16 @@
 		folder: {
 			payload_param: { image_format } = {},
 			placemark: {
-				polygon
+				polygon,
+				margin: buffer_distance_meters = 0
 			},
+			wayline_coordinate_sys_param:{height_mode} = {},
 			global_height, auto_flight_speed,
 			template_type: templateType
 		} = {},
 	} = templateXMLObj
+	const [latitude, longitude, height] = take_off_ref_point.split(',').map(item => _.round(item, 6))
+	let startPoint = { latitude, longitude, height: Number.isNaN(height) ? 0 : height }
 
 	const {
 		mission_config: { take_off_security_height } = {},
@@ -98,14 +102,9 @@
 		execute_height_mode = polygonPointFolder.execute_height_mode
 		pointPlacemark = polygonPointFolder.placemark
 	}
-
-	const [latitude, longitude, height] = take_off_ref_point.split(',').map(item => _.round(item, 6))
-	let startPoint = { latitude, longitude, height }
-
 	// 取出点位
 	const coordinates = polygon?.outer_boundary_is.linear_ring
 		.coordinates?.split('\n') || []
-
 	// 数组转换
 	let polygonList = coordinates.map((coordinate) =>
 		coordinate
@@ -113,9 +112,21 @@
 			.split(',')
 			.map((v) => Number(v)),
 	)
-
 	polygonList.pop()
-
+	const templatePlacemark = templateXMLObj.folder.placemark
+	// 点航线list
+	let pointList = handlePointListForKmz({
+		placemark: polygonPointFolder.placemark,
+		startPoint,
+		execute_height_mode,
+		auto_flight_speed
+	}).map((i,index)=> {
+		// 注入是否使用全局高度参数
+		return {
+			...i,
+			use_global_height: index > 0 ? templatePlacemark[index-1]?.use_global_height : 0
+		}
+	})
 	return {
 		image_format,
 		startPoint,
@@ -124,11 +135,14 @@
 		take_off_ref_point,
 		drone_enum_value,
 		drone_sub_enum_value,
-		take_off_security_height,
-		execute_height_mode,
+		take_off_security_height,//起飞安全高度
+		execute_height_mode,//执行高度模式
+		height_mode,//高度模式
+		pointList,//航点航线 点list
 		templateType,
 		pointPlacemark,
-		polygonList
+		polygonList,
+		buffer_distance_meters
 	}
 }
 

--
Gitblit v1.9.3