罗广辉
2025-06-19 f27ca082eb0a839449dd50c49007b58e5ed6946f
src/components/g-map/DroneControlPanel.vue
@@ -14,56 +14,56 @@
                            {{ flightController ? '退出控制' : '进入控制' }}
                        </Button>
                      <Button  size="small" @click="flyByPoints">
                        图斑飞行
                      </Button>
<!--                      <Button  size="small" @click="flyByPoints">-->
<!--                        图斑飞行-->
<!--                      </Button>-->
                    </div>
                </div>
                <div class="row">
                    <div class="drone-control-direction">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_Q)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_Q)" @mouseup="onMouseUp">
                            <template #icon>
                                <UndoOutlined/>
                            </template>
                            <span class="word">Q</span>
                        </Button>
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_W)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_W)" @mouseup="onMouseUp">
                            <template #icon>
                                <UpOutlined/>
                            </template>
                            <span class="word">W</span>
                        </Button>
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_E)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_E)" @mouseup="onMouseUp">
                            <template #icon>
                                <RedoOutlined/>
                            </template>
                            <span class="word">E</span>
                        </Button>
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.ARROW_UP)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.ARROW_UP)" @mouseup="onMouseUp">
                            <template #icon>
                                <ArrowUpOutlined/>
                            </template>
                        </Button>
                        <br/>
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_A)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_A)" @mouseup="onMouseUp">
                            <template #icon>
                                <LeftOutlined/>
                            </template>
                            <span class="word">A</span>
                        </Button>
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_S)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_S)" @mouseup="onMouseUp">
                            <template #icon>
                                <DownOutlined/>
                            </template>
                            <span class="word">S</span>
                        </Button>
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_D)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.KEY_D)" @mouseup="onMouseUp">
                            <template #icon>
                                <RightOutlined/>
                            </template>
                            <span class="word">D</span>
                        </Button>
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.ARROW_DOWN)" @onmouseup="onMouseUp">
                        <Button size="small" ghost @mousedown="onMouseDown(KeyCode.ARROW_DOWN)" @mouseup="onMouseUp">
                            <template #icon>
                                <ArrowDownOutlined/>
                            </template>
@@ -133,6 +133,34 @@
                                <div>
                                    <span class="form-label">返回原点高度(m):</span>
                                    <a-input-number v-model:value="takeoffToPointPopoverData.rthAltitude"/>
                                </div>
                                <div>
                                    <span class="form-label">指点飞行高度(m):</span>
                                    <a-input-number :min="2" :max="8000" v-model:value="takeoffToPointPopoverData.commanderFlightHeight"/>
                                </div>
                                <div>
                                  <span class="form-label">返航模式:</span>
                                  <a-select
                                    v-model:value="takeoffToPointPopoverData.rthMode"
                                    style="width: 120px"
                                    :options="RthModeOptions"
                                  ></a-select>
                                </div>
                                <div>
                                  <span class="form-label">指点飞行模式:</span>
                                  <a-select
                                    v-model:value="takeoffToPointPopoverData.commanderFlightMode"
                                    style="width: 120px"
                                    :options="CommanderFlightModeOptions"
                                  ></a-select>
                                </div>
                                <div>
                                  <span class="form-label">指点飞行失控动作:</span>
                                  <a-select
                                    v-model:value="takeoffToPointPopoverData.commanderModeLostAction"
                                    style="width: 120px"
                                    :options="CommanderModeLostActionOptions"
                                  ></a-select>
                                </div>
                                <div>
                                    <span class="form-label">失控操作:</span>
@@ -308,6 +336,9 @@
} from '/@/api/drone-control/drone'
import { useDroneControl } from './use-drone-control'
import {
  RthModeOptions,
  CommanderModeLostActionOptions,
  CommanderFlightModeOptions,
  GimbalResetMode,
  GimbalResetModeOptions,
  LostControlActionInCommandFLightOptions,
@@ -319,13 +350,17 @@
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'
import { start } from 'repl'
const props = defineProps<{
    sn: string,
    deviceInfo: DeviceInfoType,
    payloads: null | PayloadInfo[],
    modelValue: Boolean,
}>()
const cesiumFunc = cesiumOperation()
const store = useMyStore()
const clientId = computed(() => {
@@ -425,7 +460,11 @@
  maxSpeed: MAX_SPEED,
  rthAltitude: 100 as null | number,
  rcLostAction: LostControlActionInCommandFLight.RETURN_HOME,
  exitWaylineWhenRcLost: WaylineLostControlActionInCommandFlight.EXEC_LOST_ACTION
  exitWaylineWhenRcLost: WaylineLostControlActionInCommandFlight.EXEC_LOST_ACTION,
  rthMode: 0 as number,
  commanderModeLostAction: 1 as number,
  commanderFlightMode: 0 as number,
  commanderFlightHeight: 100 as number
})
function onShowTakeoffToPointPopover () {
@@ -458,7 +497,11 @@
        rth_altitude: takeoffToPointPopoverData.rthAltitude,
        max_speed: takeoffToPointPopoverData.maxSpeed,
        rc_lost_action: takeoffToPointPopoverData.rcLostAction,
        exit_wayline_when_rc_lost: takeoffToPointPopoverData.exitWaylineWhenRcLost
        exit_wayline_when_rc_lost: takeoffToPointPopoverData.exitWaylineWhenRcLost,
        rth_mode: takeoffToPointPopoverData.rthMode,
        commander_mode_lost_action: takeoffToPointPopoverData.commanderModeLostAction,
        commander_flight_mode: takeoffToPointPopoverData.commanderFlightMode,
        commander_flight_height: takeoffToPointPopoverData.commanderFlightHeight
      })
    } catch (error) {
    }
@@ -497,26 +540,104 @@
    lat: props.deviceInfo.dock.basic_osd.latitude
  })
  const deviceSn = props.deviceInfo.dock.basic_osd.sub_device?.device_sn
  const jsonData = await parseJsonFile('../src/assets/jsonData/图斑_FeaturesToJSON(1).json')
  const jsonPath = 'src/main/resources/jkj(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]
  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 || []
    // 机场位置
    const startPoint = {
      lon: props.deviceInfo.dock.basic_osd.longitude,
      lat: props.deviceInfo.dock.basic_osd.latitude
    }
    targetPoint.unshift(startPoint)
    console.log('targetPoint====', targetPoint)
    // 获取到点之后在图上绘点
    targetPoint.forEach((point: { lon: number; lat: number }, index: number) => {
      console.log(point)
      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,
      }
      areaList.push(point)
      cesiumFunc.addPoint(setting)
      // 根据点画连线
      let polylineSetting = {}
      if (index === (targetPoint.length - 1)) {
        polylineSetting = {
          polyline: {
            positions: Cesium.Cartesian3.fromDegreesArrayHeights([
              point.lon,
              point.lat,
              0,
              targetPoint[0].lon,
              targetPoint[0].lat,
              0
            ]),
            width: 10,
            arcType: Cesium.ArcType.NONE,
            material: new Cesium.PolylineArrowMaterialProperty(
              Cesium.Color.RED
            ),
          },
          id: 'fxTarget' + index
        }
      } else {
        polylineSetting = {
          polyline: {
            positions: Cesium.Cartesian3.fromDegreesArrayHeights([
              point.lon,
              point.lat,
              0,
              targetPoint[index + 1].lon,
              targetPoint[index + 1].lat,
              0
            ]),
            width: 10,
            arcType: Cesium.ArcType.NONE,
            material: new Cesium.PolylineArrowMaterialProperty(
              Cesium.Color.RED
            ),
          },
          id: 'fxTarget' + index
        }
      }
      cesiumFunc.addPolyline(polylineSetting)
    })
    list.push(areaList)
  })
  flyByArea(sn, dockPoint, list, radius, deviceSn).then(res => {
    console.log(res, '----------------')
  })
}