From bc1187b4b8cd44a9f6b3425e433d37f35b826c30 Mon Sep 17 00:00:00 2001 From: Raphael Riebl Date: Mon, 21 Oct 2024 16:44:17 +0200 Subject: [PATCH] facilites: round altitude value to nearest integer value --- vanetza/facilities/cam_functions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vanetza/facilities/cam_functions.cpp b/vanetza/facilities/cam_functions.cpp index 93a0d2e25..5d0bd3ee3 100644 --- a/vanetza/facilities/cam_functions.cpp +++ b/vanetza/facilities/cam_functions.cpp @@ -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; }