Skip to content

Commit

Permalink
facilites: round altitude value to nearest integer value
Browse files Browse the repository at this point in the history
  • Loading branch information
riebl committed Oct 21, 2024
1 parent c93410c commit bc1187b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vanetza/facilities/cam_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ AltitudeConfidence_t to_altitude_confidence(units::Length confidence)
AltitudeValue_t to_altitude_value(units::Length alt)
{
using boost::units::isnan;
static_assert(AltitudeValue_oneCentimeter == 1, "AltitudeValue encodes an integer number of centimeters");

if (!isnan(alt)) {
alt = boost::algorithm::clamp(alt, -1000.0 * units::si::meter, 8000.0 * units::si::meter);
return AltitudeValue_oneCentimeter * 100.0 * (alt / units::si::meter);
return round(alt, units::si::centi * units::si::meter);
} else {
return AltitudeValue_unavailable;
}
Expand Down

0 comments on commit bc1187b

Please sign in to comment.