35 #include <GeographicLib/UTMUPS.hpp>
50 throwIfOutOfRange(moy_value, MinuteOfTheYear::MIN, MinuteOfTheYear::MAX,
"MinuteOfTheYear");
51 moy.value = moy_value;
71 mapem.map.time_stamp_is_present =
true;
81 throwIfOutOfRange(id_value, IntersectionID::MIN, IntersectionID::MAX,
"IntersectionID");
82 intsct_id.value = id_value;
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;
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;
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;
139 inline void setPosition3D(Position3D& pos,
const double latitude,
const double longitude) {
142 pos.elevation_is_present =
false;
153 inline void setPosition3D(Position3D& pos,
const double latitude,
const double longitude,
const double altitude) {
156 pos.elevation_is_present =
true;
167 inline void setPosition3D(IntersectionGeometry& intsct,
double latitude,
double longitude,
double altitude) {
168 setPosition3D(intsct.ref_point, latitude, longitude, altitude);
184 std::string required_frame_prefix =
"utm_";
185 if(utm_position.header.frame_id.rfind(required_frame_prefix, 0) != 0)
187 throw std::invalid_argument(
"Frame-ID of UTM Position '"+utm_position.header.frame_id+
"' does not start with required prefix '"+required_frame_prefix+
"'!");
189 double latitude, longitude;
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());
195 setPosition3D(reference_position, latitude, longitude, utm_position.point.z);