27 std::vector<PbCrosswalk>* crosswalks) {
28 CHECK_NOTNULL(crosswalks);
29 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement(
"object");
31 std::string object_type;
32 std::string object_id;
36 if (checker != tinyxml2::XML_SUCCESS) {
37 std::string err_msg =
"Error parse object type.";
41 if (object_type ==
"crosswalk") {
43 crosswalk.mutable_id()->set_id(object_id);
44 PbPolygon* polygon = crosswalk.mutable_polygon();
45 const tinyxml2::XMLElement* outline_node =
46 sub_node->FirstChildElement(
"outline");
47 if (outline_node ==
nullptr) {
48 std::string err_msg =
"Error parse crosswalk outline";
52 crosswalks->emplace_back(crosswalk);
54 sub_node = sub_node->NextSiblingElement(
"object");
60 const tinyxml2::XMLElement& xml_node,
61 std::vector<PbClearArea>* clear_areas) {
62 CHECK_NOTNULL(clear_areas);
63 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement(
"object");
65 std::string object_type;
66 std::string object_id;
71 if (checker != tinyxml2::XML_SUCCESS) {
72 std::string err_msg =
"Error parse object type.";
76 if (object_type ==
"clearArea") {
78 clear_area.mutable_id()->set_id(object_id);
79 PbPolygon* polygon = clear_area.mutable_polygon();
80 ACHECK(polygon !=
nullptr);
81 const tinyxml2::XMLElement* outline_node =
82 sub_node->FirstChildElement(
"outline");
83 if (outline_node ==
nullptr) {
84 std::string err_msg =
"Error parse cleararea outline";
88 clear_areas->emplace_back(clear_area);
90 sub_node = sub_node->NextSiblingElement(
"object");
97 const tinyxml2::XMLElement& xml_node,
98 std::vector<PbSpeedBump>* speed_bumps) {
99 CHECK_NOTNULL(speed_bumps);
100 const tinyxml2::XMLElement* object_node =
101 xml_node.FirstChildElement(
"object");
102 while (object_node) {
103 std::string object_type;
104 std::string object_id;
109 if (checker != tinyxml2::XML_SUCCESS) {
110 std::string err_msg =
"Error parse object type.";
114 if (object_type ==
"speedBump") {
116 const tinyxml2::XMLElement* sub_node =
117 object_node->FirstChildElement(
"geometry");
118 speed_bump.mutable_id()->set_id(object_id);
120 PbCurve* curve = speed_bump.add_position();
123 sub_node = sub_node->NextSiblingElement(
"geometry");
125 if (speed_bump.
position().empty()) {
126 std::string err_msg =
"Error speed bump miss stop line.";
129 speed_bumps->emplace_back(speed_bump);
131 object_node = object_node->NextSiblingElement(
"object");
137 const tinyxml2::XMLElement& xml_node,
138 std::vector<StopLineInternal>* stop_lines) {
139 CHECK_NOTNULL(stop_lines);
140 const tinyxml2::XMLElement* object_node =
141 xml_node.FirstChildElement(
"object");
142 while (object_node) {
143 std::string object_type;
144 std::string object_id;
149 if (checker != tinyxml2::XML_SUCCESS) {
150 std::string err_msg =
"Error parse object type.";
154 if (object_type ==
"stopline") {
156 stop_line.
id = object_id;
158 ACHECK(curve_segment !=
nullptr);
159 const auto sub_node = object_node->FirstChildElement(
"geometry");
160 if (sub_node ==
nullptr) {
161 std::string err_msg =
"Error parse stopline geometry";
165 stop_lines->emplace_back(stop_line);
167 object_node = object_node->NextSiblingElement(
"object");
173 const tinyxml2::XMLElement& xml_node,
174 std::vector<PbParkingSpace>* parking_spaces) {
175 CHECK_NOTNULL(parking_spaces);
176 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement(
"object");
178 std::string object_type;
179 std::string object_id;
183 if (checker != tinyxml2::XML_SUCCESS) {
184 std::string err_msg =
"Error parse object type.";
188 if (object_type ==
"parkingSpace") {
190 parking_space.mutable_id()->set_id(object_id);
192 double heading = 0.0;
193 checker = sub_node->QueryDoubleAttribute(
"heading", &heading);
194 if (checker != tinyxml2::XML_SUCCESS) {
195 std::string err_msg =
"Error parse parking space heading.";
198 parking_space.set_heading(heading);
200 PbPolygon* polygon = parking_space.mutable_polygon();
201 const auto* outline_node = sub_node->FirstChildElement(
"outline");
202 if (outline_node ==
nullptr) {
203 std::string err_msg =
"Error parse parking space outline";
207 parking_spaces->emplace_back(parking_space);
209 sub_node = sub_node->NextSiblingElement(
"object");
215 const tinyxml2::XMLElement& xml_node,
216 std::vector<PbPNCJunction>* pnc_junctions) {
217 CHECK_NOTNULL(pnc_junctions);
219 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement(
"object");
221 std::string object_type;
222 std::string object_id;
226 if (checker != tinyxml2::XML_SUCCESS) {
227 std::string err_msg =
"Error parse object type.";
231 if (object_type ==
"PNCJunction") {
233 pnc_junction.mutable_id()->set_id(object_id);
235 PbPolygon* polygon = pnc_junction.mutable_polygon();
236 const auto* outline_node = sub_node->FirstChildElement(
"outline");
237 if (outline_node ==
nullptr) {
238 std::string err_msg =
"Error parse pnc junction outline";
245 pnc_junctions->emplace_back(pnc_junction);
248 sub_node = sub_node->NextSiblingElement(
"object");
256 CHECK_NOTNULL(pnc_junction);
258 auto sub_node = xml_node.FirstChildElement(
"passageGroup");
260 std::string object_id;
261 std::string object_type;
262 PbPassageGroup* passage_group = pnc_junction->add_passage_group();
265 if (checker != tinyxml2::XML_SUCCESS) {
266 std::string err_msg =
"Error parse object type.";
269 passage_group->mutable_id()->set_id(object_id);
273 sub_node = sub_node->NextSiblingElement(
"passageGroup");
281 CHECK_NOTNULL(passage_group);
283 auto sub_node = xml_node.FirstChildElement(
"passage");
285 std::string object_type;
288 if (checker != tinyxml2::XML_SUCCESS) {
289 std::string err_msg =
"Error parse object type.";
293 auto passage = passage_group->add_passage();
296 passage->set_type(pb_passage_type);
298 std::vector<std::string> passage_node_ids;
300 for (
auto id : passage_node_ids) {
301 passage->add_lane_id()->set_id(
id);
305 for (
auto id : passage_node_ids) {
306 passage->add_signal_id()->set_id(
id);
310 for (
auto id : passage_node_ids) {
311 passage->add_yield_id()->set_id(
id);
316 for (
auto id : passage_node_ids) {
317 passage->add_stop_sign_id()->set_id(
id);
320 sub_node = sub_node->NextSiblingElement(
"passage");
327 const tinyxml2::XMLElement& xml_node,
const std::string& child_node_name,
328 std::vector<std::string>* passage_node_ids) {
329 CHECK_NOTNULL(passage_node_ids);
331 passage_node_ids->clear();
332 auto sub_node = xml_node.FirstChildElement(child_node_name.c_str());
334 std::string object_id;
337 if (checker != tinyxml2::XML_SUCCESS) {
338 std::string err_msg =
"Error parse passage lane id.";
341 passage_node_ids->push_back(object_id);
343 sub_node = sub_node->NextSiblingElement(child_node_name.c_str());
351 CHECK_NOTNULL(passage_type);
354 if (upper_str ==
"ENTRANCE") {
355 *passage_type = apollo::hdmap::Passage_Type_ENTRANCE;
356 }
else if (upper_str ==
"EXIT") {
357 *passage_type = apollo::hdmap::Passage_Type_EXIT;
359 *passage_type = apollo::hdmap::Passage_Type_UNKNOWN;
366 const tinyxml2::XMLElement& xml_node,
367 std::vector<RSUInternal>* rsus) {
370 auto rsu_node = xml_node.FirstChildElement(
"object");
372 std::string object_type;
373 std::string object_id;
378 if (checker != tinyxml2::XML_SUCCESS) {
379 std::string err_msg =
"Error parse rsu type.";
383 if (object_type ==
"rsu") {
384 std::string junction_id;
386 "junctionID", &junction_id);
387 if (checker != tinyxml2::XML_SUCCESS) {
388 std::string err_msg =
"Error parse rsu junction id.";
393 rsu.
rsu.mutable_id()->set_id(object_id);
394 rsu.
rsu.mutable_junction_id()->set_id(junction_id);
396 rsus->emplace_back(rsu);
398 rsu_node = rsu_node->NextSiblingElement(
"object");
407 CHECK_NOTNULL(objects);
410 auto sub_node = xml_node.FirstChildElement(
"objects");
411 if (sub_node !=
nullptr) {
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
static Status ParseObjects(const tinyxml2::XMLElement &xml_node, ObjectInternal *objects)
static Status ParsePassageIds(const tinyxml2::XMLElement &xml_node, const std::string &child_node_name, std::vector< std::string > *passage_node_ids)
static Status ParseSpeedBumps(const tinyxml2::XMLElement &xml_node, std::vector< PbSpeedBump > *speed_bumps)
static Status ParsePassage(const tinyxml2::XMLElement &xml_node, PbPassageGroup *passage_group)
static Status ParsePassageGroup(const tinyxml2::XMLElement &xml_node, PbPNCJunction *pnc_junction)
static Status ParseCrosswalks(const tinyxml2::XMLElement &xml_node, std::vector< PbCrosswalk > *crosswalks)
static Status ParseClearAreas(const tinyxml2::XMLElement &xml_node, std::vector< PbClearArea > *clear_areas)
static Status ParsePNCJunctions(const tinyxml2::XMLElement &xml_node, std::vector< PbPNCJunction > *pnc_junctions)
static Status ToPassageType(const std::string &type, PbPassageType *passage_type)
static Status ParseStopLines(const tinyxml2::XMLElement &xml_node, std::vector< StopLineInternal > *stop_lines)
static Status ParseParkingSpaces(const tinyxml2::XMLElement &xml_node, std::vector< PbParkingSpace > *parking_spaces)
static Status ParseRSUs(const tinyxml2::XMLElement &xml_node, std::vector< RSUInternal > *rsus)
static Status ParseGeometry(const tinyxml2::XMLElement &xml_node, PbCurveSegment *curve_segment)
static std::string ToUpper(const std::string &s)
static tinyxml2::XMLError QueryStringAttribute(const tinyxml2::XMLElement &xml_node, const std::string &name, std::string *value)
static Status ParseOutline(const tinyxml2::XMLElement &xml_node, PbPolygon *polygon)
#define RETURN_IF_ERROR(expr)
apollo::hdmap::Passage_Type PbPassageType
std::vector< RSUInternal > rsus