Skip to content

Commit

Permalink
Limit precision of floating point numbers sent to SondeHub.
Browse files Browse the repository at this point in the history
  • Loading branch information
srcejon committed Nov 18, 2024
1 parent 5cc7b3a commit 7b7f9e2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions sdrbase/util/sondehub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ void SondeHub::upload(
}

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 {
Expand All @@ -75,27 +77,27 @@ void SondeHub::upload(
{
obj.insert("frame", frame->m_frameNumber);
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)
{
// Don't upload uncalibrated measurements, as there can be a significant error
if (frame->isTemperatureCalibrated()) {
obj.insert("temp", frame->getTemperatureFloat(subframe));
obj.insert("temp", QString::number(frame->getTemperatureFloat(subframe), 'f', 1).toDouble());
}
if (frame->isHumidityCalibrated())
{
float humidity = frame->getHumidityFloat(subframe);
if (humidity != 0.0f) {
obj.insert("humidity", humidity);
obj.insert("humidity", QString::number(humidity, 'f', 1).toDouble());
}
}
if (frame->isPressureCalibrated())
{
float pressure = frame->getPressureFloat(subframe);
if (pressure != 0.0f) {
obj.insert("pressure", pressure);
obj.insert("pressure", QString::number(pressure, 'f', 2).toDouble());
}
}
}
Expand All @@ -107,12 +109,12 @@ void SondeHub::upload(

if (frame->m_posValid)
{
obj.insert("lat", frame->m_latitude);
obj.insert("lon", frame->m_longitude);
obj.insert("alt", frame->m_height);
obj.insert("vel_h", frame->m_speed);
obj.insert("vel_v", frame->m_verticalRate);
obj.insert("heading", frame->m_heading);
obj.insert("lat", QString::number(frame->m_latitude, 'f', 5).toDouble());
obj.insert("lon", QString::number(frame->m_longitude, 'f', 5).toDouble());
obj.insert("alt", QString::number(frame->m_height, 'f', 1).toDouble());
obj.insert("vel_h", QString::number(frame->m_speed, 'f', 2).toDouble());
obj.insert("vel_v", QString::number(frame->m_verticalRate, 'f', 2).toDouble());
obj.insert("heading", QString::number(frame->m_heading, 'f', 1).toDouble());
obj.insert("sats", frame->m_satellitesUsed);
}

Expand Down

0 comments on commit 7b7f9e2

Please sign in to comment.