24bool IsRoadBelongToJunction(
const std::string& road_id) {
26 return road_id !=
"-1";
35 std::vector<RoadInternal>* roads) {
38 auto road_node = xml_node.FirstChildElement(
"road");
42 std::string junction_id;
46 if (checker != tinyxml2::XML_SUCCESS) {
47 std::string err_msg =
"Error parsing road attributes";
52 road_internal.
id = id;
53 road_internal.
road.mutable_id()->set_id(
id);
54 if (IsRoadBelongToJunction(junction_id)) {
55 road_internal.
road.mutable_junction_id()->set_id(junction_id);
60 if (checker != tinyxml2::XML_SUCCESS) {
66 road_internal.
road.set_type(pb_road_type);
73 Parse_road_objects(*road_node, &road_internal);
75 Parse_road_signals(*road_node, &road_internal);
77 roads->push_back(road_internal);
78 road_node = road_node->NextSiblingElement(
"road");
84void RoadsXmlParser::Parse_road_objects(
const tinyxml2::XMLElement& xml_node,
86 CHECK_NOTNULL(road_info);
89 auto sub_node = xml_node.FirstChildElement(
"objects");
90 if (sub_node !=
nullptr) {
106void RoadsXmlParser::Parse_road_signals(
const tinyxml2::XMLElement& xml_node,
107 RoadInternal* road_info) {
108 CHECK_NOTNULL(road_info);
111 auto sub_node = xml_node.FirstChildElement(
"signals");
112 if (sub_node !=
nullptr) {
122Status RoadsXmlParser::to_pb_road_type(
const std::string& type,
124 CHECK_NOTNULL(pb_road_type);
128 if (upper_type ==
"UNKNOWN") {
130 }
else if (upper_type ==
"HIGHWAY") {
132 }
else if (upper_type ==
"CITYROAD") {
134 }
else if (upper_type ==
"PARK") {
137 std::string err_msg =
"Error or unsupport road type";
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
static Status Parse(const tinyxml2::XMLElement &xml_node, const std::string &road_id, std::vector< RoadSectionInternal > *sections)
static Status ParseSpeedBumps(const tinyxml2::XMLElement &xml_node, std::vector< PbSpeedBump > *speed_bumps)
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 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 Parse(const tinyxml2::XMLElement &xml_node, std::vector< RoadInternal > *roads)
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)
static Status ParseTrafficLights(const tinyxml2::XMLElement &xml_node, std::vector< TrafficLightInternal > *traffic_lights)
static std::string ToUpper(const std::string &s)
static tinyxml2::XMLError QueryStringAttribute(const tinyxml2::XMLElement &xml_node, const std::string &name, std::string *value)
#define RETURN_IF_ERROR(expr)
apollo::hdmap::Road_Type PbRoadType
std::vector< PbPNCJunction > pnc_junctions
std::vector< PbClearArea > clear_areas
std::vector< RoadSectionInternal > sections
std::vector< PbSpeedBump > speed_bumps
std::vector< PbParkingSpace > parking_spaces
std::vector< StopLineInternal > stop_lines
std::vector< PbCrosswalk > crosswalks