From 16fcff23e254e02bd0b09624e8dc44b6097dc6f9 Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Thu, 16 Nov 2023 10:23:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/demo' into demo

---
 src/components/g-map/DroneControlPanel.vue |   86 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/src/components/g-map/DroneControlPanel.vue b/src/components/g-map/DroneControlPanel.vue
index 24731e6..51159b7 100644
--- a/src/components/g-map/DroneControlPanel.vue
+++ b/src/components/g-map/DroneControlPanel.vue
@@ -13,6 +13,10 @@
                         <Button :ghost="!flightController" size="small" @click="onClickFightControl">
                             {{ flightController ? '退出控制' : '进入控制' }}
                         </Button>
+
+                      <Button  size="small" @click="flyByPoints">
+                        图斑飞行
+                      </Button>
                     </div>
                 </div>
                 <div class="row">
@@ -313,13 +317,18 @@
 import DroneControlInfoPanel from './DroneControlInfoPanel.vue'
 import { noDebugCmdList as baseCmdList, DeviceCmdItem, DeviceCmd } from '/@/types/device-cmd'
 import { useDockControl } from './use-dock-control'
-
+import { flyByArea, Point } from '/@/api/wayline'
+import { parseJsonFile } from '/@/utils/geo-utils'
+import { cesiumOperation } from '/@/hooks/use-cesium-tsa'
+import * as Cesium from 'cesium'
 const props = defineProps<{
     sn: string,
     deviceInfo: DeviceInfoType,
     payloads: null | PayloadInfo[],
     modelValue: Boolean,
 }>()
+
+const cesiumFunc = cesiumOperation()
 
 const store = useMyStore()
 const clientId = computed(() => {
@@ -340,11 +349,19 @@
     cmd: cmdItem.cmdKey,
     action: cmdItem.action
   }, false)
-  if (result && flightController.value) {
+  // if (result && flightController.value) {
+  //   message.success('返航成功')
+  //   exitFlightCOntrol()
+  // } else {
+  //   message.warn('请先进入控制!')
+  // }
+  // cmdItem.loading = false
+  if (result) {
     message.success('返航成功')
+  }
+  // 退出飞行控制
+  if (result && flightController.value) {
     exitFlightCOntrol()
-  } else {
-    message.warn('请先进入控制!')
   }
   cmdItem.loading = false
 }
@@ -474,6 +491,67 @@
   enterFlightControl()
 }
 
+// 根据图斑飞行
+async function flyByPoints () {
+  // 半径m
+  const radius = 7000
+  const dockPoint:Point = reactive({
+    lon: props.deviceInfo.dock.basic_osd.longitude,
+    lat: props.deviceInfo.dock.basic_osd.latitude
+  })
+  const deviceSn = props.deviceInfo.dock.basic_osd.sub_device?.device_sn
+  const jsonPath = 'src/main/resources/jkj(1).json'
+  const sn = props.sn
+
+  console.log(payloadSelectInfo, '-------------')
+  const payloadIndex = payloadSelectInfo.payloadIndex
+  // const jsonData = await parseJsonFile('../src/assets/jsonData/jkj(1).json')
+
+  // const features = jsonData.features
+  // const list = []
+
+  // features.forEach(feature => {
+  //   const areaList = []
+  //   feature.geometry.coordinates[0].forEach(areaPoint => {
+  //     console.log('areaPoint:', areaPoint)
+  //     const point = {
+  //       lon: areaPoint[0],
+  //       lat: areaPoint[1]
+  //     }
+  //     areaList.push(point)
+  //   })
+  //   list.push(areaList)
+  // })
+
+  flyByArea(sn, dockPoint, jsonPath, radius, deviceSn, payloadIndex).then(res => {
+    const targetPoint = res.data
+    // 获取到点之后在图上绘点
+    targetPoint.forEach((point, index) => {
+      const setting = {
+        longitude: point.lon,
+        latitude: point.lat,
+        point: {
+          pixelSize: 8,
+          outlineWidth: 2,
+          color: Cesium.Color.RED,
+          outlineColor: Cesium.Color.BLACK,
+        },
+        label: {
+          text: '位置' + (index + 1),
+          outlineWidth: 20,
+          font: '14px sans-serif',
+          heightReference: 80,
+          pixelOffset: new Cesium.Cartesian2(0, -35),
+          fillColor: Cesium.Color.BLACK
+        },
+        id: 'target' + index,
+      }
+
+      cesiumFunc.addPoint(setting)
+    })
+  })
+}
+
 // 进入飞行控制
 async function enterFlightControl () {
   if (!clientId.value) {

--
Gitblit v1.9.3