feat: 新增geoidSeparation验证
This commit is contained in:
parent
d92024a145
commit
d5c2b069bb
@ -3,6 +3,9 @@ package com.imdroid.sideslope.rtkcluster;
|
||||
import com.imdroid.secapi.dto.RtkrcvProfile;
|
||||
import com.imdroid.secapi.dto.RtkrcvGroup;
|
||||
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.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -34,6 +37,10 @@ public class RtkrcvConfigService {
|
||||
|
||||
@Autowired(required = false)
|
||||
private RtkrcvGroupMapper groupMapper;
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
@Autowired
|
||||
private RtkrcvProfileMapper profileMapper;
|
||||
|
||||
/**
|
||||
* 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());
|
||||
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) {
|
||||
String replaced = line;
|
||||
if (!fromGroup.isEmpty()) {
|
||||
@ -81,9 +94,7 @@ public class RtkrcvConfigService {
|
||||
replaced = replaceValueLine(replaced, "misc-timeout", "300000");
|
||||
replaced = replaceValueLine(replaced, "misc-reconnect", "3000");
|
||||
}
|
||||
Integer outHeight = profile.getOutHeight();
|
||||
int heightValue = (outHeight == null) ? 1 : (outHeight == 0 ? 0 : 1);
|
||||
replaced = replaceValueLine(replaced, "out-height", String.valueOf(heightValue));
|
||||
replaced = replaceValueLine(replaced, "out-height", String.valueOf(computedOutHeight));
|
||||
rendered.add(replaced);
|
||||
}
|
||||
|
||||
@ -130,6 +141,27 @@ public class RtkrcvConfigService {
|
||||
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 {
|
||||
ClassPathResource resource = new ClassPathResource("rtkrcv_default.conf");
|
||||
if (!resource.exists()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user