From 7abab3d5474858f58ddd96bebbdf0379ddd1aa77 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Tue, 17 Oct 2023 15:17:00 +0800
Subject: [PATCH] 飞机起飞时实时位置更新

---
 src/pages/page-web/projects/tsa.vue |   48 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/src/pages/page-web/projects/tsa.vue b/src/pages/page-web/projects/tsa.vue
index c5cba3e..ec804aa 100644
--- a/src/pages/page-web/projects/tsa.vue
+++ b/src/pages/page-web/projects/tsa.vue
@@ -266,7 +266,6 @@
 <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'
@@ -280,6 +279,7 @@
 } 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
@@ -326,28 +326,46 @@
 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,

--
Gitblit v1.9.3