From 48351c3ce0d4a370396562403a44fe7deb7c795c Mon Sep 17 00:00:00 2001 From: sd <1504629600@qq.com> Date: Fri, 6 Feb 2026 15:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=A9=BA=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E6=B5=8B=E8=B7=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/cesiumMap/HoverTooltip.vue | 1 - ruoyi-ui/src/views/cesiumMap/MeasurementPanel.vue | 2 +- ruoyi-ui/src/views/cesiumMap/index.vue | 164 +++++++++++++++------- ruoyi-ui/src/views/childRoom/RightPanel.vue | 7 - 4 files changed, 113 insertions(+), 61 deletions(-) diff --git a/ruoyi-ui/src/views/cesiumMap/HoverTooltip.vue b/ruoyi-ui/src/views/cesiumMap/HoverTooltip.vue index c4f11f6..09c88df 100644 --- a/ruoyi-ui/src/views/cesiumMap/HoverTooltip.vue +++ b/ruoyi-ui/src/views/cesiumMap/HoverTooltip.vue @@ -3,7 +3,6 @@
{{ content }}
- 删除 diff --git a/ruoyi-ui/src/views/cesiumMap/MeasurementPanel.vue b/ruoyi-ui/src/views/cesiumMap/MeasurementPanel.vue index d09f8d4..703075d 100644 --- a/ruoyi-ui/src/views/cesiumMap/MeasurementPanel.vue +++ b/ruoyi-ui/src/views/cesiumMap/MeasurementPanel.vue @@ -8,7 +8,7 @@
面积: - {{ result.area.toFixed(2) }} 平方米 + {{ (result.area / 1000000).toFixed(2) }} 平方千米
半径: diff --git a/ruoyi-ui/src/views/cesiumMap/index.vue b/ruoyi-ui/src/views/cesiumMap/index.vue index 69f240e..b6857ef 100644 --- a/ruoyi-ui/src/views/cesiumMap/index.vue +++ b/ruoyi-ui/src/views/cesiumMap/index.vue @@ -153,9 +153,9 @@ export default { defaultStyles: { point: { color: '#FF0000', size: 12 }, line: { color: '#00FF00', width: 3 }, - polygon: { color: '#0000FF', opacity: 0, width: 3 }, - rectangle: { color: '#FFA500', opacity: 0, width: 3 }, - circle: { color: '#800080', opacity: 0, width: 3 }, + polygon: { color: '#0000FF', opacity: 0, width: 4 }, + rectangle: { color: '#FFA500', opacity: 0, width: 4 }, + circle: { color: '#800080', opacity: 0, width: 4 }, sector: { color: '#FF6347', opacity: 0, width: 3 }, arrow: { color: '#FF0000', width: 6 }, text: { color: '#000000', font: '48px Microsoft YaHei, PingFang SC, sans-serif', backgroundColor: 'rgba(255, 255, 255, 0.8)' }, @@ -211,15 +211,15 @@ export default { switch (unit) { case 'm': - displayValue = `1:${scaleDenominator}` + displayValue = `${scaleDenominator}` metersPerPixel = scaleFactor / pixelsPerCm break case 'km': - displayValue = `1:${scaleDenominator}` + displayValue = `${scaleDenominator}` metersPerPixel = (scaleFactor * 1000) / pixelsPerCm break default: - displayValue = `1:${scaleDenominator}` + displayValue = `${scaleDenominator}` metersPerPixel = scaleFactor / pixelsPerCm } @@ -812,7 +812,7 @@ export default { // 显示小框提示 this.hoverTooltip = { visible: true, - content: `长度:${length.toFixed(2)} 米\n${bearingType === 'magnetic' ? '磁方位' : '真方位'}:${bearing.toFixed(2)}°`, + content: `${(length / 1000).toFixed(1)}km ,${bearingType === 'magnetic' ? '磁' : '真'}:${bearing.toFixed(1)}°`, position: { x: movement.endPosition.x + 10, y: movement.endPosition.y - 10 @@ -1857,7 +1857,7 @@ export default { this.drawingPoints = []; }, // 生成圆形的点,用于绘制边框线 - generateCirclePositions(center, radius, numPoints = 64) { + generateCirclePositions(center, radius, numPoints = 128) { const positions = []; const ellipsoid = this.viewer.scene.globe.ellipsoid; @@ -1934,7 +1934,7 @@ export default { // 确保角度差不为零 angleDiff = Math.max(0.01, angleDiff); // 计算扇形的顶点数(根据角度差确定,确保平滑) - const numPoints = Math.max(5, Math.ceil(angleDiff * 180 / Math.PI / 10)); + const numPoints = Math.max(10, Math.ceil(angleDiff * 180 / Math.PI / 5)); const angleStep = angleDiff / (numPoints - 1); // 生成扇形的顶点(顺时针方向) for (let i = 0; i < numPoints; i++) { @@ -2452,6 +2452,13 @@ export default { lng: Cesium.Math.toDegrees(cartographic.longitude) } }, + degreesToDMS(decimalDegrees) { + const degrees = Math.floor(decimalDegrees) + const minutesDecimal = (decimalDegrees - degrees) * 60 + const minutes = Math.floor(minutesDecimal) + const seconds = ((minutesDecimal - minutes) * 60).toFixed(2) + return `${degrees}°${minutes}'${seconds}"` + }, calculateRectangle(start, end) { const startLL = this.cartesianToLatLng(start) const endLL = this.cartesianToLatLng(end) @@ -2745,49 +2752,102 @@ export default { } } }, - clearAll() { - // 1. 检查数组是否有内容 - if (this.allEntities && this.allEntities.length > 0) { - // 2. 遍历每一个对象进行删除 - this.allEntities.forEach(item => { - try { - // 情况 A: 数组里存的是原生的 Cesium Entity (点、线通常是这种情况) - if (item instanceof Cesium.Entity) { - this.viewer.entities.remove(item); - } - // 情况 B: 数组里存的是包装对象 (你的矩形、圆可能是这种 { entity: ... }) - else if (item.entity && item.entity instanceof Cesium.Entity) { - this.viewer.entities.remove(item.entity); - } - // 情况 C: 兜底方案,尝试通过 ID 删除 - else if (item.id) { - this.viewer.entities.removeById(item.id); - } - // 移除线实体相关的点实体 - if (item.type === 'line' && item.pointEntities) { - item.pointEntities.forEach(pointEntity => { - this.viewer.entities.remove(pointEntity); - }); + clearAll(showConfirm = true) { + if (showConfirm) { + this.$confirm('是否清除所有编辑内容?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.executeClearAll(); + }).catch(() => { + // 用户点击取消,不做任何操作 + }); + } else { + this.executeClearAll(); + } + }, + executeClearAll() { + // 1. 检查数组是否有内容 + if (this.allEntities && this.allEntities.length > 0) { + // 2. 遍历每一个对象进行删除 + this.allEntities.forEach(item => { + try { + let entity = null; + + // 情况 A: 数组里存的是原生的 Cesium Entity (点、线通常是这种情况) + if (item instanceof Cesium.Entity) { + entity = item; + } + // 情况 B: 数组里存的是包装对象 (你的矩形、圆可能是这种 { entity: ... }) + else if (item.entity && item.entity instanceof Cesium.Entity) { + entity = item.entity; + } + // 情况 C: 兜底方案,尝试通过 ID 删除 + else if (item.id) { + entity = this.viewer.entities.getById(item.id); + } + + // 检查是否是航线实体,如果是则跳过删除 + if (entity && entity.properties) { + const isMissionWaypoint = entity.properties.isMissionWaypoint; + const isMissionRouteLine = entity.properties.isMissionRouteLine; + if (isMissionWaypoint || isMissionRouteLine) { + return; // 跳过航线相关实体 + } + } + + // 删除非航线实体 + if (entity) { + this.viewer.entities.remove(entity); + } + + // 移除线实体相关的点实体 + if (item.type === 'line' && item.pointEntities) { + item.pointEntities.forEach(pointEntity => { + this.viewer.entities.remove(pointEntity); + }); + } + } catch (e) { + console.warn('删除实体失败:', e); } - } catch (e) { - console.warn('删除实体失败:', e); + }); + } + // 3. 清空数组(只保留航线实体) + this.allEntities = this.allEntities.filter(item => { + let entity = null; + if (item instanceof Cesium.Entity) { + entity = item; + } else if (item.entity && item.entity instanceof Cesium.Entity) { + entity = item.entity; + } else if (item.id) { + entity = this.viewer.entities.getById(item.id); } + + if (entity && entity.properties) { + const isMissionWaypoint = entity.properties.isMissionWaypoint; + const isMissionRouteLine = entity.properties.isMissionRouteLine; + return isMissionWaypoint || isMissionRouteLine; + } + return false; + }); + // 4. 清理可能残留的绘制过程中的临时图形 + if (this.tempEntity) { + this.viewer.entities.remove(this.tempEntity); + this.tempEntity = null; + } + if (this.tempPreviewEntity) { + this.viewer.entities.remove(this.tempPreviewEntity); + this.tempPreviewEntity = null; + } + // 5. 重置其他状态(如测量面板、绘制状态) + this.measurementResult = null; + this.stopDrawing(); + + this.$message({ + type: 'success', + message: '清除成功!' }); - } - // 3. 清空数组 - this.allEntities = []; - // 4. 清理可能残留的绘制过程中的临时图形 - if (this.tempEntity) { - this.viewer.entities.remove(this.tempEntity); - this.tempEntity = null; - } - if (this.tempPreviewEntity) { - this.viewer.entities.remove(this.tempPreviewEntity); - this.tempPreviewEntity = null; - } - // 5. 重置其他状态(如测量面板、绘制状态) - this.measurementResult = null; - this.stopDrawing(); }, // ================== 其他方法 ================== getTypeName(type) { @@ -3007,7 +3067,7 @@ export default { }, duration: 2 }) - this.$message.success(`已定位到经度 ${lng.toFixed(4)},纬度 ${lat.toFixed(4)}`) + this.$message.success(`已定位到经度 ${this.degreesToDMS(lng)},纬度 ${this.degreesToDMS(lat)}`) } }, @@ -3279,7 +3339,7 @@ export default { const cartographic = Cesium.Cartographic.fromCartesian(cartesian) const longitude = Cesium.Math.toDegrees(cartographic.longitude) const latitude = Cesium.Math.toDegrees(cartographic.latitude) - this.coordinatesText = `经度: ${longitude.toFixed(6)}, 纬度: ${latitude.toFixed(6)}` + this.coordinatesText = `经度: ${this.degreesToDMS(longitude)}, 纬度: ${this.degreesToDMS(latitude)}` } else { this.coordinatesText = '经度: --, 纬度: --' } @@ -3287,7 +3347,7 @@ export default { }, destroyViewer() { this.stopDrawing() - this.clearAll() + this.clearAll(false) if (this.pointMovementHandler) { this.pointMovementHandler.destroy() diff --git a/ruoyi-ui/src/views/childRoom/RightPanel.vue b/ruoyi-ui/src/views/childRoom/RightPanel.vue index 380e4ea..7160d2a 100644 --- a/ruoyi-ui/src/views/childRoom/RightPanel.vue +++ b/ruoyi-ui/src/views/childRoom/RightPanel.vue @@ -359,13 +359,6 @@ export default { if (plan) { this.$emit('select-plan', plan) } - // 仅加载并显示当前新方案的航线 - const planRoutes = this.routes.filter(r => r.scenarioId === planId) - planRoutes.forEach(route => { - if (!this.activeRouteIds.includes(route.id)) { - this.handleSelectRoute(route) - } - }) } },