Apollo 10.0
自动驾驶开放平台
junctions_xml_parser.cc
浏览该文件的文档.
1/* Copyright 2017 The Apollo Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14=========================================================================*/
16
17#include <string>
18
20
21namespace apollo {
22namespace hdmap {
23namespace adapter {
24
25Status JunctionsXmlParser::Parse(const tinyxml2::XMLElement& xml_node,
26 std::vector<JunctionInternal>* junctions) {
27 const tinyxml2::XMLElement* junction_node =
28 xml_node.FirstChildElement("junction");
29 while (junction_node) {
30 // id
31 std::string junction_id;
32 int checker =
33 UtilXmlParser::QueryStringAttribute(*junction_node, "id", &junction_id);
34 if (checker != tinyxml2::XML_SUCCESS) {
35 std::string err_msg = "Error parse junction id";
37 }
38
39 // outline
40 const tinyxml2::XMLElement* sub_node =
41 junction_node->FirstChildElement("outline");
42 if (!sub_node) {
43 std::string err_msg = "Error parse junction outline";
45 }
46
47 PbJunction junction;
48 junction.mutable_id()->set_id(junction_id);
49 PbPolygon* polygon = junction.mutable_polygon();
51
52 JunctionInternal junction_internal;
53 junction_internal.junction = junction;
54
55 // overlap
56 sub_node = junction_node->FirstChildElement("objectOverlapGroup");
57 if (sub_node) {
58 sub_node = sub_node->FirstChildElement("objectReference");
59 while (sub_node) {
60 std::string object_id;
61 checker =
62 UtilXmlParser::QueryStringAttribute(*sub_node, "id", &object_id);
63 if (checker != tinyxml2::XML_SUCCESS) {
64 std::string err_msg = "Error parse junction overlap id";
66 }
67
68 OverlapWithJunction overlap_with_juntion;
69 overlap_with_juntion.object_id = object_id;
70 junction_internal.overlap_with_junctions.push_back(
71 overlap_with_juntion);
72
73 sub_node = sub_node->NextSiblingElement("objectReference");
74 }
75 }
76
77 junctions->push_back(junction_internal);
78 junction_node = junction_node->NextSiblingElement("junction");
79 }
80 return Status::OK();
81}
82
83} // namespace adapter
84} // namespace hdmap
85} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
static Status OK()
generate a success status.
Definition status.h:60
static Status Parse(const tinyxml2::XMLElement &xml_node, std::vector< JunctionInternal > *junctions)
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)
Definition status.h:25
class register implement
Definition arena_queue.h:37
std::vector< OverlapWithJunction > overlap_with_junctions