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 167 of file mapem_ts_utils.h.
167 {
169 }
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 183 of file mapem_ts_utils.h.
183 {
185 }
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 94 of file mapem_ts_utils.h.
94 {
96 }
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 83 of file mapem_ts_utils.h.
83 {
85 }
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 72 of file mapem_ts_utils.h.
72 {
74 }
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 47 of file mapem_ts_utils.h.
47 {
48
49
50 time_t ts = static_cast<time_t>(unixSecond);
51
52 struct tm* timeinfo;
53 timeinfo = gmtime(&ts);
54
55
56 timeinfo->tm_sec = 0;
57 timeinfo->tm_min = 0;
58 timeinfo->tm_hour = 0;
59 timeinfo->tm_mday = 1;
60 timeinfo->tm_mon = 0;
61
62 return timegm(timeinfo);
63 }
◆ 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 109 of file mapem_ts_utils.h.
109 {
110 gm::PointStamped utm_point;
111 double latitude =
getLatitude(reference_position.lat);
112 double longitude =
getLongitude(reference_position.lon);
113 if(reference_position.elevation_is_present) utm_point.point.z =
getElevation(reference_position.elevation);
114 try {
115 GeographicLib::UTMUPS::Forward(latitude, longitude, zone, northp, utm_point.point.x, utm_point.point.y);
116 std::string hemisphere;
117 if(northp) hemisphere="N";
118 else hemisphere="S";
119 utm_point.header.frame_id="utm_"+std::to_string(zone)+hemisphere;
120 } catch (GeographicLib::GeographicErr& e) {
121 throw std::invalid_argument(e.what());
122 }
123 return utm_point;
124 }
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 138 of file mapem_ts_utils.h.
138 {
139 gm::PointStamped utm_point;
140 double latitude =
getLatitude(reference_position.lat);
141 double longitude =
getLongitude(reference_position.lon);
142 if(reference_position.elevation_is_present) utm_point.point.z =
getElevation(reference_position.elevation);
143 try {
144 double scale;
145 GeographicLib::UTMUPS::Forward(latitude, longitude, zone, northp, utm_point.point.x, utm_point.point.y, conv_angle, scale);
146 std::string hemisphere;
147 if(northp) hemisphere="N";
148 else hemisphere="S";
149 utm_point.header.frame_id="utm_"+std::to_string(zone)+hemisphere;
150 } catch (GeographicLib::GeographicErr& e) {
151 throw std::invalid_argument(e.what());
152 }
153 return utm_point;
154 }