From e72969f25dd1a243e48c783dedc0f198ee08c2b8 Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Wed, 20 Mar 2024 17:19:04 +0800
Subject: [PATCH] update:新增航线、航点事件编辑
---
src/utils/cesium/use-map-draw.ts | 44 ++++++++++++++++++++++++++++----------------
1 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/src/utils/cesium/use-map-draw.ts b/src/utils/cesium/use-map-draw.ts
index e5a8005..3f411f2 100644
--- a/src/utils/cesium/use-map-draw.ts
+++ b/src/utils/cesium/use-map-draw.ts
@@ -5,6 +5,7 @@
import { ref } from 'vue'
import { cesiumOperation } from '/@/hooks/use-cesium-tsa'
import { XMLToJSON } from './kmz'
+import _ from 'lodash'
const { addPolyline, getEntityById, removeAllDataSource, removeAllPoint } = cesiumOperation()
const getResource = (name: string) => {
@@ -125,7 +126,10 @@
// 绘制路线
const drawWayline = async (entities?: Cesium.Entity[], kmlStr?: string) => {
- if (!entities && !kmlStr) {
+ // if (!entities && !kmlStr) {
+ // dataSource.show = false
+ // }
+ if (dataSource) {
dataSource.show = false
}
let kmlEntityArr = entities || [...entitiesList]
@@ -145,7 +149,9 @@
}
const kmlJson = XMLToJSON(kmlRes)
// 所有航点
- const kmlPoints = kmlJson.Document.Folder.Placemark
+ const kmlPoints = Array.isArray(kmlJson.Document.Folder.Placemark)
+ ? kmlJson.Document.Folder.Placemark
+ : [kmlJson.Document.Folder.Placemark]
// 起飞点
let btmStartPoint = null
// 获取文件中的起飞点
@@ -303,23 +309,26 @@
kmlRes = await fileRes.fileInfoObj['wpmz/template.kml']
}
const kmlJson = XMLToJSON(kmlRes).Document
- const points = kmlJson.Folder?.Placemark
+ const points = Array.isArray(kmlJson.Folder?.Placemark) ? kmlJson.Folder.Placemark : [kmlJson.Folder.Placemark]
let takePhotoNum = 0
points?.forEach((point: { actionGroup: any }, index: number) => {
- if (Reflect.has(point, 'actionGroup')) {
- const action = point.actionGroup.action
- if (Array.isArray(action)) {
- action.forEach((item) => {
- const { actionActuatorFunc } = item
- actionActuatorFunc?.['#text'] === 'takePhoto' && takePhotoNum++
- const actionObj: eventParmas | any = actionList.find((event) => actionActuatorFunc['#text'] === event.key)
+ if (point !== undefined) {
+ if (Reflect.has(point, 'actionGroup')) {
+ const action = point.actionGroup.action
+ if (Array.isArray(action)) {
+ action.forEach((item) => {
+ const { actionActuatorFunc } = item
+ actionActuatorFunc?.['#text'] === 'takePhoto' && takePhotoNum++
+ const actionObj: eventParmas | any = actionList.find((event) => actionActuatorFunc['#text'] === event.key)
+ waylinePointsEvent.value[index].eventList?.push(actionObj)
+ })
+ } else {
+ action?.actionActuatorFunc['#text'] === 'takePhoto' && takePhotoNum++
+ const actionObj: eventParmas | any = actionList.find(
+ (item) => action?.actionActuatorFunc['#text'] === item.key,
+ )
waylinePointsEvent.value[index].eventList?.push(actionObj)
- })
- } else {
- const { actionActuatorFunc } = action
- actionActuatorFunc['#text'] === 'takePhoto' && takePhotoNum++
- const actionObj: eventParmas | any = actionList.find((item) => actionActuatorFunc['#text'] === item.key)
- waylinePointsEvent.value[index].eventList?.push(actionObj)
+ }
}
}
})
@@ -328,6 +337,9 @@
const clearWaylineData = () => {
kmlEntities.value = []
waylinePointsEvent.value = []
+ _.transform(waylineDetails, (_result, value) => {
+ value.value = 0
+ })
}
return {
--
Gitblit v1.9.3