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 =
33 checker +=
35 if (checker != tinyxml2::XML_SUCCESS) {
36 std::string err_msg = "Error parse signal type.";
38 }
39
40 if (object_type == "trafficLight") {
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 }
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;
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();
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 }
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;
92 &sub_signal_xml_type);
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();
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;
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 }
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)
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