Utility functions for the ETSI ITS MAPEM.
More...
#include <ctime>
#include <GeographicLib/UTMUPS.hpp>
Go to the source code of this file.
|
| uint64_t | etsi_its_mapem_ts_msgs::access::getUnixSecondsOfYear (const uint64_t unixSecond) |
| | Get the unix seconds of the beginning of a year that corresponds to a given unix timestamp.
|
| uint64_t | etsi_its_mapem_ts_msgs::access::getUnixNanosecondsFromMinuteOfTheYear (const MinuteOfTheYear &moy, const uint64_t unix_nanoseconds_estimate) |
| | Get the unix nanoseconds from MinuteOfTheYear object.
|
| uint64_t | etsi_its_mapem_ts_msgs::access::getUnixNanosecondsFromMapData (const MapData &map, const uint64_t unix_nanoseconds_estimate) |
| | Get the unix nanoseconds from MapData object.
|
| uint64_t | etsi_its_mapem_ts_msgs::access::getUnixNanoseconds (const MAPEM &mapem, const uint64_t unix_timestamp_estimate) |
| | Get the unix nanoseconds from MinuteOfTheYear object.
|
| gm::PointStamped | etsi_its_mapem_ts_msgs::access::getUTMPosition (const Position3D &reference_position, int &zone, bool &northp) |
| | Get the UTM Position defined by the given Position3D.
|
| gm::PointStamped | etsi_its_mapem_ts_msgs::access::getUTMPositionWithConvergenceAngle (const Position3D &reference_position, int &zone, bool &northp, double &conv_angle) |
| | Get the UTM Position defined by the given Position3D along with the grid-convergence angle.
|
| gm::PointStamped | etsi_its_mapem_ts_msgs::access::getRefPointUTMPosition (const IntersectionGeometry &intsctn, int &zone, bool &northp) |
| | Get the UTM Position of ref_point defined by the Position3D along with the grid-convergence angle in an IntersectionGeometry object.
|
| gm::PointStamped | etsi_its_mapem_ts_msgs::access::getRefPointUTMPositionWithConvergenceAngle (const IntersectionGeometry &intsctn, int &zone, bool &northp, double &conv_angle) |
| | Get the UTM Position of ref_point defined by the Position3D in an IntersectionGeometry object.
|
Utility functions for the ETSI ITS MAPEM.
Definition in file mapem_ts_utils.h.
◆ getRefPointUTMPosition()
| gm::PointStamped etsi_its_mapem_ts_msgs::access::getRefPointUTMPosition |
( |
const IntersectionGeometry & | intsctn, |
|
|
int & | zone, |
|
|
bool & | northp ) |
|
inline |
Get the UTM Position of ref_point defined by the Position3D along with the grid-convergence angle in an IntersectionGeometry object.
The position is transformed into UTM by using GeographicLib::UTMUPS The altitude value is directly used as z-Coordinate
- Parameters
-
| [in] | intsctn | IntersectionGeometry to get the UTM Position from |
| [out] | zone | the UTM zone (zero means UPS) |
| [out] | northp | hemisphere (true means north, false means south) |
- Returns
- gm::PointStamped geometry_msgs::PointStamped of the given position
Definition at line 144 of file mapem_ts_utils.h.
144 {
146 }
gm::PointStamped getUTMPosition(const Position3D &reference_position, int &zone, bool &northp)
Get the UTM Position defined by the given Position3D.
◆ getRefPointUTMPositionWithConvergenceAngle()
| gm::PointStamped etsi_its_mapem_ts_msgs::access::getRefPointUTMPositionWithConvergenceAngle |
( |
const IntersectionGeometry & | intsctn, |
|
|
int & | zone, |
|
|
bool & | northp, |
|
|
double & | conv_angle ) |
|
inline |
Get the UTM Position of ref_point defined by the Position3D in an IntersectionGeometry object.
The position is transformed into UTM by using GeographicLib::UTMUPS The altitude value is directly used as z-Coordinate
- Parameters
-
| [in] | intsctn | IntersectionGeometry to get the UTM Position from |
| [out] | zone | the UTM zone (zero means UPS) |
| [out] | northp | hemisphere (true means north, false means south) |
| [out] | conv_angle | grid-convergence angle in degree |
- Returns
- gm::PointStamped geometry_msgs::PointStamped of the given position
Definition at line 160 of file mapem_ts_utils.h.
160 {
162 }
gm::PointStamped getUTMPositionWithConvergenceAngle(const Position3D &reference_position, int &zone, bool &northp, double &conv_angle)
Get the UTM Position defined by the given Position3D along with the grid-convergence angle.
◆ getUnixNanoseconds()
| uint64_t etsi_its_mapem_ts_msgs::access::getUnixNanoseconds |
( |
const MAPEM & | mapem, |
|
|
const uint64_t | unix_timestamp_estimate ) |
|
inline |
Get the unix nanoseconds from MinuteOfTheYear object.
- Parameters
-
| mapem | given MAPEM object |
| unix_nanoseconds_estimate | unix timestamp to derive the current year from in nanoseconds |
- Returns
- uint64_t unix timestamp according to the stored MinuteOfTheYear in nanoseconds
Definition at line 71 of file mapem_ts_utils.h.
71 {
73 }
uint64_t getUnixNanosecondsFromMapData(const MapData &map, const uint64_t unix_nanoseconds_estimate)
Get the unix nanoseconds from MapData object.
◆ getUnixNanosecondsFromMapData()
| uint64_t etsi_its_mapem_ts_msgs::access::getUnixNanosecondsFromMapData |
( |
const MapData & | map, |
|
|
const uint64_t | unix_nanoseconds_estimate ) |
|
inline |
Get the unix nanoseconds from MapData object.
- Parameters
-
| map | given MapData object |
| unix_nanoseconds_estimate | unix timestamp to derive the current year from in nanoseconds |
- Returns
- uint64_t unix timestamp according to the given MinuteOfTheYear in nanoseconds
Definition at line 60 of file mapem_ts_utils.h.
60 {
62 }
MinuteOfTheYear getMinuteOfTheYear(const MapData &map)
Get the value of MinuteOfTheYear object MapData object.
uint64_t getUnixNanosecondsFromMinuteOfTheYear(const MinuteOfTheYear &moy, const uint64_t unix_nanoseconds_estimate)
Get the unix nanoseconds from MinuteOfTheYear object.
◆ getUnixNanosecondsFromMinuteOfTheYear()
| uint64_t etsi_its_mapem_ts_msgs::access::getUnixNanosecondsFromMinuteOfTheYear |
( |
const MinuteOfTheYear & | moy, |
|
|
const uint64_t | unix_nanoseconds_estimate ) |
|
inline |
Get the unix nanoseconds from MinuteOfTheYear object.
- Parameters
-
| moy | given MinuteOfTheYear object |
| unix_nanoseconds_estimate | unix timestamp to derive the current year from in nanoseconds |
- Returns
- uint64_t unix timestamp according to the given MinuteOfTheYear in nanoseconds
Definition at line 49 of file mapem_ts_utils.h.
49 {
51 }
uint64_t getUnixSecondsOfYear(const uint64_t unixSecond)
Get the unix seconds of the beginning of a year that corresponds to a given unix timestamp.
◆ getUnixSecondsOfYear()
| uint64_t etsi_its_mapem_ts_msgs::access::getUnixSecondsOfYear |
( |
const uint64_t | unixSecond | ) |
|
|
inline |
Get the unix seconds of the beginning of a year that corresponds to a given unix timestamp.
- Parameters
-
| unixSecond | timestamp that defines the year for that the unix seconds for the beginning of the year should be derived |
- Returns
- uint64_t unix seconds of the beginning of the year
Definition at line 24 of file mapem_ts_utils.h.
24 {
25
26
27 time_t ts = static_cast<time_t>(unixSecond);
28
29 struct tm* timeinfo;
30 timeinfo = gmtime(&ts);
31
32
33 timeinfo->tm_sec = 0;
34 timeinfo->tm_min = 0;
35 timeinfo->tm_hour = 0;
36 timeinfo->tm_mday = 1;
37 timeinfo->tm_mon = 0;
38
39 return timegm(timeinfo);
40 }
◆ getUTMPosition()
| gm::PointStamped etsi_its_mapem_ts_msgs::access::getUTMPosition |
( |
const Position3D & | reference_position, |
|
|
int & | zone, |
|
|
bool & | northp ) |
|
inline |
Get the UTM Position defined by the given Position3D.
The position is transformed into UTM by using GeographicLib::UTMUPS The altitude value is directly used as z-Coordinate
- Parameters
-
| [in] | reference_position | Position3D to get the UTM Position from |
| [out] | zone | the UTM zone (zero means UPS) |
| [out] | northp | hemisphere (true means north, false means south) |
- Returns
- gm::PointStamped geometry_msgs::PointStamped of the given position
Definition at line 86 of file mapem_ts_utils.h.
86 {
87 gm::PointStamped utm_point;
88 double latitude =
getLatitude(reference_position.lat);
90 if(reference_position.elevation_is_present) utm_point.point.z =
getElevation(reference_position.elevation);
91 try {
92 GeographicLib::UTMUPS::Forward(latitude, longitude, zone, northp, utm_point.point.x, utm_point.point.y);
93 std::string hemisphere;
94 if(northp) hemisphere="N";
95 else hemisphere="S";
96 utm_point.header.frame_id="utm_"+std::to_string(zone)+hemisphere;
97 } catch (GeographicLib::GeographicErr& e) {
98 throw std::invalid_argument(e.what());
99 }
100 return utm_point;
101 }
double getLongitude(const Longitude &longitude)
Get the Longitude value.
double getLatitude(const Latitude &latitude)
Get the Latitude value.
double getElevation(const Elevation &elevation)
Get the Elevation value.
◆ getUTMPositionWithConvergenceAngle()
| gm::PointStamped etsi_its_mapem_ts_msgs::access::getUTMPositionWithConvergenceAngle |
( |
const Position3D & | reference_position, |
|
|
int & | zone, |
|
|
bool & | northp, |
|
|
double & | conv_angle ) |
|
inline |
Get the UTM Position defined by the given Position3D along with the grid-convergence angle.
The position is transformed into UTM by using GeographicLib::UTMUPS The altitude value is directly used as z-Coordinate
- Parameters
-
| [in] | reference_position | Position3D to get the UTM Position from |
| [out] | zone | the UTM zone (zero means UPS) |
| [out] | northp | hemisphere (true means north, false means south) |
| [out] | conv_angle | grid-convergence angle in degree |
- Returns
- gm::PointStamped geometry_msgs::PointStamped of the given position
Definition at line 115 of file mapem_ts_utils.h.
115 {
116 gm::PointStamped utm_point;
117 double latitude =
getLatitude(reference_position.lat);
118 double longitude =
getLongitude(reference_position.lon);
119 if(reference_position.elevation_is_present) utm_point.point.z =
getElevation(reference_position.elevation);
120 try {
121 double scale;
122 GeographicLib::UTMUPS::Forward(latitude, longitude, zone, northp, utm_point.point.x, utm_point.point.y, conv_angle, scale);
123 std::string hemisphere;
124 if(northp) hemisphere="N";
125 else hemisphere="S";
126 utm_point.header.frame_id="utm_"+std::to_string(zone)+hemisphere;
127 } catch (GeographicLib::GeographicErr& e) {
128 throw std::invalid_argument(e.what());
129 }
130 return utm_point;
131 }