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

#include <signals_xml_parser.h>

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

静态 Public 成员函数

static Status ParseTrafficLights (const tinyxml2::XMLElement &xml_node, std::vector< TrafficLightInternal > *traffic_lights)
 
static Status ParseStopSigns (const tinyxml2::XMLElement &xml_node, std::vector< StopSignInternal > *stop_signs)
 
static Status ParseYieldSigns (const tinyxml2::XMLElement &xml_node, std::vector< YieldSignInternal > *yield_signs)
 

详细描述

在文件 signals_xml_parser.h 第 29 行定义.

成员函数说明

◆ ParseStopSigns()

Status apollo::hdmap::adapter::SignalsXmlParser::ParseStopSigns ( const tinyxml2::XMLElement &  xml_node,
std::vector< StopSignInternal > *  stop_signs 
)
static

在文件 signals_xml_parser.cc 第 229 行定义.

231 {
232 CHECK_NOTNULL(stop_signs);
233
234 auto signal_node = xml_node.FirstChildElement("signal");
235 while (signal_node) {
236 std::string object_type;
237 std::string object_id;
238 int checker =
239 UtilXmlParser::QueryStringAttribute(*signal_node, "type", &object_type);
240 checker +=
241 UtilXmlParser::QueryStringAttribute(*signal_node, "id", &object_id);
242 if (checker != tinyxml2::XML_SUCCESS) {
243 std::string err_msg = "Error parse signal type.";
245 }
246
247 if (object_type == "stopSign") {
248 PbStopSign stop_sign;
249 stop_sign.mutable_id()->set_id(object_id);
250
251 StopSignInternal stop_sign_internal;
252 stop_sign_internal.stop_sign = stop_sign;
253
254 auto sub_node = signal_node->FirstChildElement("stopline");
255 if (sub_node) {
256 sub_node = sub_node->FirstChildElement("objectReference");
257 while (sub_node) {
258 std::string stop_line_id;
259 int checker = UtilXmlParser::QueryStringAttribute(*sub_node, "id",
260 &stop_line_id);
261 ACHECK(checker == tinyxml2::XML_SUCCESS);
262 stop_sign_internal.stop_line_ids.insert(stop_line_id);
263
264 sub_node = sub_node->NextSiblingElement("objectReference");
265 }
266 }
267
268 sub_node = signal_node->FirstChildElement("attribute");
269 if (sub_node) {
270 std::string stop_type;
271 int checker = UtilXmlParser::QueryStringAttribute(*sub_node, "stopType",
272 &stop_type);
273 if (checker != tinyxml2::XML_SUCCESS) {
274 std::string err_msg = "Error parse stop type.";
276 }
277
278 PbStopSignType pb_stop_type;
279 ToPbStopSignType(stop_type, &pb_stop_type);
280 stop_sign_internal.stop_sign.set_type(pb_stop_type);
281 }
282
283 stop_signs->emplace_back(stop_sign_internal);
284 }
285
286 signal_node = signal_node->NextSiblingElement("signal");
287 }
288 return Status::OK();
289}
static Status OK()
generate a success status.
Definition status.h:60
static tinyxml2::XMLError QueryStringAttribute(const tinyxml2::XMLElement &xml_node, const std::string &name, std::string *value)
#define ACHECK(cond)
Definition log.h:80
apollo::hdmap::StopSign PbStopSign
apollo::hdmap::StopSign_StopType PbStopSignType

◆ ParseTrafficLights()

Status apollo::hdmap::adapter::SignalsXmlParser::ParseTrafficLights ( const tinyxml2::XMLElement &  xml_node,
std::vector< TrafficLightInternal > *  traffic_lights 
)
static

在文件 signals_xml_parser.cc 第 23 行定义.

25 {
26 CHECK_NOTNULL(traffic_lights);
27 auto signal_node = xml_node.FirstChildElement("signal");
28 while (signal_node) {
29 std::string object_type;
30 std::string object_id;
31 int checker =
32 UtilXmlParser::QueryStringAttribute(*signal_node, "type", &object_type);
33 checker +=
34 UtilXmlParser::QueryStringAttribute(*signal_node, "id", &object_id);
35 if (checker != tinyxml2::XML_SUCCESS) {
36 std::string err_msg = "Error parse signal type.";
38 }
39
40 if (object_type == "trafficLight") {
41 PbSignal traffic_light;
42 traffic_light.mutable_id()->set_id(object_id);
43 std::string layout_type;
45 *signal_node, "layoutType", &layout_type);
46 if (checker != tinyxml2::XML_SUCCESS) {
47 std::string err_msg = "Error parse signal layout type.";
49 }
50 PbSignalType signal_layout_type;
51 ToPbSignalType(layout_type, &signal_layout_type);
52 traffic_light.set_type(signal_layout_type);
53
54 auto sign_infos_node = signal_node->FirstChildElement("signInfos");
55 if (sign_infos_node != nullptr) {
56 auto sign_info_node = sign_infos_node->FirstChildElement("signInfo");
57 while (sign_info_node != nullptr) {
58 std::string sign_info_type;
59 checker = UtilXmlParser::QueryStringAttribute(*sign_info_node, "type",
60 &sign_info_type);
61 if (checker != tinyxml2::XML_SUCCESS) {
62 std::string err_msg = "Error parse sign info type.";
64 }
65
66 auto sign_info = traffic_light.add_sign_info();
67 PbSignInfoType pb_sign_info_type;
68 to_pb_sign_info_type(sign_info_type, &pb_sign_info_type);
69 sign_info->set_type(pb_sign_info_type);
70
71 sign_info_node = sign_info_node->NextSiblingElement("signInfo");
72 }
73 }
74
75 PbPolygon* polygon = traffic_light.mutable_boundary();
76 auto outline_node = signal_node->FirstChildElement("outline");
77 if (outline_node == nullptr) {
78 std::string err_msg = "Error parse signal outline";
80 }
81 RETURN_IF_ERROR(UtilXmlParser::ParseOutline(*outline_node, polygon));
82 auto sub_node = signal_node->FirstChildElement("subSignal");
83 if (sub_node == nullptr) {
84 std::string err_msg = "Error parse sub signal.";
86 }
87
88 while (sub_node) {
89 std::string sub_signal_id;
90 std::string sub_signal_xml_type;
91 checker = UtilXmlParser::QueryStringAttribute(*sub_node, "type",
92 &sub_signal_xml_type);
93 checker += UtilXmlParser::QueryStringAttribute(*sub_node, "id",
94 &sub_signal_id);
95 if (checker != tinyxml2::XML_SUCCESS) {
96 std::string err_msg = "Error parse sub signal layout type.";
98 }
99
100 PbSubSignal* sub_signal = traffic_light.add_subsignal();
101 PbSubSignalType sub_signal_type;
102 ToPbSubSignalType(sub_signal_xml_type, &sub_signal_type);
103 sub_signal->mutable_id()->set_id(sub_signal_id);
104 sub_signal->set_type(sub_signal_type);
105 PbPoint3D* pt = sub_signal->mutable_location();
107
108 sub_node = sub_node->NextSiblingElement("subSignal");
109 }
110
111 TrafficLightInternal trafficlight_internal;
112 trafficlight_internal.id = object_id;
113 trafficlight_internal.traffic_light = traffic_light;
114
115 sub_node = signal_node->FirstChildElement("stopline");
116 if (sub_node) {
117 sub_node = sub_node->FirstChildElement("objectReference");
118 while (sub_node) {
119 std::string stop_line_id;
120 int checker = UtilXmlParser::QueryStringAttribute(*sub_node, "id",
121 &stop_line_id);
122 ACHECK(checker == tinyxml2::XML_SUCCESS);
123 trafficlight_internal.stop_line_ids.insert(stop_line_id);
124 sub_node = sub_node->NextSiblingElement("objectReference");
125 }
126 }
127 traffic_lights->emplace_back(trafficlight_internal);
128 }
129 signal_node = signal_node->NextSiblingElement("signal");
130 }
131 return Status::OK();
132}
static Status ParseOutline(const tinyxml2::XMLElement &xml_node, PbPolygon *polygon)
static Status ParsePoint(const tinyxml2::XMLElement &xml_node, PbPoint3D *pt)
#define RETURN_IF_ERROR(expr)
Definition status.h:25
apollo::hdmap::Signal PbSignal
apollo::hdmap::Subsignal_Type PbSubSignalType
apollo::hdmap::SignInfo::Type PbSignInfoType
apollo::hdmap::Signal_Type PbSignalType
apollo::common::PointENU PbPoint3D
apollo::hdmap::Subsignal PbSubSignal
apollo::hdmap::Polygon PbPolygon

◆ ParseYieldSigns()

Status apollo::hdmap::adapter::SignalsXmlParser::ParseYieldSigns ( const tinyxml2::XMLElement &  xml_node,
std::vector< YieldSignInternal > *  yield_signs 
)
static

在文件 signals_xml_parser.cc 第 291 行定义.

293 {
294 CHECK_NOTNULL(yield_signs);
295
296 auto signal_node = xml_node.FirstChildElement("signal");
297 while (signal_node) {
298 std::string object_type;
299 std::string object_id;
300 int checker =
301 UtilXmlParser::QueryStringAttribute(*signal_node, "type", &object_type);
302 checker +=
303 UtilXmlParser::QueryStringAttribute(*signal_node, "id", &object_id);
304 if (checker != tinyxml2::XML_SUCCESS) {
305 std::string err_msg = "Error parse signal type.";
307 }
308
309 if (object_type == "yieldSign") {
310 PbYieldSign yield_sign;
311 yield_sign.mutable_id()->set_id(object_id);
312 YieldSignInternal yield_sign_internal;
313 yield_sign_internal.id = object_id;
314 yield_sign_internal.yield_sign = yield_sign;
315 auto sub_node = signal_node->FirstChildElement("stopline");
316 if (sub_node) {
317 sub_node = sub_node->FirstChildElement("objectReference");
318 while (sub_node) {
319 std::string stop_line_id;
320 int checker = UtilXmlParser::QueryStringAttribute(*sub_node, "id",
321 &stop_line_id);
322 ACHECK(checker == tinyxml2::XML_SUCCESS);
323 yield_sign_internal.stop_line_ids.insert(stop_line_id);
324
325 sub_node = sub_node->NextSiblingElement("objectReference");
326 }
327 }
328 yield_signs->emplace_back(yield_sign_internal);
329 }
330
331 signal_node = signal_node->NextSiblingElement("signal");
332 }
333 return Status::OK();
334}
apollo::hdmap::YieldSign PbYieldSign

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