吉安感知网项目-前端
shuishen
2026-02-05 48d9fca88c60c17d9a591b311a0bd5dc61d1462d
feat:多边形绘制优化,移动端webview存储优化
2 files modified
51 ■■■■■ changed files
applications/drone-command/src/utils/cesium/shapeTools/edit/EditPolygonTool.js 49 ●●●●● patch | view | raw | blame | history
applications/mobile-web-view/src/config/website.js 2 ●●● patch | view | raw | blame | history
applications/drone-command/src/utils/cesium/shapeTools/edit/EditPolygonTool.js
@@ -3,6 +3,7 @@
import { ToolBase } from '../ToolBase'
const POINT_ENTITY_NAME = 'edit-polygon-point'
const MIDPOINT_ENTITY_NAME = 'edit-polygon-midpoint'
const DEFAULT_STYLE = {
    fill: Cesium.Color.fromBytes(45, 140, 240, 99),
    outline: Cesium.Color.fromBytes(45, 140, 240, 255),
@@ -57,7 +58,20 @@
    handleLeftDown(click) {
        const pickedEntity = this.viewer.scene.pick(click.position)?.id
        if (!pickedEntity || pickedEntity.name !== POINT_ENTITY_NAME) return
        if (!pickedEntity) return
        if (pickedEntity.name === MIDPOINT_ENTITY_NAME) {
            const leftIndex = pickedEntity.customData?.leftIndex
            const rightIndex = pickedEntity.customData?.rightIndex
            if (typeof leftIndex !== 'number' || typeof rightIndex !== 'number') return
            const midpoint = this.getMidpointPosition(leftIndex, rightIndex)
            this.positions.splice(rightIndex, 0, midpoint)
            this.rebuildPointEntities()
            this.isDragging = true
            this.draggedIndex = rightIndex
            this.disableMapControl()
            return
        }
        if (pickedEntity.name !== POINT_ENTITY_NAME) return
        const index = pickedEntity.customData?.index
        if (typeof index !== 'number') return
        this.isDragging = true
@@ -131,7 +145,7 @@
    rebuildPointEntities() {
        this.dataSource.entities.values
            .slice()
            .filter(entity => entity?.name === POINT_ENTITY_NAME)
            .filter(entity => entity?.name === POINT_ENTITY_NAME || entity?.name === MIDPOINT_ENTITY_NAME)
            .forEach(entity => this.dataSource.entities.remove(entity))
        this.positions.forEach((position, index) => {
@@ -151,6 +165,30 @@
                },
            })
        })
        const count = this.positions.length
        if (count < 2) return
        const segmentCount = count === 2 ? 1 : count
        for (let i = 0; i < segmentCount; i += 1) {
            const leftIndex = i
            const rightIndex = i + 1 < count ? i + 1 : 0
            this.dataSource.entities.add({
                name: MIDPOINT_ENTITY_NAME,
                position: new Cesium.CallbackProperty(() => this.getMidpointPosition(leftIndex, rightIndex), false),
                point: {
                    pixelSize: 8,
                    color: Cesium.Color.WHITE.withAlpha(0.6),
                    outlineColor: this.style.outline.withAlpha(0.6),
                    outlineWidth: 2,
                    heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                },
                customData: {
                    leftIndex,
                    rightIndex,
                },
            })
        }
    }
    getPositions() {
@@ -164,6 +202,13 @@
        return scene.camera.pickEllipsoid(screenPosition, scene.globe.ellipsoid)
    }
    getMidpointPosition(leftIndex, rightIndex) {
        const left = this.positions[leftIndex]
        const right = this.positions[rightIndex]
        if (!left || !right) return left || right
        return Cesium.Cartesian3.midpoint(left, right, new Cesium.Cartesian3())
    }
    setStyle(style) {
        this.style = resolveStyle(style)
        if (this.polygonEntity?.polygon) {
applications/mobile-web-view/src/config/website.js
@@ -4,7 +4,7 @@
export default {
    title: '',
    logo: 'S',
    key: 'saber', //配置主键,目前用于存储
    key: 'mobile', //配置主键,目前用于存储
    indexTitle: 'BladeX 微服务平台',
    clientId: 'drone', // 客户端id
    clientSecret: 'drone_secret', // 客户端密钥