From aec00ecc093be803860c8675cbe1c4c776a7cb4e Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Tue, 19 Mar 2024 17:49:21 +0800
Subject: [PATCH] update: 新建航线、事件编辑、kmz文件问题修改
---
src/utils/cesium/use-kmz-tsa.ts | 130 ++++++++++++++++++++++++++----------------
1 files changed, 80 insertions(+), 50 deletions(-)
diff --git a/src/utils/cesium/use-kmz-tsa.ts b/src/utils/cesium/use-kmz-tsa.ts
index a437f4a..d7ff54c 100644
--- a/src/utils/cesium/use-kmz-tsa.ts
+++ b/src/utils/cesium/use-kmz-tsa.ts
@@ -145,58 +145,73 @@
template.value = tplXmlJson.Document
return kmzRes
}
- const create = (waylineBasicInfo) => {
- const author = window.localStorage.getItem('username') || ''
- const createTime = new Date().getTime()
- // 模板
- const template = {
- author,
- createTime,
- updateTime: createTime,
- missionConfig: {
- flyToWaylineMode: 'safely',
- finishAction: 'goHome',
- exitOnRCLost: 'goContinue',
- executeRCLostAction: 'goBack',
- takeOffSecurityHeight: 20,
- takeOffRefPoint: '0.000000,0.000000,0.000000',
- takeOffRefPointAGLHeight: 0,
- globalTransitionalSpeed: 15,
- globalRTHHeight: 80,
- droneInfo: {
- droneEnumValue: 0,
- droneSubEnumValue: 0,
+ const create = async (waylineBasicInfo: { fileName: string; droneEnumValue: string; payloadEnumValue: string }) => {
+ try {
+ const { fileName, droneEnumValue, payloadEnumValue } = waylineBasicInfo
+ const author = window.localStorage.getItem('username') || ''
+ const createTime = new Date().getTime()
+ // 模板
+ const droneModel: { [key: string]: string } = {
+ 52: '0',
+ 53: '1',
+ 66: '0',
+ 67: '1',
+ 80: '0',
+ 81: '1',
+ } as const
+ const templateJson = {
+ author,
+ createTime,
+ updateTime: createTime,
+ missionConfig: {
+ flyToWaylineMode: 'safely',
+ finishAction: 'goHome',
+ exitOnRCLost: 'goContinue',
+ executeRCLostAction: 'goBack',
+ takeOffSecurityHeight: 20,
+ takeOffRefPoint: '0.000000,0.000000,0.000000',
+ takeOffRefPointAGLHeight: 0,
+ globalTransitionalSpeed: 15,
+ globalRTHHeight: 80,
+ droneInfo: {
+ droneEnumValue,
+ droneSubEnumValue: droneModel[payloadEnumValue],
+ },
+ payloadInfo: {
+ payloadEnumValue,
+ payloadSubEnumValue: droneModel[payloadEnumValue],
+ payloadPositionIndex: 0,
+ },
},
- payloadInfo: {
- payloadEnumValue: 0,
- payloadSubEnumValue: 0,
- payloadPositionIndex: 0,
+ Folder: {
+ templateType: 'waypoint',
+ useGlobalTransitionalSpeed: 0,
+ templateId: 0,
+ waylineCoordinateSysParam: {
+ coordinateMode: 'WGS84',
+ heightMode: 'EGM96',
+ globalShootHeight: 50,
+ positioningType: 'GPS',
+ surfaceFollowModeEnable: 1,
+ surfaceRelativeHeight: 100,
+ },
+ autoFlightSpeed: 7,
+ gimbalPitchMode: 'usePointSetting',
+ globalWaypointHeadingParam: {
+ waypointHeadingMode: 'followWayline',
+ waypointHeadingAngle: 0,
+ waypointPoiPoint: '0.000000,0.000000,0.000000',
+ waypointHeadingPathMode: 'followBadArc',
+ },
+ globalWaypointTurnMode: 'toPointAndStopWithDiscontinuityCurvature',
+ globalUseStraightLine: 0,
+ Placemark: [],
},
- },
- Folder: {
- templateType: 'waypoint',
- useGlobalTransitionalSpeed: 0,
- templateId: 0,
- waylineCoordinateSysParam: {
- coordinateMode: 'WGS84',
- heightMode: 'EGM96',
- globalShootHeight: 50,
- positioningType: 'GPS',
- surfaceFollowModeEnable: 1,
- surfaceRelativeHeight: 100,
- },
- autoFlightSpeed: 7,
- gimbalPitchMode: 'usePointSetting',
- globalWaypointHeadingParam: {
- waypointHeadingMode: 'followWayline',
- waypointHeadingAngle: 0,
- waypointPoiPoint: '0.000000,0.000000,0.000000',
- waypointHeadingPathMode: 'followBadArc',
- },
- globalWaypointTurnMode: 'toPointAndStopWithDiscontinuityCurvature',
- globalUseStraightLine: 0,
- Placemark: [],
- },
+ }
+ template.value = templateJson
+ return true
+ } catch (error) {
+ return error
}
}
const save = () => {
@@ -246,6 +261,21 @@
if (item === 'waylineId') {
waylinesObj[key][item] = templateJson[key].templateId
}
+ if (item === 'Placemark') {
+ const placemarks = _.cloneDeep(templateJson[key][item])
+ placemarks.forEach(
+ (placemark: {
+ executeHeight: { '#text': string }
+ ellipsoidHeight?: { [x: string]: string }
+ height?: { [x: string]: string }
+ }) => {
+ placemark.executeHeight = { '#text': placemark.ellipsoidHeight?.['#text'] || '' }
+ delete placemark.ellipsoidHeight
+ delete placemark.height
+ },
+ )
+ waylinesObj[key][item] = placemarks
+ }
})
} else {
waylinesObj[key] = templateJson[key]
--
Gitblit v1.9.3