| | |
| | | import { ref } from 'vue' |
| | | import { cesiumOperation } from '/@/hooks/use-cesium-tsa' |
| | | import { XMLToJSON } from './kmz' |
| | | import _, { includes } from 'lodash' |
| | | const { addPolyline, getEntityById, removeAllDataSource, removeAllPoint } = cesiumOperation() |
| | | |
| | | const getResource = (name: string) => { |
| | |
| | | icon: getResource('waylinetool/camera-off.png'), |
| | | }, |
| | | { |
| | | key: 'time', |
| | | key: 'multipleTiming', |
| | | name: '开始等时间隔拍照', |
| | | icon: getResource('waylinetool/shoot1.png'), |
| | | }, |
| | | { |
| | | key: 'distance', |
| | | key: 'multipleDistance', |
| | | name: '开始等距间隔拍照', |
| | | icon: getResource('waylinetool/shoot2.png'), |
| | | }, |
| | |
| | | key: 'hover', |
| | | name: '悬停等待', |
| | | icon: getResource('waylinetool/xt.png'), |
| | | }, |
| | | { |
| | | key: 'panoShot', |
| | | name: '全景拍摄', |
| | | icon: getResource('waylinetool/panoramicview.png'), |
| | | }, |
| | | ] |
| | | |
| | |
| | | |
| | | // 绘制路线 |
| | | 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 |
| | | let takePhotoNum = 0 |
| | | const points = Array.isArray(kmlJson.Folder?.Placemark) ? kmlJson.Folder.Placemark : [kmlJson.Folder.Placemark] |
| | | 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) |
| | | 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) |
| | | if (point !== undefined) { |
| | | if (Reflect.has(point, 'actionGroup')) { |
| | | if (Array.isArray(point.actionGroup)) { |
| | | const actionGroups = point.actionGroup |
| | | actionGroups.forEach((actionGroup) => { |
| | | const action = actionGroup.action |
| | | const actionTrigger = actionGroup.actionTrigger |
| | | pointActionShow(action, actionTrigger, index) |
| | | }) |
| | | } else { |
| | | const action = point.actionGroup.action |
| | | const actionTrigger = point.actionGroup.actionTrigger |
| | | pointActionShow(action, actionTrigger, index) |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | waylineDetails[3].value = takePhotoNum |
| | | } |
| | | |
| | | let takePhotoNum = 0 |
| | | const pointActionShow = ( |
| | | action: { forEach: (arg0: (item: any) => void) => void; actionActuatorFunc: { [x: string]: string } }, |
| | | actionTrigger: { actionTriggerType: { [x: string]: string } }, |
| | | index: number, |
| | | ) => { |
| | | if (Array.isArray(action)) { |
| | | action.forEach((item) => { |
| | | const { actionActuatorFunc } = item |
| | | actionActuatorFunc?.['#text'] === 'takePhoto' && takePhotoNum++ |
| | | const actionObj: eventParmas | any = actionList.find((event) => { |
| | | if (actionTrigger?.actionTriggerType['#text'] === event.key) { |
| | | return actionTrigger?.actionTriggerType['#text'] === event.key |
| | | } else { |
| | | return actionActuatorFunc['#text'] === event.key |
| | | } |
| | | }) |
| | | waylinePointsEvent.value[index].eventList?.push(actionObj) |
| | | }) |
| | | } else { |
| | | action?.actionActuatorFunc['#text'] === 'takePhoto' && takePhotoNum++ |
| | | const actionObj: eventParmas | any = actionList.find((item) => { |
| | | const actionTriggerType = actionTrigger.actionTriggerType['#text'] |
| | | if (['multipleDistance', 'multipleTiming'].includes(actionTriggerType)) { |
| | | return actionTriggerType === item.key |
| | | } else { |
| | | return action?.actionActuatorFunc['#text'] === item.key |
| | | } |
| | | }) |
| | | waylinePointsEvent.value[index].eventList?.push(actionObj) |
| | | } |
| | | } |
| | | |
| | | const clearWaylineData = () => { |
| | | kmlEntities.value = [] |
| | | waylinePointsEvent.value = [] |
| | | _.transform(waylineDetails, (_result, value) => { |
| | | value.value = 0 |
| | | }) |
| | | } |
| | | |
| | | return { |
| | |
| | | } |
| | | } |
| | | |
| | | export { waylinePointsEvent, waylineDetails, kmlEntities, selectPointIndex } |
| | | export { waylinePointsEvent, waylineDetails, kmlEntities, selectPointIndex, actionList } |
| | | export default useMapDraw |