| | |
| | | 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) => { |
| | |
| | | |
| | | // 绘制路线 |
| | | 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] |
| | |
| | | } |
| | | 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 |
| | | // 获取文件中的起飞点 |
| | |
| | | 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) |
| | | } |
| | | } |
| | | } |
| | | }) |
| | |
| | | const clearWaylineData = () => { |
| | | kmlEntities.value = [] |
| | | waylinePointsEvent.value = [] |
| | | _.transform(waylineDetails, (_result, value) => { |
| | | value.value = 0 |
| | | }) |
| | | } |
| | | |
| | | return { |