32#ifndef ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_SETTERS_H
33#define ETSI_ITS_MSGS_UTILS_IMPL_CDD_CDD_V2_2_1_SETTERS_H
37#include <GeographicLib/UTMUPS.hpp>
48inline void setItsPduHeader(ItsPduHeader& header,
const uint8_t message_id,
const uint32_t station_id,
49 const uint8_t protocol_version = 0) {
52 header.message_id.value = message_id;
53 throwIfOutOfRange(protocol_version, OrdinalNumber1B::MIN, OrdinalNumber1B::MAX,
"ProtocolVersion");
54 header.protocol_version.value = protocol_version;
65template <
typename Wgs84AngleValue>
67 int64_t deg = (int64_t)std::round(value * 1e1);
68 throwIfOutOfRange(deg, Wgs84AngleValue::MIN, Wgs84AngleValue::MAX,
"Wgs84AngleValue");
78template<
typename Wgs84AngleConf
idence>
80 auto heading_conf = std::round(value * 1e1 * etsi_its_msgs::ONE_D_GAUSSIAN_FACTOR);
81 if (heading_conf < Wgs84AngleConfidence::MIN && heading_conf > 0.0){
82 heading_conf = Wgs84AngleConfidence::MIN;
83 }
else if (heading_conf >= Wgs84AngleConfidence::OUT_OF_RANGE || heading_conf <= 0.0) {
84 heading_conf = Wgs84AngleConfidence::UNAVAILABLE;
86 confidence.value =
static_cast<decltype(confidence.value)
>(heading_conf);
99template <
typename Wgs84Angle,
typename Wgs84AngleConf
idence = decltype(Wgs84Angle::conf
idence)>
100void setWGSHeadingCDD(Wgs84Angle& heading,
const double value,
double confidence = std::numeric_limits<double>::infinity()) {
Common setter functions for the ETSI ITS Common Data Dictionary (CDD) v1.3.1, v2.1....
void setStationId(StationId &station_id, const uint32_t id_value)
Set the Station Id object.
void setWGSHeadingValue(Wgs84AngleValue &heading, const double value)
Set the Wgs84AngleValue object.
void setWGSHeadingCDD(Wgs84Angle &heading, const double value, double confidence=std::numeric_limits< double >::infinity())
Set the Wgs84Angle object.
void setItsPduHeader(ItsPduHeader &header, const uint8_t message_id, const uint32_t station_id, const uint8_t protocol_version=0)
Set the Its Pdu Header object.
void setWGSHeadingConfidence(Wgs84AngleConfidence &confidence, const double value)
Set the Wgs84AngleConfidence object.
Sanity-check functions etc.
void throwIfOutOfRange(const T1 &val, const T2 &min, const T2 &max, const std::string val_desc)
Throws an exception if a given value is out of a defined range.