1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 16:38:37 -05:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Edouard Griffiths
d0cae88ba8
Merge pull request #2338 from srcejon/fix_2337
RadioSonde: Limit precision of floating point numbers sent to SondeHub.
2024-11-19 16:27:50 +01:00
Jon Beniston
7b7f9e2c06 Limit precision of floating point numbers sent to SondeHub. 2024-11-18 09:48:50 +00:00

View File

@ -58,7 +58,9 @@ void SondeHub::upload(
} }
QJsonArray uploaderPos { QJsonArray uploaderPos {
uploaderLat, uploaderLon, uploaderAlt QString::number(uploaderLat, 'f', 5).toDouble(),
QString::number(uploaderLon, 'f', 5).toDouble(),
QString::number(uploaderAlt, 'f', 1).toDouble()
}; };
QJsonObject obj { QJsonObject obj {
@ -75,27 +77,27 @@ void SondeHub::upload(
{ {
obj.insert("frame", frame->m_frameNumber); obj.insert("frame", frame->m_frameNumber);
obj.insert("serial", frame->m_serial); obj.insert("serial", frame->m_serial);
obj.insert("batt", frame->m_batteryVoltage); obj.insert("batt", QString::number(frame->m_batteryVoltage, 'f', 2).toDouble());
} }
if (frame->m_measValid) if (frame->m_measValid)
{ {
// Don't upload uncalibrated measurements, as there can be a significant error // Don't upload uncalibrated measurements, as there can be a significant error
if (frame->isTemperatureCalibrated()) { if (frame->isTemperatureCalibrated()) {
obj.insert("temp", frame->getTemperatureFloat(subframe)); obj.insert("temp", QString::number(frame->getTemperatureFloat(subframe), 'f', 1).toDouble());
} }
if (frame->isHumidityCalibrated()) if (frame->isHumidityCalibrated())
{ {
float humidity = frame->getHumidityFloat(subframe); float humidity = frame->getHumidityFloat(subframe);
if (humidity != 0.0f) { if (humidity != 0.0f) {
obj.insert("humidity", humidity); obj.insert("humidity", QString::number(humidity, 'f', 1).toDouble());
} }
} }
if (frame->isPressureCalibrated()) if (frame->isPressureCalibrated())
{ {
float pressure = frame->getPressureFloat(subframe); float pressure = frame->getPressureFloat(subframe);
if (pressure != 0.0f) { if (pressure != 0.0f) {
obj.insert("pressure", pressure); obj.insert("pressure", QString::number(pressure, 'f', 2).toDouble());
} }
} }
} }
@ -107,12 +109,12 @@ void SondeHub::upload(
if (frame->m_posValid) if (frame->m_posValid)
{ {
obj.insert("lat", frame->m_latitude); obj.insert("lat", QString::number(frame->m_latitude, 'f', 5).toDouble());
obj.insert("lon", frame->m_longitude); obj.insert("lon", QString::number(frame->m_longitude, 'f', 5).toDouble());
obj.insert("alt", frame->m_height); obj.insert("alt", QString::number(frame->m_height, 'f', 1).toDouble());
obj.insert("vel_h", frame->m_speed); obj.insert("vel_h", QString::number(frame->m_speed, 'f', 2).toDouble());
obj.insert("vel_v", frame->m_verticalRate); obj.insert("vel_v", QString::number(frame->m_verticalRate, 'f', 2).toDouble());
obj.insert("heading", frame->m_heading); obj.insert("heading", QString::number(frame->m_heading, 'f', 1).toDouble());
obj.insert("sats", frame->m_satellitesUsed); obj.insert("sats", frame->m_satellitesUsed);
} }