From c0327c583bedec8e9421e2cba9b0447c0e06a494 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 13 Nov 2023 10:16:18 +0800
Subject: [PATCH] 图斑加载
---
src/components/g-map/DroneControlPanel.vue | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/src/components/g-map/DroneControlPanel.vue b/src/components/g-map/DroneControlPanel.vue
index bf5c592..549ed53 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,6 +317,8 @@
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'
const props = defineProps<{
sn: string,
@@ -482,6 +488,37 @@
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 jsonData = await parseJsonFile('../src/assets/jsonData/图斑_FeaturesToJSON(1).json')
+ const sn = props.sn
+ 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, list, radius).then(res => {
+ console.log(res, '----------------')
+ })
+}
+
// 进入飞行控制
async function enterFlightControl () {
if (!clientId.value) {
--
Gitblit v1.9.3