etsi_its_messages v3.4.0
Loading...
Searching...
No Matches
mapem_ts_setters.h File Reference

Setter functions for the ETSI ITS MAPEM. More...

#include <GeographicLib/UTMUPS.hpp>
#include <etsi_its_msgs_utils/impl/checks.h>

Go to the source code of this file.

Functions

template<typename T1, typename T2>
void etsi_its_mapem_ts_msgs::access::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.
void etsi_its_mapem_ts_msgs::access::throwIfNotPresent (const bool is_present, const std::string val_desc)
 Throws an exception if the given value is not present.
void etsi_its_mapem_ts_msgs::access::setMinuteOfTheYear (MinuteOfTheYear &moy, const uint32_t moy_value)
 Set the MinuteOfTheYear object.
void etsi_its_mapem_ts_msgs::access::setMinuteOfTheYear (MapData &map, const uint32_t moy_value)
 Set the MinuteOfTheYear for a given MapData object.
void etsi_its_mapem_ts_msgs::access::setMinuteOfTheYear (MAPEM &mapem, const uint32_t moy_value)
 Set the Minute Of The Year object.
void etsi_its_mapem_ts_msgs::access::setIntersectionID (IntersectionID &intsct_id, const uint16_t id_value)
 Set the IntersectionID value.
void etsi_its_mapem_ts_msgs::access::setIntersectionID (IntersectionGeometry &intsct, const uint16_t id_value)
 Set the IntersectionID for an IntersectionGeometry object.
void etsi_its_mapem_ts_msgs::access::setLatitude (Latitude &latitude, const double deg)
 Set the Latitude object.
void etsi_its_mapem_ts_msgs::access::setLongitude (Longitude &longitude, const double deg)
 Set the Longitude object.
void etsi_its_mapem_ts_msgs::access::setElevation (Elevation &elevation, const double value)
 Set the Elevation object.
void etsi_its_mapem_ts_msgs::access::setPosition3D (Position3D &pos, const double latitude, const double longitude)
 Set the Position3D object.
void etsi_its_mapem_ts_msgs::access::setPosition3D (Position3D &pos, const double latitude, const double longitude, const double altitude)
 Set the Position3D object.
void etsi_its_mapem_ts_msgs::access::setPosition3D (IntersectionGeometry &intsct, double latitude, double longitude, double altitude)
 Set the Position3D of IntersectionGeometry object.
void etsi_its_mapem_ts_msgs::access::setPosition3DFromUTMPosition (Position3D &reference_position, const gm::PointStamped &utm_position, const int zone, const bool northp)
 Set the Position3D from a given UTM-Position.

Detailed Description

Setter functions for the ETSI ITS MAPEM.

Definition in file mapem_ts_setters.h.

Function Documentation

◆ setElevation()

void etsi_its_mapem_ts_msgs::access::setElevation ( Elevation & elevation,
const double value )
inline

Set the Elevation object.

Parameters
elevationobject to set
valueElevation value (above the reference ellipsoid surface) in meter as decimal number

Definition at line 125 of file mapem_ts_setters.h.

125 {
126 int64_t alt_in_dm = (int64_t)std::round(value*1e1);
127 if(alt_in_dm>=Elevation::MIN && alt_in_dm<=Elevation::MAX) elevation.value = alt_in_dm;
128 else if(alt_in_dm<Elevation::MIN) elevation.value = Elevation::MIN;
129 else if(alt_in_dm>Elevation::MAX) elevation.value = Elevation::MAX;
130 }

◆ setIntersectionID() [1/2]

void etsi_its_mapem_ts_msgs::access::setIntersectionID ( IntersectionGeometry & intsct,
const uint16_t id_value )
inline

Set the IntersectionID for an IntersectionGeometry object.

Parameters
intsctIntersectionGeometry object
id_valuevalue to set

Definition at line 91 of file mapem_ts_setters.h.

91 {
92 setIntersectionID(intsct.id.id, id_value);
93 }
void setIntersectionID(IntersectionID &intsct_id, const uint16_t id_value)
Set the IntersectionID value.

◆ setIntersectionID() [2/2]

void etsi_its_mapem_ts_msgs::access::setIntersectionID ( IntersectionID & intsct_id,
const uint16_t id_value )
inline

Set the IntersectionID value.

Parameters
intsct_idIntersectionID object
id_valuevalue to set

Definition at line 80 of file mapem_ts_setters.h.

80 {
81 throwIfOutOfRange(id_value, IntersectionID::MIN, IntersectionID::MAX, "IntersectionID");
82 intsct_id.value = id_value;
83 }
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.

◆ setLatitude()

void etsi_its_mapem_ts_msgs::access::setLatitude ( Latitude & latitude,
const double deg )
inline

Set the Latitude object.

Parameters
latitudeobject to set
degLatitude value in degree as decimal number

Definition at line 101 of file mapem_ts_setters.h.

101 {
102 int64_t angle_in_10_micro_degree = (int64_t)std::round(deg*1e7);
103 throwIfOutOfRange(angle_in_10_micro_degree, Latitude::MIN, Latitude::MAX, "Latitude");
104 latitude.value = angle_in_10_micro_degree;
105 }

◆ setLongitude()

void etsi_its_mapem_ts_msgs::access::setLongitude ( Longitude & longitude,
const double deg )
inline

Set the Longitude object.

Parameters
longitudeobject to set
degLongitude value in degree as decimal number

Definition at line 113 of file mapem_ts_setters.h.

113 {
114 int64_t angle_in_10_micro_degree = (int64_t)std::round(deg*1e7);
115 throwIfOutOfRange(angle_in_10_micro_degree, Longitude::MIN, Longitude::MAX, "Longitude");
116 longitude.value = angle_in_10_micro_degree;
117 }

◆ setMinuteOfTheYear() [1/3]

void etsi_its_mapem_ts_msgs::access::setMinuteOfTheYear ( MapData & map,
const uint32_t moy_value )
inline

Set the MinuteOfTheYear for a given MapData object.

Parameters
mapMapData object
moy_valuevalue to set

Definition at line 60 of file mapem_ts_setters.h.

60 {
61 setMinuteOfTheYear(map.time_stamp, moy_value);
62 }
void setMinuteOfTheYear(MinuteOfTheYear &moy, const uint32_t moy_value)
Set the MinuteOfTheYear object.

◆ setMinuteOfTheYear() [2/3]

void etsi_its_mapem_ts_msgs::access::setMinuteOfTheYear ( MAPEM & mapem,
const uint32_t moy_value )
inline

Set the Minute Of The Year object.

Parameters
mapem

Definition at line 69 of file mapem_ts_setters.h.

69 {
70 setMinuteOfTheYear(mapem.map, moy_value);
71 mapem.map.time_stamp_is_present = true;
72 }

◆ setMinuteOfTheYear() [3/3]

void etsi_its_mapem_ts_msgs::access::setMinuteOfTheYear ( MinuteOfTheYear & moy,
const uint32_t moy_value )
inline

Set the MinuteOfTheYear object.

Parameters
moyMinuteOfTheYear object
moy_valuevalue to set

Definition at line 49 of file mapem_ts_setters.h.

49 {
50 throwIfOutOfRange(moy_value, MinuteOfTheYear::MIN, MinuteOfTheYear::MAX, "MinuteOfTheYear");
51 moy.value = moy_value;
52 }

◆ setPosition3D() [1/3]

void etsi_its_mapem_ts_msgs::access::setPosition3D ( IntersectionGeometry & intsct,
double latitude,
double longitude,
double altitude )
inline

Set the Position3D of IntersectionGeometry object.

Parameters
intsctIntersectionGeometry object
latitudeLatitude value in degree as decimal number
longitudeLongitude value in degree as decimal number
altitudeAltitude value (above the reference ellipsoid surface) in meter as decimal number

Definition at line 167 of file mapem_ts_setters.h.

167 {
168 setPosition3D(intsct.ref_point, latitude, longitude, altitude);
169 }
void setPosition3D(Position3D &pos, const double latitude, const double longitude)
Set the Position3D object.

◆ setPosition3D() [2/3]

void etsi_its_mapem_ts_msgs::access::setPosition3D ( Position3D & pos,
const double latitude,
const double longitude )
inline

Set the Position3D object.

Parameters
posobject to set
latitudeLatitude value in degree as decimal number
longitudeLongitude value in degree as decimal number

Definition at line 139 of file mapem_ts_setters.h.

139 {
140 setLatitude(pos.lat, latitude);
141 setLongitude(pos.lon, longitude);
142 pos.elevation_is_present = false;
143 }
void setLatitude(Latitude &latitude, const double deg)
Set the Latitude object.
void setLongitude(Longitude &longitude, const double deg)
Set the Longitude object.

◆ setPosition3D() [3/3]

void etsi_its_mapem_ts_msgs::access::setPosition3D ( Position3D & pos,
const double latitude,
const double longitude,
const double altitude )
inline

Set the Position3D object.

Parameters
posobject to set
latitudeLatitude value in degree as decimal number
longitudeLongitude value in degree as decimal number
altitudeAltitude value (above the reference ellipsoid surface) in meter as decimal number

Definition at line 153 of file mapem_ts_setters.h.

153 {
154 setPosition3D(pos, latitude, longitude);
155 setElevation(pos.elevation, altitude);
156 pos.elevation_is_present = true;
157 }
void setElevation(Elevation &elevation, const double value)
Set the Elevation object.

◆ setPosition3DFromUTMPosition()

void etsi_its_mapem_ts_msgs::access::setPosition3DFromUTMPosition ( Position3D & reference_position,
const gm::PointStamped & utm_position,
const int zone,
const bool northp )
inline

Set the Position3D from a given UTM-Position.

The position is transformed to latitude and longitude by using GeographicLib::UTMUPS The z-Coordinate is directly used as altitude value The frame_id of the given utm_position must be set to 'utm_<zone><N/S>'

Parameters
[out]reference_positionPosition3D to set
[in]utm_positiongeometry_msgs::PointStamped describing the given utm position
[in]zonethe UTM zone (zero means UPS) of the given position
[in]northphemisphere (true means north, false means south)

Definition at line 183 of file mapem_ts_setters.h.

183 {
184 std::string required_frame_prefix = "utm_";
185 if(utm_position.header.frame_id.rfind(required_frame_prefix, 0) != 0)
186 {
187 throw std::invalid_argument("Frame-ID of UTM Position '"+utm_position.header.frame_id+"' does not start with required prefix '"+required_frame_prefix+"'!");
188 }
189 double latitude, longitude;
190 try {
191 GeographicLib::UTMUPS::Reverse(zone, northp, utm_position.point.x, utm_position.point.y, latitude, longitude);
192 } catch (GeographicLib::GeographicErr& e) {
193 throw std::invalid_argument(e.what());
194 }
195 setPosition3D(reference_position, latitude, longitude, utm_position.point.z);
196 }

◆ throwIfNotPresent()

void etsi_its_mapem_ts_msgs::access::throwIfNotPresent ( const bool is_present,
const std::string val_desc )
inline

Throws an exception if the given value is not present.

Parameters
is_presentWhether the value is present.
val_descDescription of the value for the exception message.

Definition at line 58 of file mapem_ts_getters.h.

58 {
59 MinuteOfTheYear moy = getMinuteOfTheYear(map);
60 return moy.value;
MinuteOfTheYear getMinuteOfTheYear(const MapData &map)
Get the value of MinuteOfTheYear object MapData object.

◆ throwIfOutOfRange()

template<typename T1, typename T2>
void etsi_its_mapem_ts_msgs::access::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.

Template Parameters
T1
T2
Parameters
valThe value to check if it is in the range.
minThe minimum value of the range.
maxThe maximum value of the range.
val_descDescription of the value for the exception message.

Definition at line 47 of file mapem_ts_getters.h.

47 {
48 throwIfNotPresent(map.time_stamp_is_present, "map.time_stamp");
49 return map.time_stamp;
50 }
51
void throwIfNotPresent(const bool is_present, const std::string val_desc)
Throws an exception if the given value is not present.