| | |
| | | <ArrowLeftOutlined /> |
| | | <span>返回上一页</span> |
| | | </div> |
| | | <li |
| | | v-for="(position, index) in tragetPointArr" |
| | | :key="index" |
| | | :class="{ selectedColor : index === selectedPoint }" |
| | | @click="tragetPointClick(position, index)"> |
| | | <li v-for="(item, index) in tragetPointArr" :key="index" :class="{ selectedColor: index === selectedPoint }" |
| | | @click="tragetPointClick(item.position, index)"> |
| | | <div class="graph"> |
| | | <div class="left" :style="{borderTopColor: index === selectedPoint ? '#FF9900' : '#2D8CF0'}"></div> |
| | | <div class="left" :style="{ borderTopColor: index === selectedPoint ? '#FF9900' : '#2D8CF0' }"></div> |
| | | <div class="right">{{ index + 1 }}</div> |
| | | </div> |
| | | <div class="graph-right"></div> |
| | | <div class="graph-right"> |
| | | <div v-for="(event, index) in item.eventList" :key="index" class="s-event-icon"> |
| | | <a-tooltip placement="top"> |
| | | <template #title> |
| | | {{ event.name }} |
| | | </template> |
| | | <img :src="event.icon" alt="icon" /> |
| | | </a-tooltip> |
| | | </div> |
| | | </div> |
| | | </li> |
| | | </ul> |
| | | </a-spin> |
| | |
| | | import { getRoot } from '/@/root' |
| | | import * as Cesium from 'cesium' |
| | | import { cesiumOperation } from '/@/hooks/use-cesium-tsa' |
| | | import { stat } from 'fs' |
| | | import axios from 'axios' |
| | | import JSZIP from 'jszip' |
| | | // 初始化jszip |
| | | const JsZip = new JSZIP() |
| | | |
| | | const getResource = (name: string) => { |
| | | return new URL(`/src/assets/icons/${name}`, import.meta.url).href |
| | | } |
| | | |
| | | const projectWayLine = ref<HTMLDivElement>() |
| | | |
| | |
| | | const { removeById, addClickEvent, getEntityById } = cesiumOperation() |
| | | |
| | | const isPointListOpen = ref<boolean>(false) |
| | | const tragetPointArr = ref<Cesium.Cartesian3[]>([]) |
| | | const tragetPointArr = ref<{ |
| | | position: Cesium.Cartesian3, |
| | | eventList: any[] |
| | | }[]>([]) |
| | | const selectedPoint = ref<number | null>(null) |
| | | |
| | | // 对应事件 |
| | | const eventList = reactive<{ |
| | | key: string, |
| | | name: string, |
| | | distinguish?: string, |
| | | icon?: string |
| | | }[]>([ |
| | | { |
| | | key: 'takePhoto', |
| | | name: '单拍', |
| | | icon: getResource('waylinetool/camera.png'), |
| | | }, |
| | | { |
| | | key: 'startRecord', |
| | | name: '开始录像', |
| | | icon: getResource('waylinetool/camera-on.png'), |
| | | }, |
| | | { |
| | | key: 'stopRecord', |
| | | name: '结束录像', |
| | | icon: getResource('waylinetool/camera-off.png'), |
| | | }, |
| | | { |
| | | key: 'time', |
| | | name: '开始等时间隔拍照', |
| | | icon: getResource('waylinetool/shoot1.png'), |
| | | }, |
| | | { |
| | | key: 'distance', |
| | | name: '开始等距间隔拍照', |
| | | icon: getResource('waylinetool/shoot2.png'), |
| | | }, |
| | | { |
| | | key: 'zoom', |
| | | name: '变焦', |
| | | icon: getResource('waylinetool/fd.png'), |
| | | }, |
| | | { |
| | | key: 'customDirName', |
| | | name: '创建新文件夹', |
| | | icon: getResource('waylinetool/create-file.png'), |
| | | }, |
| | | { |
| | | key: 'gimbalRotate', |
| | | distinguish: 'Yaw', |
| | | name: '云台俯仰角', |
| | | icon: getResource('waylinetool/holderyaw.png'), |
| | | }, |
| | | { |
| | | key: 'gimbalYawRotate', |
| | | name: '云台偏航角', |
| | | distinguish: 'pitch', |
| | | icon: getResource('waylinetool/holdertilt.png'), |
| | | }, |
| | | { |
| | | key: 'rotateYaw', |
| | | name: '飞行器偏航', |
| | | icon: getResource('waylinetool/droneyaw.png'), |
| | | }, |
| | | { |
| | | key: 'hover', |
| | | name: '悬停等待', |
| | | icon: getResource('waylinetool/xt.png'), |
| | | } |
| | | ]) |
| | | |
| | | onMounted(() => { |
| | | const parent = document.getElementsByClassName('scrollbar').item(0)?.parentNode as HTMLDivElement |
| | |
| | | }, 1000) |
| | | console.log(workspaceId.value) |
| | | }) |
| | | |
| | | onUnmounted(() => { |
| | | if (kmlDataSource) { |
| | | global.$viewer.dataSources.remove(kmlDataSource) |
| | |
| | | removeById('clickBox') |
| | | store.commit('SET_WAYLINE_INFO', { |
| | | isShow: false, |
| | | wayline: {} |
| | | wayline: {}, |
| | | position: null, |
| | | }) |
| | | }) |
| | | |
| | |
| | | getWayLineFile(workspaceId.value, wayline.id).then(res => { |
| | | store.commit('SET_SELECT_WAYLINE_INFO', wayline) |
| | | initKmlFile(res.data) |
| | | store.commit('SET_WAYLINE_KMZPATH', res.data) |
| | | }).finally(() => { |
| | | loading.value = false |
| | | }) |
| | | // 清除选中点柱形和隐藏按钮 |
| | | store.commit('SET_WAYLINE_INFO', { |
| | | isShow: false, |
| | | wayline: {} |
| | | wayline: {}, |
| | | position: null |
| | | }) |
| | | removeById('clickBox') |
| | | isPointListOpen.value = !isPointListOpen.value |
| | |
| | | * @param file |
| | | */ |
| | | function initKmlFile (file: string) { |
| | | const [, address] = file.split('cloud-bucket') |
| | | file = import.meta.env.VITE_MEDIAPANEL_API_URL + address |
| | | removeById('kmzLine') |
| | | const options = { |
| | | camera: global.$viewer.scene.camera, |
| | |
| | | outlineColor: Cesium.Color.BLACK, |
| | | }) |
| | | cartesianArr.push(entity.position._value) |
| | | tragetPointArr.value[i] = { |
| | | position: entity.position._value, |
| | | eventList: [] |
| | | } |
| | | } |
| | | tragetPointArr.value = cartesianArr |
| | | const stripe = createStripe() |
| | | // tragetPointArr.value = cartesianArr |
| | | // const stripe = createStripe() |
| | | const lineEntity = global.$viewer.entities.add({ |
| | | name: 'entityLine', |
| | | id: 'kmzLine', |
| | |
| | | global.$viewer.flyTo(lineEntity, { |
| | | offset: new Cesium.HeadingPitchRange(0, -90, 8000) |
| | | }) |
| | | |
| | | // 解析kmz文件 |
| | | readKmzFile(file) |
| | | }) |
| | | } |
| | | |
| | | // 点击目标点 |
| | | function tragetPointClick (position: Cesium.Cartesian3, index: number) { |
| | | selectedPoint.value = index |
| | | store.commit('SET_WAYLINE_INFO', { |
| | | isShow: true, |
| | | wayline: currentWayLine |
| | | wayline: currentWayLine, |
| | | position: index |
| | | }) |
| | | if (getEntityById('clickBox')) { |
| | | removeById('clickBox') |
| | |
| | | heightReference: true |
| | | } |
| | | } |
| | | |
| | | const boxEntity = global.$viewer.entities.add(entity) |
| | | global.$viewer.flyTo(boxEntity, { |
| | | duration: 3, |
| | |
| | | return stripe |
| | | } |
| | | |
| | | /** |
| | | * @description: 获取kmz文件中的内容 |
| | | * @param {*} kmzPath kmz文件地址 |
| | | * @return {*} void |
| | | */ |
| | | const readKmzFile = (kmzPath: string) => { |
| | | // 使用axios读取文件 |
| | | return axios.get(kmzPath, { responseType: 'arraybuffer' }) |
| | | .then(fileRes => fileRes.data) |
| | | .then(kmzData => JsZip.loadAsync(kmzData)) // 解压kmz文件 |
| | | .then(kmzZip => { |
| | | // 通过文件名找到 KML 文件 |
| | | const kmlFile = kmzZip.file(/\.kml$/i)[0] |
| | | return kmlFile.async('text') |
| | | }).then(kml => { |
| | | // 查找航点标签reg |
| | | const regx = /<Placemark>([\s\S]*?)<\/Placemark>/g |
| | | // 查找事件组reg |
| | | const actionGroupReg = /<wpml:actionGroup>([\s\S]*?)<\/wpml:actionGroup>/g |
| | | // 查找单个事件reg |
| | | const actionRegx = /<wpml:action>([\s\S]*?)<\/wpml:action>/g |
| | | // 获取shootType |
| | | const shootTypeRegx = /<wpml:shootType>([\s\S]*?)<\/wpml:shootType>/g |
| | | // 云台角度 |
| | | const gimbalPitchRotateAngleRegx = /<wpml:gimbalPitchRotateAngle>(.*?)<\/wpml:gimbalPitchRotateAngle>/ |
| | | const gimbalYawRotateAngleRegx = /<wpml:gimbalYawRotateAngle>(.*?)<\/wpml:gimbalYawRotateAngle>/ |
| | | // 当前kmz文件航点 |
| | | const kmlPoints = kml.match(regx) |
| | | kmlPoints?.forEach((point: string, index: number) => { |
| | | // 当前点的事件组 |
| | | const ponitAction = point.match(actionGroupReg) |
| | | const eventArr: string[] = [] |
| | | if (ponitAction) { |
| | | // 当前事件 |
| | | const actions = ponitAction[0].match(actionRegx) |
| | | actions?.forEach(action => { |
| | | eventList.forEach((item: any) => { |
| | | if (!item.distinguish) { |
| | | action.includes(item.key) && eventArr.push(item) |
| | | } else { |
| | | const pitchAngle = action?.match(gimbalPitchRotateAngleRegx) || [] |
| | | const yawAngle = action?.match(gimbalYawRotateAngleRegx) || [] |
| | | if (!!Number(pitchAngle[1]) && item.distinguish === 'pitch') { |
| | | eventArr.push(item) |
| | | } |
| | | if (!!Number(yawAngle[1]) && item.distinguish === 'yaw') { |
| | | eventArr.push(item) |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | tragetPointArr.value[index].eventList = eventArr |
| | | } |
| | | // 获取当前是否存在拍照模式 |
| | | const pointShootTypeKML = point.match(shootTypeRegx) |
| | | if (pointShootTypeKML) { |
| | | pointShootTypeKML.forEach((type: string) => { |
| | | eventList.forEach((item: any) => { |
| | | type.includes(item.key) && eventArr.push(item) |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | const openEditModal = (wayline: any) => { |
| | | currentWayLine.value = wayline |
| | | editVisible.value = true |
| | |
| | | padding: 0; |
| | | margin: 0; |
| | | list-style-type: none; |
| | | |
| | | .back-btn { |
| | | cursor: pointer; |
| | | padding: 10px; |
| | | border-bottom: 1px solid #4f4f4f; |
| | | |
| | | span { |
| | | margin-left: 10px; |
| | | } |
| | | |
| | | &:hover { |
| | | color: #2d8cf0; |
| | | } |
| | | } |
| | | |
| | | li { |
| | | cursor: pointer; |
| | | padding: 10px 0; |
| | | margin: 0 7px; |
| | | display: flex; |
| | | |
| | | .graph { |
| | | width: 40px; |
| | | display: flex; |
| | | align-items: center; |
| | | |
| | | .left { |
| | | width: 0; |
| | | height: 0; |
| | |
| | | border-right: 10px solid transparent; |
| | | border-left: 10px solid transparent; |
| | | } |
| | | |
| | | .right { |
| | | margin-left: 3px; |
| | | } |
| | | } |
| | | |
| | | .graph-right { |
| | | width: calc(100% - 40px); |
| | | height: 30px; |
| | | border-bottom: 1px solid #4f4f4f; |
| | | display: flex; |
| | | align-items: center; |
| | | |
| | | .s-event-icon { |
| | | width: 25px; |
| | | height: 25px; |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | |
| | | img { |
| | | width: 70%; |
| | | } |
| | | } |
| | | } |
| | | |
| | | &:hover { |
| | | background-color: #3C3C3C; |
| | | } |
| | |
| | | |
| | | .selectedColor { |
| | | background-color: #3C3C3C; |
| | | } |
| | | </style> |
| | | }</style> |