| 115 | } |
| 116 | |
| 117 | static void test_roads(const pugi::xml_document &xml, boost::optional<Map>& map) { |
| 118 | pugi::xml_node open_drive_node = xml.child("OpenDRIVE"); |
| 119 | |
| 120 | // Check total Roads |
| 121 | auto roads_parser = open_drive_node.children("road"); |
| 122 | auto total_roads_parser = std::distance(roads_parser.begin(), roads_parser.end()); |
| 123 | auto total_roads = map->GetMap().GetRoads().size(); |
| 124 | ASSERT_EQ(total_roads, total_roads_parser); |
| 125 | |
| 126 | for (pugi::xml_node road_node : roads_parser) { |
| 127 | RoadId road_id = road_node.attribute("id").as_uint(); |
| 128 | |
| 129 | for (pugi::xml_node lanes_node : road_node.children("lanes")) { |
| 130 | |
| 131 | // Check total Lane Sections |
| 132 | auto lane_sections_parser = lanes_node.children("laneSection"); |
| 133 | auto total_lane_sections_parser = std::distance(lane_sections_parser.begin(), lane_sections_parser.end()); |
| 134 | auto total_lane_sections = map->GetMap().GetRoad(road_id).GetLaneSections().size(); |
| 135 | ASSERT_EQ(total_lane_sections, total_lane_sections_parser); |
| 136 | |
| 137 | for (pugi::xml_node lane_section_node : lane_sections_parser) { |
| 138 | |
| 139 | // Check total Lanes |
| 140 | const double s = lane_section_node.attribute("s").as_double(); |
| 141 | auto lane_section = map->GetMap().GetRoad(road_id).GetLaneSectionsAt(s); |
| 142 | size_t total_lanes = 0u; |
| 143 | for (auto it = lane_section.begin(); it != lane_section.end(); ++it) { |
| 144 | total_lanes = it->GetLanes().size(); |
| 145 | } |
| 146 | auto left_nodes = lane_section_node.child("left").children("lane"); |
| 147 | auto center_nodes = lane_section_node.child("center").children("lane"); |
| 148 | auto right_nodes = lane_section_node.child("right").children("lane"); |
| 149 | auto total_lanes_parser = std::distance(left_nodes.begin(), left_nodes.end()); |
| 150 | total_lanes_parser += std::distance(right_nodes.begin(), right_nodes.end()); |
| 151 | total_lanes_parser += std::distance(center_nodes.begin(), center_nodes.end()); |
| 152 | |
| 153 | ASSERT_EQ(total_lanes, total_lanes_parser); |
| 154 | |
| 155 | |
| 156 | auto total_road_mark = 0; |
| 157 | auto total_road_mark_parser = 0; |
| 158 | for (auto it = lane_section.begin(); it != lane_section.end(); ++it) { |
| 159 | auto total_left = get_total_road_marks(left_nodes, *it); |
| 160 | auto total_center = get_total_road_marks(center_nodes, *it); |
| 161 | auto total_right = get_total_road_marks(right_nodes, *it); |
| 162 | total_road_mark = total_left.first + total_center.first + total_right.first; |
| 163 | total_road_mark_parser = total_left.first + total_center.first + total_right.first; |
| 164 | } |
| 165 | ASSERT_EQ(total_road_mark, total_road_mark_parser); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // Junctions |
| 172 | static void test_junctions(const pugi::xml_document &xml, boost::optional<Map>& map) { |
no test coverage detected