test_mapem_ts_access.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <cmath>
3 
5 
6 TEST(etsi_its_mapem_ts_msgs, test_set_get_mapem) {
7  mapem_ts_msgs::IntersectionGeometry intsct;
8 
9  unsigned int intersection_id = randomInt(mapem_ts_msgs::IntersectionID::MIN, mapem_ts_msgs::IntersectionID::MAX);
10  mapem_ts_access::setIntersectionID(intsct, intersection_id);
11  EXPECT_EQ(intersection_id, mapem_ts_access::getIntersectionID(intsct));
12 
13  // Set specific position to test utm projection
14  double latitude = 50.787467;
15  double longitude = 6.046498;
16  double altitude = 209.0;
17  mapem_ts_access::setPosition3D(intsct, latitude, longitude, altitude);
18  int zone;
19  bool northp;
20  gm::PointStamped utm = mapem_ts_access::getRefPointUTMPosition(intsct, zone, northp);
21  EXPECT_NEAR(291827.02, utm.point.x, 1e-1);
22  EXPECT_NEAR(5630349.72, utm.point.y, 1e-1);
23  EXPECT_EQ(altitude, utm.point.z);
24  EXPECT_EQ(32, zone);
25  EXPECT_EQ(true, northp);
26  mapem_ts_access::setPosition3DFromUTMPosition(intsct.ref_point, utm, zone, northp);
27  EXPECT_NEAR(latitude, mapem_ts_access::getLatitude(intsct.ref_point), 1e-7);
28  EXPECT_NEAR(longitude, mapem_ts_access::getLongitude(intsct.ref_point), 1e-7);
29  EXPECT_NEAR(altitude, mapem_ts_access::getElevation(intsct.ref_point), 1e-2);
30 
31  mapem_ts_msgs::MAPEM mapem;
32 
33  unsigned int moy = randomInt(mapem_ts_msgs::MinuteOfTheYear::MIN, mapem_ts_msgs::MinuteOfTheYear::MAX);
35  EXPECT_EQ(moy, mapem_ts_access::getMinuteOfTheYearValue(mapem));
36  // Generate dummy time: 04.01.2007 1:15
37  struct tm timeinfo;
38  timeinfo.tm_sec = 0;
39  timeinfo.tm_min = 15;
40  timeinfo.tm_hour = 1;
41  timeinfo.tm_mday = 4;
42  timeinfo.tm_mon = 0;
43  timeinfo.tm_year = 107; //years since 1900
44  uint64_t unix_stamp = timegm(&timeinfo);
45  // Set time to beginning of 2007: 01.01.2007 0:00
46  timeinfo.tm_sec = 0;
47  timeinfo.tm_min = 0;
48  timeinfo.tm_hour = 0;
49  timeinfo.tm_mday = 1;
50  timeinfo.tm_mon = 0;
51  timeinfo.tm_year = 107; //years since 1900
52  EXPECT_EQ((timegm(&timeinfo)+60*moy)*1e9, mapem_ts_access::getUnixNanoseconds(mapem, unix_stamp*1e9));
53 }
getLatitude
double getLatitude(const CAM &cam)
Get the Latitude value of CAM.
Definition: cam_getters_common.h:75
etsi_its_mapem_ts_msgs::access::setPosition3DFromUTMPosition
void setPosition3DFromUTMPosition(Position3D &reference_position, const gm::PointStamped &utm_position, const int zone, const bool northp)
Set the Position3D from a given UTM-Position.
Definition: mapem_ts_setters.h:183
getLongitude
double getLongitude(const CAM &cam)
Get the Longitude value of CAM.
Definition: cam_getters_common.h:85
etsi_its_mapem_ts_msgs::access::setMinuteOfTheYear
void setMinuteOfTheYear(MinuteOfTheYear &moy, const uint32_t moy_value)
Set the MinuteOfTheYear object.
Definition: mapem_ts_setters.h:49
etsi_its_mapem_ts_msgs
Definition: mapem_ts_getters.h:34
etsi_its_mapem_ts_msgs::access::getUnixNanoseconds
uint64_t getUnixNanoseconds(const MAPEM &mapem, const uint64_t unix_timestamp_estimate)
Get the unix nanoseconds from MinuteOfTheYear object.
Definition: mapem_ts_utils.h:94
etsi_its_mapem_ts_msgs::access::setIntersectionID
void setIntersectionID(IntersectionID &intsct_id, const uint16_t id_value)
Set the IntersectionID value.
Definition: mapem_ts_setters.h:80
etsi_its_mapem_ts_msgs::access
Definition: mapem_ts_getters.h:36
randomInt
int randomInt(int min, int max)
Definition: test_access.cpp:28
etsi_its_mapem_ts_msgs::access::getIntersectionID
uint16_t getIntersectionID(const IntersectionID &intsct_id)
Get the IntersectionID value.
Definition: mapem_ts_getters.h:89
etsi_its_mapem_ts_msgs::access::setPosition3D
void setPosition3D(Position3D &pos, const double latitude, const double longitude)
Set the Position3D object.
Definition: mapem_ts_setters.h:139
etsi_its_mapem_ts_msgs::access::getRefPointUTMPosition
gm::PointStamped 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 ...
Definition: mapem_ts_utils.h:167
TEST
TEST(etsi_its_mapem_ts_msgs, test_set_get_mapem)
Definition: test_mapem_ts_access.cpp:6
etsi_its_mapem_ts_msgs::access::getMinuteOfTheYearValue
uint32_t getMinuteOfTheYearValue(const MapData &map)
Get the value of MinuteOfTheYear value from MapData object.
Definition: mapem_ts_getters.h:58
etsi_its_mapem_ts_msgs::access::getElevation
double getElevation(const Elevation &elevation)
Get the Elevation value.
Definition: mapem_ts_getters.h:129


etsi_its_msgs_utils
Author(s): Jean-Pierre Busch , Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:32:12