Apollo 11.0
自动驾驶开放平台
apollo::hdmap::adapter::UtilXmlParser类 参考

#include <util_xml_parser.h>

apollo::hdmap::adapter::UtilXmlParser 的协作图:

静态 Public 成员函数

static Status ParseCurve (const tinyxml2::XMLElement &xml_node, PbCurve *curve)
 
static Status ParseGeometry (const tinyxml2::XMLElement &xml_node, PbCurveSegment *curve_segment)
 
static Status ParsePointSet (const tinyxml2::XMLElement &xml_node, PbLineSegment *line_segment)
 
static Status ParseOutline (const tinyxml2::XMLElement &xml_node, PbPolygon *polygon)
 
static Status ParsePoint (const tinyxml2::XMLElement &xml_node, PbPoint3D *pt)
 
static std::string ToUpper (const std::string &s)
 
static void WGS84ToUTM (const double x, const double y, const double z, double *output_x, double *output_y, double *output_z)
 
static double CurveLength (const PbCurve &curve)
 
static tinyxml2::XMLError QueryStringAttribute (const tinyxml2::XMLElement &xml_node, const std::string &name, std::string *value)
 

详细描述

在文件 util_xml_parser.h 第 28 行定义.

成员函数说明

◆ CurveLength()

double apollo::hdmap::adapter::UtilXmlParser::CurveLength ( const PbCurve &  curve)
static

在文件 util_xml_parser.cc 第 191 行定义.

191 {
192 double length = 0.0;
193 for (int i = 0; i < curve.segment_size(); ++i) {
194 length += curve.segment(i).length();
195 }
196
197 return length;
198}

◆ ParseCurve()

Status apollo::hdmap::adapter::UtilXmlParser::ParseCurve ( const tinyxml2::XMLElement &  xml_node,
PbCurve *  curve 
)
static

在文件 util_xml_parser.cc 第 26 行定义.

27 {
28 CHECK_NOTNULL(curve);
29
30 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement("geometry");
31 while (sub_node) {
32 PbCurveSegment* curve_segment = curve->add_segment();
33 RETURN_IF_ERROR(UtilXmlParser::ParseGeometry(*sub_node, curve_segment));
34 sub_node = sub_node->NextSiblingElement("geometry");
35 }
36
37 return Status::OK();
38}
static Status OK()
generate a success status.
Definition status.h:60
static Status ParseGeometry(const tinyxml2::XMLElement &xml_node, PbCurveSegment *curve_segment)
#define RETURN_IF_ERROR(expr)
Definition status.h:25
apollo::hdmap::CurveSegment PbCurveSegment

◆ ParseGeometry()

Status apollo::hdmap::adapter::UtilXmlParser::ParseGeometry ( const tinyxml2::XMLElement &  xml_node,
PbCurveSegment *  curve_segment 
)
static

在文件 util_xml_parser.cc 第 40 行定义.

41 {
42 CHECK_NOTNULL(curve_segment);
43
44 // Read geometry attributes
45 double s = 0.0;
46 double ptx = 0.0;
47 double pty = 0.0;
48 double ptz = 0.0;
49 double length = 0.0;
50
51 int checker = tinyxml2::XML_SUCCESS;
52
53 checker += xml_node.QueryDoubleAttribute("sOffset", &s);
54 checker += xml_node.QueryDoubleAttribute("x", &ptx);
55 checker += xml_node.QueryDoubleAttribute("y", &pty);
56 checker += xml_node.QueryDoubleAttribute("length", &length);
57
58 if (checker == tinyxml2::XML_SUCCESS) {
59 curve_segment->set_s(s);
60
61 double output_x = 0.0;
62 double output_y = 0.0;
63 double output_z = 0.0;
64
65 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
66
67 curve_segment->mutable_start_position()->set_x(output_x);
68 curve_segment->mutable_start_position()->set_y(output_y);
69 curve_segment->set_length(length);
70 }
71
72 const auto sub_node = xml_node.FirstChildElement("pointSet");
73 if (sub_node) {
74 PbLineSegment* line_segment = curve_segment->mutable_line_segment();
75 RETURN_IF_ERROR(ParsePointSet(*sub_node, line_segment));
76 return Status::OK();
77 }
78
79 std::string err_msg = "Error geometry object";
81}
static void WGS84ToUTM(const double x, const double y, const double z, double *output_x, double *output_y, double *output_z)
static Status ParsePointSet(const tinyxml2::XMLElement &xml_node, PbLineSegment *line_segment)
apollo::hdmap::LineSegment PbLineSegment

◆ ParseOutline()

Status apollo::hdmap::adapter::UtilXmlParser::ParseOutline ( const tinyxml2::XMLElement &  xml_node,
PbPolygon *  polygon 
)
static

在文件 util_xml_parser.cc 第 113 行定义.

114 {
115 const tinyxml2::XMLElement* sub_node =
116 xml_node.FirstChildElement("cornerGlobal");
117 while (sub_node) {
118 double ptx = 0.0;
119 double pty = 0.0;
120 double ptz = 0.0;
121 int checker = tinyxml2::XML_SUCCESS;
122 checker += sub_node->QueryDoubleAttribute("x", &ptx);
123 checker += sub_node->QueryDoubleAttribute("y", &pty);
124 checker += sub_node->QueryDoubleAttribute("z", &ptz);
125
126 if (checker != tinyxml2::XML_SUCCESS) {
127 std::string err_msg = "Error parsing cornerGlobal point attributes";
129 }
130
131 PbPoint3D* pt = polygon->add_point();
132 double output_x = 0.0;
133 double output_y = 0.0;
134 double output_z = 0.0;
135 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
136 pt->set_x(output_x);
137 pt->set_y(output_y);
138 pt->set_z(output_z);
139
140 sub_node = sub_node->NextSiblingElement("cornerGlobal");
141 }
142
143 return Status::OK();
144}
apollo::common::PointENU PbPoint3D

◆ ParsePoint()

Status apollo::hdmap::adapter::UtilXmlParser::ParsePoint ( const tinyxml2::XMLElement &  xml_node,
PbPoint3D *  pt 
)
static

在文件 util_xml_parser.cc 第 146 行定义.

147 {
148 CHECK_NOTNULL(pt);
149
150 const auto sub_node = xml_node.FirstChildElement("centerPoint");
151 ACHECK(sub_node != nullptr);
152 int checker = tinyxml2::XML_SUCCESS;
153 double ptx = 0.0;
154 double pty = 0.0;
155 double ptz = 0.0;
156 checker += sub_node->QueryDoubleAttribute("x", &ptx);
157 checker += sub_node->QueryDoubleAttribute("y", &pty);
158 checker += sub_node->QueryDoubleAttribute("z", &ptz);
159
160 if (checker != tinyxml2::XML_SUCCESS) {
161 std::string err_msg = "Error parse point attributes";
163 }
164
165 double output_x = 0.0;
166 double output_y = 0.0;
167 double output_z = 0.0;
168 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
169 pt->set_x(output_x);
170 pt->set_y(output_y);
171 pt->set_z(output_z);
172
173 return Status::OK();
174}
#define ACHECK(cond)
Definition log.h:80

◆ ParsePointSet()

Status apollo::hdmap::adapter::UtilXmlParser::ParsePointSet ( const tinyxml2::XMLElement &  xml_node,
PbLineSegment *  line_segment 
)
static

在文件 util_xml_parser.cc 第 83 行定义.

84 {
85 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement("point");
86 while (sub_node) {
87 double ptx = 0.0;
88 double pty = 0.0;
89 double ptz = 0.0;
90 int checker = tinyxml2::XML_SUCCESS;
91 checker += sub_node->QueryDoubleAttribute("x", &ptx);
92 checker += sub_node->QueryDoubleAttribute("y", &pty);
93
94 if (checker != tinyxml2::XML_SUCCESS) {
95 std::string err_msg = "Error parsing geometry point attributes";
97 }
98
99 PbPoint3D* pt = line_segment->add_point();
100 double output_x = 0.0;
101 double output_y = 0.0;
102 double output_z = 0.0;
103 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
104 pt->set_x(output_x);
105 pt->set_y(output_y);
106
107 sub_node = sub_node->NextSiblingElement("point");
108 }
109
110 return Status::OK();
111}

◆ QueryStringAttribute()

tinyxml2::XMLError apollo::hdmap::adapter::UtilXmlParser::QueryStringAttribute ( const tinyxml2::XMLElement &  xml_node,
const std::string &  name,
std::string *  value 
)
static

在文件 util_xml_parser.cc 第 200 行定义.

202 {
203 CHECK_NOTNULL(value);
204 const char* val = xml_node.Attribute(name.c_str());
205 if (val == nullptr) {
206 return tinyxml2::XML_NO_ATTRIBUTE;
207 }
208
209 *value = val;
210 return tinyxml2::XML_SUCCESS;
211}

◆ ToUpper()

std::string apollo::hdmap::adapter::UtilXmlParser::ToUpper ( const std::string &  s)
static

在文件 util_xml_parser.cc 第 176 行定义.

176 {
177 std::string value = s;
178 std::transform(value.begin(), value.end(), value.begin(),
179 [](unsigned char c) { return std::toupper(c); });
180
181 return value;
182}

◆ WGS84ToUTM()

void apollo::hdmap::adapter::UtilXmlParser::WGS84ToUTM ( const double  x,
const double  y,
const double  z,
double *  output_x,
double *  output_y,
double *  output_z 
)
static

在文件 util_xml_parser.cc 第 184 行定义.

186 {
188 output_y, output_z);
189}
Status CoordiateConvert(const double longitude, const double latitude, const double height_ellipsoid, double *utm_x, double *utm_y, double *utm_z)

该类的文档由以下文件生成: