feat: 新增geoidSeparation验证

This commit is contained in:
yarnom 2025-10-29 18:36:01 +08:00
parent d92024a145
commit d5c2b069bb

View File

@ -3,6 +3,9 @@ package com.imdroid.sideslope.rtkcluster;
import com.imdroid.secapi.dto.RtkrcvProfile; import com.imdroid.secapi.dto.RtkrcvProfile;
import com.imdroid.secapi.dto.RtkrcvGroup; import com.imdroid.secapi.dto.RtkrcvGroup;
import com.imdroid.secapi.dto.RtkrcvGroupMapper; import com.imdroid.secapi.dto.RtkrcvGroupMapper;
import com.imdroid.secapi.dto.RtkrcvProfileMapper;
import com.imdroid.sideslope.service.DeviceService;
import com.imdroid.sideslope.service.Device;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -34,6 +37,10 @@ public class RtkrcvConfigService {
@Autowired(required = false) @Autowired(required = false)
private RtkrcvGroupMapper groupMapper; private RtkrcvGroupMapper groupMapper;
@Autowired
private DeviceService deviceService;
@Autowired
private RtkrcvProfileMapper profileMapper;
/** /**
* Generate an RTKLIB rtkrcv config file from template using profile values. * Generate an RTKLIB rtkrcv config file from template using profile values.
@ -58,6 +65,12 @@ public class RtkrcvConfigService {
List<String> rendered = new ArrayList<>(lines.size()); List<String> rendered = new ArrayList<>(lines.size());
Map<String, String> fromGroup = loadGroupConfig(profile); Map<String, String> fromGroup = loadGroupConfig(profile);
// Determine out-height from device geoidSeparation and write back to profile
int computedOutHeight = computeOutHeightFromDevice(profile.getDeviceId());
try {
profile.setOutHeight(computedOutHeight);
profileMapper.updateById(profile);
} catch (Exception ignore) {}
for (String line : lines) { for (String line : lines) {
String replaced = line; String replaced = line;
if (!fromGroup.isEmpty()) { if (!fromGroup.isEmpty()) {
@ -81,9 +94,7 @@ public class RtkrcvConfigService {
replaced = replaceValueLine(replaced, "misc-timeout", "300000"); replaced = replaceValueLine(replaced, "misc-timeout", "300000");
replaced = replaceValueLine(replaced, "misc-reconnect", "3000"); replaced = replaceValueLine(replaced, "misc-reconnect", "3000");
} }
Integer outHeight = profile.getOutHeight(); replaced = replaceValueLine(replaced, "out-height", String.valueOf(computedOutHeight));
int heightValue = (outHeight == null) ? 1 : (outHeight == 0 ? 0 : 1);
replaced = replaceValueLine(replaced, "out-height", String.valueOf(heightValue));
rendered.add(replaced); rendered.add(replaced);
} }
@ -130,6 +141,27 @@ public class RtkrcvConfigService {
if (value != null) map.put(key, value); if (value != null) map.put(key, value);
} }
private int computeOutHeightFromDevice(String deviceId) {
try {
Device device = deviceService.findByDeviceId(deviceId);
if (device != null) {
Double gsep = device.getGeoidSeparation();
Double lat = device.getLatitude();
Double lon = device.getLongitude();
Double alt = device.getAltitude();
LOGGER.info("[device:{}] lat={}, lon={}, alt={}, geoidSeparation={}",
deviceId, lat, lon, alt, gsep);
if (gsep != null) {
return (Math.abs(gsep) == 0.0) ? 0 : 1;
}
}
} catch (Exception e) {
LOGGER.warn("computeOutHeightFromDevice error for {}: {}", deviceId, e.getMessage());
}
// default to 1 (geodetic) if unknown
return 1;
}
private List<String> readTemplateLines() throws IOException { private List<String> readTemplateLines() throws IOException {
ClassPathResource resource = new ClassPathResource("rtkrcv_default.conf"); ClassPathResource resource = new ClassPathResource("rtkrcv_default.conf");
if (!resource.exists()) { if (!resource.exists()) {