吉安感知网项目-前端
shuishen
2026-02-02 2d40c08a9358a1fc1183a45fa806d5e433822e21
applications/drone-command/src/utils/cesium/shapeTools/draw/DrawBufferCircleTool.js
@@ -1,7 +1,12 @@
import * as Cesium from 'cesium'
import { MapTooltip } from '@ztzf/utils'
import { ToolBase } from '../ToolBase'
import { buildEllipsePositions } from '../shapeUtils'
import {
   buildEllipsePositions,
   formatBufferRadius,
   getBufferRadiusLabelStyle,
   getBufferRadiusPoint,
} from '../shapeUtils'
export class DrawBufferCircleTool extends ToolBase {
   constructor(viewer) {
@@ -21,6 +26,9 @@
      this.radiusPoint1 = null
      this.radiusPoint2 = null
      this.radiusPoint3 = null
      this.radiusLevel1LabelEntity = null
      this.radiusLevel2LabelEntity = null
      this.radiusLevel3LabelEntity = null
      this.isDrawing = false
      this.drawStep = 0
      this.isCompleted = false
@@ -193,6 +201,10 @@
            material: Cesium.Color.fromBytes(0, 251, 255, 255),
         },
      })
      this.radiusLevel1LabelEntity = this.createRadiusLabelEntity(() => this.radiusLevel1)
      this.radiusLevel2LabelEntity = this.createRadiusLabelEntity(() => this.radiusLevel2)
      this.radiusLevel3LabelEntity = this.createRadiusLabelEntity(() => this.radiusLevel3)
   }
   clearPreviewEntities() {
@@ -204,6 +216,9 @@
      this.circleLevel1OutlineEntity = null
      this.circleLevel2OutlineEntity = null
      this.circleLevel3OutlineEntity = null
      this.radiusLevel1LabelEntity = null
      this.radiusLevel2LabelEntity = null
      this.radiusLevel3LabelEntity = null
   }
   getSurfaceDistance(startCartesian, endCartesian) {
@@ -218,6 +233,23 @@
      const cartesian = scene.pickPosition(screenPosition)
      if (cartesian) return cartesian
      return scene.camera.pickEllipsoid(screenPosition, scene.globe.ellipsoid)
   }
   getRadiusPoint(radius) {
      return getBufferRadiusPoint(this.centerCartesian, radius)
   }
   createRadiusLabelEntity(getRadius) {
      return this.dataSource.entities.add({
         position: new Cesium.CallbackProperty(
            () => getBufferRadiusPoint(this.centerCartesian, getRadius()),
            false
         ),
         label: {
            ...getBufferRadiusLabelStyle(),
            text: new Cesium.CallbackProperty(() => formatBufferRadius(getRadius()), false),
         },
      })
   }
   destroy() {
@@ -241,6 +273,9 @@
      this.radiusPoint1 = null
      this.radiusPoint2 = null
      this.radiusPoint3 = null
      this.radiusLevel1LabelEntity = null
      this.radiusLevel2LabelEntity = null
      this.radiusLevel3LabelEntity = null
      this.isDrawing = false
      this.drawStep = 0
      this.isCompleted = false