Compare commits
2 Commits
9d54bdcb1a
...
b6629696d6
| Author | SHA1 | Date | |
|---|---|---|---|
| b6629696d6 | |||
|
|
c8678bc0a0 |
@ -519,28 +519,33 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
||||
}
|
||||
|
||||
if (insertIndex != -1) {
|
||||
ByteBuf newBuf = Unpooled.buffer();
|
||||
newBuf.writeBytes(originalData, 0, insertIndex / 2);
|
||||
|
||||
// 使用f9p坐标生成1005消息
|
||||
double[] ecef = new double[3];
|
||||
// 修复:确保坐标值不为null,并正确处理Double类型
|
||||
// 检查基站是否有有效的ECEF坐标
|
||||
Double ecefX = deviceBs.getEcefx();
|
||||
Double ecefY = deviceBs.getEcefy();
|
||||
Double ecefZ = deviceBs.getEcefz();
|
||||
|
||||
ecef[0] = ecefX != null ? ecefX.doubleValue() : 0.0;
|
||||
ecef[1] = ecefY != null ? ecefY.doubleValue() : 0.0;
|
||||
ecef[2] = ecefZ != null ? ecefZ.doubleValue() : 0.0;
|
||||
// 验证坐标有效性
|
||||
if (isValidEcefCoordinates(ecefX, ecefY, ecefZ)) {
|
||||
ByteBuf newBuf = Unpooled.buffer();
|
||||
newBuf.writeBytes(originalData, 0, insertIndex / 2);
|
||||
|
||||
String rtcm1005 = Rtcm1005.generateRtcm1005Hex(ecef, 0);
|
||||
if (rtcm1005 != null) {
|
||||
byte[] rtcm1005Bytes = ByteUtil.hexStringTobyte(rtcm1005);
|
||||
newBuf.writeBytes(rtcm1005Bytes);
|
||||
double[] ecef = new double[3];
|
||||
ecef[0] = ecefX.doubleValue();
|
||||
ecef[1] = ecefY.doubleValue();
|
||||
ecef[2] = ecefZ.doubleValue();
|
||||
|
||||
String rtcm1005 = Rtcm1005.generateRtcm1005Hex(ecef, 0);
|
||||
if (rtcm1005 != null && !rtcm1005.isEmpty()) {
|
||||
byte[] rtcm1005Bytes = ByteUtil.hexStringTobyte(rtcm1005);
|
||||
newBuf.writeBytes(rtcm1005Bytes);
|
||||
}
|
||||
|
||||
newBuf.writeBytes(originalData, insertIndex / 2, originalData.length - insertIndex / 2);
|
||||
buf = newBuf;
|
||||
} else {
|
||||
logger.warn("Base station {} has invalid ECEF coordinates, skipping RTCM 1005 generation for device {}",
|
||||
deviceBs.getDeviceId(), deviceId);
|
||||
}
|
||||
|
||||
newBuf.writeBytes(originalData, insertIndex / 2, originalData.length - insertIndex / 2);
|
||||
buf = newBuf;
|
||||
}
|
||||
|
||||
lastD300ForwardTimeMap.put(deviceId, currentTime);
|
||||
@ -788,29 +793,21 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印当前基站和设备状态(用于调试)
|
||||
* 验证ECEF坐标是否有效
|
||||
*/
|
||||
@Scheduled(fixedRate = 300000) // 5分钟执行一次
|
||||
public void printStatusSummary() {
|
||||
if (logger.isInfoEnabled() && !baseStationStatusMap.isEmpty()) {
|
||||
StringBuilder summary = new StringBuilder();
|
||||
summary.append("\n=== Base Station Status Summary ===\n");
|
||||
|
||||
for (BaseStationStatus status : baseStationStatusMap.values()) {
|
||||
summary.append(String.format("Base Station: %s, Status: %s, Last Active: %s, Serving Devices: %d\n",
|
||||
status.getBaseStationId(),
|
||||
status.getStatus(),
|
||||
status.getLastActiveTime(),
|
||||
status.getServingDevices().size()));
|
||||
}
|
||||
|
||||
summary.append("=== Device Base Mapping ===\n");
|
||||
for (Map.Entry<String, String> entry : deviceCurrentBaseMap.entrySet()) {
|
||||
summary.append(String.format("Device: %s -> Base Station: %s\n",
|
||||
entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
logger.info(summary.toString());
|
||||
private boolean isValidEcefCoordinates(Double x, Double y, Double z) {
|
||||
if (x == null || y == null || z == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否为零坐标
|
||||
if (x == 0.0 && y == 0.0 && z == 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查坐标是否在地球表面合理范围内(大致6.3M到6.4M米)
|
||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||
return distance >= 6300000 && distance <= 6400000;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user