guoshilong
2023-11-14 6d3a25365554f9c7c98b8a58fba7b7aa9b3f9e9f
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,
@@ -340,11 +346,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 +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) {