| | |
| | | billboard?: billboardSetting |
| | | label?: labelSetting |
| | | id?: string |
| | | heading?: number |
| | | pitch?: number |
| | | roll?: number |
| | | } |
| | | // 定义全局的viewer变量防止重复生成 |
| | | // eslint-disable-next-line no-var |
| | |
| | | // 添加标记点 |
| | | const addPoint = (pointOption: pointOption) => { |
| | | if (!pointOption.longitude && !pointOption.latitude) return |
| | | const position = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude) |
| | | const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(pointOption.heading, pointOption.pitch, pointOption.roll)) |
| | | viewer?.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude), |
| | | billboard: pointOption.billboard, |
| | | point: pointOption.point, |
| | | label: pointOption.label, |
| | | id: pointOption.id, |
| | | orientation |
| | | }) |
| | | } |
| | | |
| | |
| | | viewer?.entities.remove(pointEntity) |
| | | } |
| | | } |
| | | |
| | | // 通过点ID获取实体 |
| | | function getEntityById (id:string) { |
| | | const pointEntity = viewer?.entities.getById(id) |
| | | return pointEntity |
| | | } |
| | | // 更新实体位置 |
| | | function updateEntityPosition (longitude:number, latitude:number, id:string, params?:any) { |
| | | const entity = getEntityById(id) as Cesium.Entity |
| | | const position = Cesium.Cartesian3.fromDegrees(longitude, latitude) |
| | | const heading = Cesium.Math.toRadians(params.heading) |
| | | const pitch = Cesium.Math.toRadians(params.pitch) |
| | | const roll = Cesium.Math.toRadians(params.roll) |
| | | const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(heading, pitch, roll)) |
| | | if (Cesium.defined(entity)) { |
| | | entity.position = position |
| | | entity.orientation = orientation |
| | | } |
| | | } |
| | | // 飞行 flyto |
| | | const flyTo = (pointOption: pointOption, time: number = 4) => { |
| | | if (!pointOption.longitude && !pointOption.latitude) return |
| | |
| | | zoonIn, |
| | | zoonOut, |
| | | roadPattern, |
| | | patternMap |
| | | patternMap, |
| | | getEntityById, |
| | | updateEntityPosition |
| | | } |
| | | } |
| | |
| | | <script lang="ts" setup> |
| | | import { computed, onMounted, reactive, ref, watch, WritableComputedRef } from 'vue' |
| | | import { EDeviceTypeName, ELocalStorageKey } from '/@/types' |
| | | import noData from '/@/assets/icons/no-data.png' |
| | | import rc from '/@/assets/icons/rc.png' |
| | | import { OnlineDevice, EModeCode, OSDVisible, EDockModeCode, DeviceOsd, EDockModeText, EModeText } from '/@/types/device' |
| | | import { useMyStore } from '/@/store' |
| | |
| | | } from '@ant-design/icons-vue' |
| | | import { EHmsLevel } from '/@/types/enums' |
| | | import { cesiumOperation } from '/@/hooks/use-cesium-tsa' |
| | | let droneEntity |
| | | |
| | | const { appContext } = getCurrentInstance() |
| | | const global = appContext.config.globalProperties |
| | |
| | | const cesium = cesiumOperation() |
| | | // 添加机场标注 |
| | | watch(() => store.state.deviceState, data => { |
| | | if (snCode.value.includes(data.currentSn)) return |
| | | snCode.value.push(data.currentSn) |
| | | // cesium.removeAllPoint() |
| | | if (data.currentType === EDeviceTypeName.Aircraft && data.deviceInfo[data.currentSn]) { |
| | | // 无人机图标 |
| | | const setting = { |
| | | longitude: data.deviceInfo[data.currentSn].longitude, |
| | | latitude: data.deviceInfo[data.currentSn].latitude, |
| | | billboard: { |
| | | image: getResource('drone.png'), |
| | | outlineWidth: 0, |
| | | width: 36, |
| | | height: 36, |
| | | scale: 1.0, |
| | | } |
| | | // cesium.removeById('drone_fly') |
| | | if (!droneEntity) { |
| | | droneEntity = cesium.getEntityById('drone_fly') |
| | | } |
| | | cesium.addPoint(setting) |
| | | console.log(data.deviceInfo[data.currentSn], '====deviceInfo====') |
| | | if (droneEntity) { |
| | | const orientation = { |
| | | heading: data.deviceInfo[data.currentSn].attitude_head, |
| | | pitch: data.deviceInfo[data.currentSn].attitude_pitch, |
| | | roll: data.deviceInfo[data.currentSn].attitude_roll |
| | | } |
| | | cesium.updateEntityPosition(data.deviceInfo[data.currentSn].longitude, data.deviceInfo[data.currentSn].latitude, 'drone_fly', orientation) |
| | | } else { |
| | | // 无人机图标 |
| | | const setting = { |
| | | longitude: data.deviceInfo[data.currentSn].longitude, |
| | | latitude: data.deviceInfo[data.currentSn].latitude, |
| | | id: 'drone_fly', |
| | | billboard: { |
| | | image: getResource('drone.png'), |
| | | outlineWidth: 0, |
| | | width: 36, |
| | | height: 36, |
| | | scale: 1.0, |
| | | }, |
| | | heading: data.deviceInfo[data.currentSn].attitude_head, |
| | | pitch: data.deviceInfo[data.currentSn].attitude_pitch, |
| | | roll: data.deviceInfo[data.currentSn].attitude_roll |
| | | } |
| | | cesium.addPoint(setting) |
| | | } |
| | | // if (osdVisible.value.visible && osdVisible.value.sn !== '') { |
| | | // deviceInfo.value.device = data.deviceInfo[osdVisible.value.sn] |
| | | // } |
| | | } |
| | | if (data.currentType === EDeviceTypeName.Dock && data.dockInfo[data.currentSn]) { |
| | | if (snCode.value.includes(data.currentSn)) return |
| | | snCode.value.push(data.currentSn) |
| | | // 机场图标位置 |
| | | const setting = { |
| | | longitude: data.dockInfo[data.currentSn].basic_osd?.longitude, |
| | |
| | | } |
| | | |
| | | export interface DeviceOsd { |
| | | attitude_head?:number, |
| | | attitude_pitch?:number, |
| | | attitude_roll?:number, |
| | | longitude: number, |
| | | latitude: number, |
| | | gear: number, |
| | |
| | | * @param creatPlan |
| | | */ |
| | | export function getFlyTimeList (creatPlan: CreatePlan) { |
| | | |
| | | const startDate = moment.unix(creatPlan.task_days[0]).toDate() |
| | | const endDate = moment.unix(creatPlan.task_days[1]).toDate() |
| | | |
| | |
| | | } else if (creatPlan.task_type === TaskType.Continuous) { |
| | | // 连续执行 |
| | | switch (creatPlan.rep_fre_type) { |
| | | // 月 |
| | | // 月 |
| | | case FrequencyType.month: { |
| | | // 先计算这几个月分别是哪个月 |
| | | const monthList = getYearMonth(startDate, endDate, creatPlan.rep_fre_val) |
| | |
| | | } |
| | | |
| | | creatPlan.task_periods?.forEach(timearr => { |
| | | |
| | | timearr.forEach(time=>{ |
| | | timearr.forEach(time => { |
| | | const timeStr = moment.unix(time).format('HH:mm') |
| | | const str = date + '-' + day + ' ' + timeStr |
| | | const tempDate = new Date(str) |
| | |
| | | const tmpDate = new Date(yearMonth) |
| | | const date = getMonthWeek(tmpDate.getFullYear(), tmpDate.getMonth(), creatPlan.rep_rule_val[0], creatPlan.rep_rule_val[1]) |
| | | creatPlan.task_periods?.forEach(timearr => { |
| | | |
| | | timearr.forEach(time=>{ |
| | | timearr.forEach(time => { |
| | | const timeStr = moment.unix(time).format('HH:mm') |
| | | const dateStr = date + ' ' + timeStr |
| | | finalDateTimeArr.push(dateStr) |
| | |
| | | |
| | | break |
| | | } |
| | | // 周 |
| | | // 周 |
| | | case FrequencyType.week: { |
| | | // 获取每n周的日期 |
| | | const weekDate = gainAllDateBetRange(startDate, endDate, creatPlan.rep_fre_val * 7) |
| | |
| | | // 拼接时间 |
| | | dateList.forEach(date => { |
| | | creatPlan.task_periods?.forEach(timearr => { |
| | | |
| | | timearr.forEach(time=>{ |
| | | timearr.forEach(time => { |
| | | const timeStr = moment.unix(time).format('HH:mm') |
| | | finalDateTimeArr.push(date + ' ' + timeStr) |
| | | }) |
| | | |
| | | }) |
| | | }) |
| | | break |
| | | } |
| | | // 日 |
| | | // 日 |
| | | case FrequencyType.day: { |
| | | // 根据每几天获取时间 |
| | | const dateList = gainAllDateBetRange(startDate, endDate, creatPlan.rep_fre_val) |
| | | // 拼接执行时间即可 |
| | | dateList.forEach(date => { |
| | | creatPlan.task_periods?.forEach(timearr => { |
| | | timearr.forEach(time=>{ |
| | | timearr.forEach(time => { |
| | | const timeStr = moment.unix(time).format('HH:mm') |
| | | |
| | | finalDateTimeArr.push(date + ' ' + timeStr) |
| | | }) |
| | | |
| | | }) |
| | | }) |
| | | break |
| | |
| | | } |
| | | |
| | | console.log('最终时间:', finalDateTimeArr) |
| | | var tempDateTimeArr = [] |
| | | let tempDateTimeArr = [] |
| | | if (creatPlan.task_type === TaskType.Repeat) { |
| | | tempDateTimeArr = finalDateTimeArr.map(dateTime=>[dateTime]) |
| | | }else if (creatPlan.task_type === TaskType.Continuous){ |
| | | for (let i = 0; i < finalDateTimeArr.length; i=i+2) { |
| | | tempDateTimeArr.push([finalDateTimeArr[i],finalDateTimeArr[i+1]]) |
| | | tempDateTimeArr = finalDateTimeArr.map(dateTime => [dateTime]) |
| | | } else if (creatPlan.task_type === TaskType.Continuous) { |
| | | for (let i = 0; i < finalDateTimeArr.length; i = i + 2) { |
| | | tempDateTimeArr.push([finalDateTimeArr[i], finalDateTimeArr[i + 1]]) |
| | | } |
| | | } |
| | | |
| | | |
| | | // 对tempDateTimeArr进行时间过滤,筛选掉过去时间和无效时间 |
| | | const futureDateTimeArr = tempDateTimeArr.filter(dateArr => { |
| | |
| | | console.log('未来时间:', futureDateTimeArr) |
| | | |
| | | const futureDateTimeUnixArr = [] as any |
| | | futureDateTimeArr.forEach(dateArr=>{ |
| | | futureDateTimeArr.forEach(dateArr => { |
| | | const list = [] as any |
| | | |
| | | dateArr.forEach(dateTimeStr=>{ |
| | | const timestamp = moment(dateTimeStr).unix() |
| | | dateArr.forEach(dateTimeStr => { |
| | | const timestamp = moment(dateTimeStr).unix() |
| | | list.push(timestamp) |
| | | }) |
| | | futureDateTimeUnixArr.push(list) |