|
|
@ -153,9 +153,9 @@ export default { |
|
|
defaultStyles: { |
|
|
defaultStyles: { |
|
|
point: { color: '#FF0000', size: 12 }, |
|
|
point: { color: '#FF0000', size: 12 }, |
|
|
line: { color: '#00FF00', width: 3 }, |
|
|
line: { color: '#00FF00', width: 3 }, |
|
|
polygon: { color: '#0000FF', opacity: 0, width: 3 }, |
|
|
polygon: { color: '#0000FF', opacity: 0, width: 4 }, |
|
|
rectangle: { color: '#FFA500', opacity: 0, width: 3 }, |
|
|
rectangle: { color: '#FFA500', opacity: 0, width: 4 }, |
|
|
circle: { color: '#800080', opacity: 0, width: 3 }, |
|
|
circle: { color: '#800080', opacity: 0, width: 4 }, |
|
|
sector: { color: '#FF6347', opacity: 0, width: 3 }, |
|
|
sector: { color: '#FF6347', opacity: 0, width: 3 }, |
|
|
arrow: { color: '#FF0000', width: 6 }, |
|
|
arrow: { color: '#FF0000', width: 6 }, |
|
|
text: { color: '#000000', font: '48px Microsoft YaHei, PingFang SC, sans-serif', backgroundColor: 'rgba(255, 255, 255, 0.8)' }, |
|
|
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) { |
|
|
switch (unit) { |
|
|
case 'm': |
|
|
case 'm': |
|
|
displayValue = `1:${scaleDenominator}` |
|
|
displayValue = `${scaleDenominator}` |
|
|
metersPerPixel = scaleFactor / pixelsPerCm |
|
|
metersPerPixel = scaleFactor / pixelsPerCm |
|
|
break |
|
|
break |
|
|
case 'km': |
|
|
case 'km': |
|
|
displayValue = `1:${scaleDenominator}` |
|
|
displayValue = `${scaleDenominator}` |
|
|
metersPerPixel = (scaleFactor * 1000) / pixelsPerCm |
|
|
metersPerPixel = (scaleFactor * 1000) / pixelsPerCm |
|
|
break |
|
|
break |
|
|
default: |
|
|
default: |
|
|
displayValue = `1:${scaleDenominator}` |
|
|
displayValue = `${scaleDenominator}` |
|
|
metersPerPixel = scaleFactor / pixelsPerCm |
|
|
metersPerPixel = scaleFactor / pixelsPerCm |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -812,7 +812,7 @@ export default { |
|
|
// 显示小框提示 |
|
|
// 显示小框提示 |
|
|
this.hoverTooltip = { |
|
|
this.hoverTooltip = { |
|
|
visible: true, |
|
|
visible: true, |
|
|
content: `长度:${length.toFixed(2)} 米\n${bearingType === 'magnetic' ? '磁方位' : '真方位'}:${bearing.toFixed(2)}°`, |
|
|
content: `${(length / 1000).toFixed(1)}km ,${bearingType === 'magnetic' ? '磁' : '真'}:${bearing.toFixed(1)}°`, |
|
|
position: { |
|
|
position: { |
|
|
x: movement.endPosition.x + 10, |
|
|
x: movement.endPosition.x + 10, |
|
|
y: movement.endPosition.y - 10 |
|
|
y: movement.endPosition.y - 10 |
|
|
@ -1857,7 +1857,7 @@ export default { |
|
|
this.drawingPoints = []; |
|
|
this.drawingPoints = []; |
|
|
}, |
|
|
}, |
|
|
// 生成圆形的点,用于绘制边框线 |
|
|
// 生成圆形的点,用于绘制边框线 |
|
|
generateCirclePositions(center, radius, numPoints = 64) { |
|
|
generateCirclePositions(center, radius, numPoints = 128) { |
|
|
const positions = []; |
|
|
const positions = []; |
|
|
const ellipsoid = this.viewer.scene.globe.ellipsoid; |
|
|
const ellipsoid = this.viewer.scene.globe.ellipsoid; |
|
|
|
|
|
|
|
|
@ -1934,7 +1934,7 @@ export default { |
|
|
// 确保角度差不为零 |
|
|
// 确保角度差不为零 |
|
|
angleDiff = Math.max(0.01, angleDiff); |
|
|
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); |
|
|
const angleStep = angleDiff / (numPoints - 1); |
|
|
// 生成扇形的顶点(顺时针方向) |
|
|
// 生成扇形的顶点(顺时针方向) |
|
|
for (let i = 0; i < numPoints; i++) { |
|
|
for (let i = 0; i < numPoints; i++) { |
|
|
@ -2452,6 +2452,13 @@ export default { |
|
|
lng: Cesium.Math.toDegrees(cartographic.longitude) |
|
|
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) { |
|
|
calculateRectangle(start, end) { |
|
|
const startLL = this.cartesianToLatLng(start) |
|
|
const startLL = this.cartesianToLatLng(start) |
|
|
const endLL = this.cartesianToLatLng(end) |
|
|
const endLL = this.cartesianToLatLng(end) |
|
|
@ -2745,49 +2752,102 @@ export default { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
clearAll() { |
|
|
clearAll(showConfirm = true) { |
|
|
// 1. 检查数组是否有内容 |
|
|
if (showConfirm) { |
|
|
if (this.allEntities && this.allEntities.length > 0) { |
|
|
this.$confirm('是否清除所有编辑内容?', '提示', { |
|
|
// 2. 遍历每一个对象进行删除 |
|
|
confirmButtonText: '确定', |
|
|
this.allEntities.forEach(item => { |
|
|
cancelButtonText: '取消', |
|
|
try { |
|
|
type: 'warning' |
|
|
// 情况 A: 数组里存的是原生的 Cesium Entity (点、线通常是这种情况) |
|
|
}).then(() => { |
|
|
if (item instanceof Cesium.Entity) { |
|
|
this.executeClearAll(); |
|
|
this.viewer.entities.remove(item); |
|
|
}).catch(() => { |
|
|
} |
|
|
// 用户点击取消,不做任何操作 |
|
|
// 情况 B: 数组里存的是包装对象 (你的矩形、圆可能是这种 { entity: ... }) |
|
|
}); |
|
|
else if (item.entity && item.entity instanceof Cesium.Entity) { |
|
|
} else { |
|
|
this.viewer.entities.remove(item.entity); |
|
|
this.executeClearAll(); |
|
|
} |
|
|
} |
|
|
// 情况 C: 兜底方案,尝试通过 ID 删除 |
|
|
}, |
|
|
else if (item.id) { |
|
|
executeClearAll() { |
|
|
this.viewer.entities.removeById(item.id); |
|
|
// 1. 检查数组是否有内容 |
|
|
} |
|
|
if (this.allEntities && this.allEntities.length > 0) { |
|
|
// 移除线实体相关的点实体 |
|
|
// 2. 遍历每一个对象进行删除 |
|
|
if (item.type === 'line' && item.pointEntities) { |
|
|
this.allEntities.forEach(item => { |
|
|
item.pointEntities.forEach(pointEntity => { |
|
|
try { |
|
|
this.viewer.entities.remove(pointEntity); |
|
|
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) { |
|
|
getTypeName(type) { |
|
|
@ -3007,7 +3067,7 @@ export default { |
|
|
}, |
|
|
}, |
|
|
duration: 2 |
|
|
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 cartographic = Cesium.Cartographic.fromCartesian(cartesian) |
|
|
const longitude = Cesium.Math.toDegrees(cartographic.longitude) |
|
|
const longitude = Cesium.Math.toDegrees(cartographic.longitude) |
|
|
const latitude = Cesium.Math.toDegrees(cartographic.latitude) |
|
|
const latitude = Cesium.Math.toDegrees(cartographic.latitude) |
|
|
this.coordinatesText = `经度: ${longitude.toFixed(6)}, 纬度: ${latitude.toFixed(6)}` |
|
|
this.coordinatesText = `经度: ${this.degreesToDMS(longitude)}, 纬度: ${this.degreesToDMS(latitude)}` |
|
|
} else { |
|
|
} else { |
|
|
this.coordinatesText = '经度: --, 纬度: --' |
|
|
this.coordinatesText = '经度: --, 纬度: --' |
|
|
} |
|
|
} |
|
|
@ -3287,7 +3347,7 @@ export default { |
|
|
}, |
|
|
}, |
|
|
destroyViewer() { |
|
|
destroyViewer() { |
|
|
this.stopDrawing() |
|
|
this.stopDrawing() |
|
|
this.clearAll() |
|
|
this.clearAll(false) |
|
|
|
|
|
|
|
|
if (this.pointMovementHandler) { |
|
|
if (this.pointMovementHandler) { |
|
|
this.pointMovementHandler.destroy() |
|
|
this.pointMovementHandler.destroy() |
|
|
|