33 c =
static_cast<char>(std::tolower(
static_cast<unsigned char>(c)));
41 std::unordered_map<std::string, std::string> geo_parameters_map;
43 static const std::regex re(R
"(\+([A-Za-z0-9_]+)(?:=("[^"]*"|'[^']*'|[^ \t\r\n+]+))?)");
44 for (std::sregex_iterator it(s.begin(), s.end(), re), end; it != end; ++it) {
45 std::string key = (*it)[1].str();
46 std::string val = (*it)[2].str();
47 geo_parameters_map[key] = val;
50 return geo_parameters_map;
55 std::unordered_map<std::string, double> geo_offset_result;
58 std::string key = attr.name();
59 double value = attr.as_double();
60 geo_offset_result[key] = value;
62 return geo_offset_result;
66 template <
typename M,
typename S>
69 auto i = parameters.find(std::forward<S>(name));
70 if (i == parameters.cend())
76 template <
typename M,
typename S,
typename O>
78 std::enable_if_t<std::is_floating_point<O>::value,
bool>
81 auto i = parameters.find(std::forward<S>(name));
82 if (i == parameters.cend())
84 out =
static_cast<O
>(std::stod(i->second));
88 template <
typename M,
typename S,
typename O>
90 std::enable_if_t<std::is_integral<O>::value && std::is_unsigned<O>::value,
bool>
93 auto i = parameters.find(std::forward<S>(name));
94 if (i == parameters.cend())
96 out =
static_cast<O
>(std::stoull(i->second));
100 template <
typename M,
typename S,
typename O>
102 std::enable_if_t<std::is_integral<O>::value && std::is_signed<O>::value,
bool>
105 auto i = parameters.find(std::forward<S>(name));
106 if (i == parameters.cend())
108 out =
static_cast<O
>(std::stoll(i->second));
112 template <
typename S,
typename O>
113 static bool TryGetParameter(O& out,std::unordered_map<std::string, double>& parameters,S&& name)
115 auto i = parameters.find(std::forward<S>(name));
116 if (i == parameters.cend()){
119 out =
static_cast<O
>(i->second);
128 bool initialized=
false;
133 auto it = geom::custom_ellipsoids.find(value);
134 if (it != geom::custom_ellipsoids.end()) {
135 ellps.
a = it->second.first;
136 ellps.
f_inv = it->second.second;
154 auto val = geom::custom_ellipsoids.find(
"wgs84");
155 ellps.
a = val->second.first;
156 ellps.
f_inv = val->second.second;
162 static boost::optional<geom::OffsetTransform>
CreateOffsetTransform(std::unordered_map<std::string, double>& offset_parameters){
164 if(offset_parameters.empty()){
182 std::unordered_map<std::string, std::string> parameters,
183 std::string proj_string,
194 projection.SetPROJString(proj_string);
199 std::unordered_map<std::string, std::string> parameters,
200 std::string proj_string,
201 geom::Ellipsoid ellipsoid, boost::optional<carla::geom::OffsetTransform> offset){
205 log_warning(
"Missing 'zone' parameter for UTM projection. Using default value " + std::to_string(p.
zone));
207 p.
north = (parameters.count(
"south") > 0) ? false :
true;
211 projection.SetPROJString(proj_string);
216 std::string proj_string,
223 projection.SetPROJString(proj_string);
228 std::unordered_map<std::string, std::string> parameters,
229 std::string proj_string,
236 log_warning(
"Missing 'lat_1' parameter for LCC projection. Using default value " + std::to_string(p.
lat_1));
238 log_warning(
"Missing 'lat_2' parameter for LCC projection. Using default value " + std::to_string(p.
lat_2));
243 projection.SetPROJString(proj_string);
297 log_warning(
"cannot find the type of projection, using default transverse mercator");
298 return std::make_pair(
304 if (proj ==
"tmerc") {
305 return std::make_pair(
308 }
else if (proj ==
"utm") {
309 return std::make_pair(
312 }
else if (proj ==
"merc") {
313 return std::make_pair(
316 }
else if (proj ==
"lcc") {
317 return std::make_pair(
321 log_debug(
"projection '" + proj +
"' is not supported, using default transverse mercator.");
322 return std::make_pair(
332 auto georeference_string =
338 auto georeference_offset_node =
345 georeference_string, georeference_offset_node);
boost::optional< OffsetTransform > offset
static void Parse(const pugi::xml_document &xml, carla::road::MapBuilder &map_builder)
void SetGeoProjection(const geom::GeoProjection &geo_projection)
void SetGeoReference(const geom::GeoLocation &geo_reference)
xml_attribute next_attribute() const
xml_node child(const char_t *name) const
const char_t * child_value() const
xml_attribute first_attribute() const
static geom::GeoProjection CreateLambertConformalConicProjection(std::unordered_map< std::string, std::string > parameters, std::string proj_string, geom::Ellipsoid ellipsoid)
static boost::optional< geom::OffsetTransform > CreateOffsetTransform(std::unordered_map< std::string, double > &offset_parameters)
static auto ParseGeoProjectionAndReference(const std::string &proj_string, const pugi::xml_node &geo_offset)
static geom::GeoLocation CreateWebMercatorGeoReference()
static geom::GeoProjection CreateTransverseMercatorProjection(std::unordered_map< std::string, std::string > parameters, std::string proj_string, geom::Ellipsoid ellipsoid)
static std::unordered_map< std::string, std::string > ParseProjectionParameters(const std::string &s)
static geom::GeoLocation CreateTransverseMercatorGeoReference(std::unordered_map< std::string, std::string > parameters)
static geom::GeoProjection CreateDefaultProjection(geom::Ellipsoid ellipsoid)
static geom::GeoProjection CreateUniversalTransverseMercatorProjection(std::unordered_map< std::string, std::string > parameters, std::string proj_string, geom::Ellipsoid ellipsoid, boost::optional< carla::geom::OffsetTransform > offset)
static std::string ToLowerCase(S &&s)
static bool TryGetParameter(std::string &out, M ¶meters, S &&name)
static std::unordered_map< std::string, double > ParseOffsetParameters(const pugi::xml_node &geo_offset)
static geom::GeoProjection CreateWebMercatorProjection(std::string proj_string, geom::Ellipsoid ellipsoid)
static geom::GeoLocation CreateLambertConic2SPGeoReference(std::unordered_map< std::string, std::string > parameters)
static geom::GeoLocation CreateUniversalTransverseMercatorGeoReference(std::unordered_map< std::string, std::string > parameters)
static geom::Ellipsoid CreateEllipsoid(std::unordered_map< std::string, std::string > parameters)
static geom::GeoLocation CreateDefaultGeoReference()
This file contains definitions of common data structures used in traffic manager.
static GeoProjection Make(T &&args)