diff --git a/ruoyi-ui/src/views/cesiumMap/index.vue b/ruoyi-ui/src/views/cesiumMap/index.vue index 54dded0..56e973c 100644 --- a/ruoyi-ui/src/views/cesiumMap/index.vue +++ b/ruoyi-ui/src/views/cesiumMap/index.vue @@ -965,15 +965,28 @@ export default { const bearing = bearingType === 'magnetic' ? this.calculateMagneticBearing(currentSegmentPositions) : this.calculateTrueBearing(currentSegmentPositions); - // 显示小框提示 - this.hoverTooltip = { - visible: true, - content: `累计长度:${cumulativeLength.toFixed(2)} 米\n${bearingType === 'magnetic' ? '磁方位' : '真方位'}:${bearing.toFixed(2)}°`, - position: { - x: movement.endPosition.x + 10, - y: movement.endPosition.y - 10 - } - }; + // 根据工具模式决定显示格式 + if (this.toolMode === 'ranging') { + // 测距模式:使用千米,简化格式 + this.hoverTooltip = { + visible: true, + content: `${(cumulativeLength / 1000).toFixed(1)}km ,${bearingType === 'magnetic' ? '磁' : '真'}:${bearing.toFixed(1)}°`, + position: { + x: movement.endPosition.x + 10, + y: movement.endPosition.y - 10 + } + }; + } else { + // 空域模式:使用米,完整格式 + this.hoverTooltip = { + visible: true, + content: `累计长度:${cumulativeLength.toFixed(2)} 米\n${bearingType === 'magnetic' ? '磁方位' : '真方位'}:${bearing.toFixed(2)}°`, + position: { + x: movement.endPosition.x + 10, + y: movement.endPosition.y - 10 + } + }; + } } else { // 如果没有找到对应的段,隐藏信息 this.hoverTooltip.visible = false; @@ -1252,15 +1265,28 @@ export default { const length = this.calculateLineLength(tempPositions); // 默认为真方位,因为绘制过程中还没有bearingType属性 const bearing = this.calculateTrueBearing(tempPositions); - // 更新小框提示,显示实时长度和真方位角 - this.hoverTooltip = { - visible: true, - content: `长度:${length.toFixed(2)} 米\n真方位:${bearing.toFixed(2)}°`, - position: { - x: movement.endPosition.x + 10, - y: movement.endPosition.y - 10 - } - }; + // 根据工具模式决定显示格式 + if (this.toolMode === 'ranging') { + // 测距模式:使用千米,简化格式 + this.hoverTooltip = { + visible: true, + content: `${(length / 1000).toFixed(1)}km ,真:${bearing.toFixed(1)}°`, + position: { + x: movement.endPosition.x + 10, + y: movement.endPosition.y - 10 + } + }; + } else { + // 空域模式:使用米,完整格式 + this.hoverTooltip = { + visible: true, + content: `长度:${length.toFixed(2)} 米\n真方位:${bearing.toFixed(2)}°`, + position: { + x: movement.endPosition.x + 10, + y: movement.endPosition.y - 10 + } + }; + } } else { // 如果没有点,隐藏提示 this.hoverTooltip.visible = false; @@ -2692,20 +2718,45 @@ export default { let declination; if (lngDeg >= 73 && lngDeg <= 135 && latDeg >= 18 && latDeg <= 53) { - // 中国地区简化磁偏角模型 - // 基于2020年数据,每年约变化0.1度 + // 中国地区简化磁偏角模型(基于WMM2025模型数据) + // 注意:中国大部分地区磁偏角偏西(负值),只有新疆、西藏等少数地区偏东(正值) + // 数据来源:NOAA WMM-2025模型 const year = new Date().getFullYear(); - const yearOffset = (year - 2020) * 0.1; + const yearOffset = (year - 2025) * 0.04; if (lngDeg < 100) { - // 西部地区 - declination = 2.0 - yearOffset; + // 西部地区(新疆、西藏等) + if (latDeg > 40) { + // 西北地区(新疆北部) + declination = 3.0 - yearOffset; + } else if (latDeg > 32) { + // 西南地区(四川、重庆等) + declination = -2.0 - yearOffset; + } else { + // 西藏地区 + declination = 1.0 - yearOffset; + } } else if (lngDeg < 115) { - // 中部地区 - declination = 1.0 - yearOffset; + // 中部地区(华北、华中) + if (latDeg > 38) { + // 华北地区(北京等) + declination = -7.5 - yearOffset; + } else if (latDeg > 32) { + // 华中北部 + declination = -5.0 - yearOffset; + } else { + // 华中南部 + declination = -3.5 - yearOffset; + } } else { - // 东部地区 - declination = 0.5 - yearOffset; + // 东部地区(华东、华南) + if (latDeg > 35) { + // 华东地区(上海等) + declination = -5.5 - yearOffset; + } else { + // 华南地区(广州、深圳等) + declination = -2.5 - yearOffset; + } } } else { // 其他地区默认磁偏角为0 @@ -2732,8 +2783,8 @@ export default { // 计算磁偏角 const declination = this.calculateMagneticDeclination(startLat, startLng); - // 计算磁方位角(真方位角加上磁偏角) - let magneticBearing = trueBearing + declination; + // 计算磁方位角(真方位角减去磁偏角) + let magneticBearing = trueBearing - declination; // 调整到0-360范围 return (magneticBearing + 360) % 360;