From 4a5096699e5bc396e027114406613e04b53f4132 Mon Sep 17 00:00:00 2001 From: Manish Date: Wed, 20 Mar 2019 19:02:02 +0100 Subject: [PATCH] Added Map getter for tests --- LibCarla/source/carla/road/Map.h | 4 ++++ LibCarla/source/test/client/test_road.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/LibCarla/source/carla/road/Map.h b/LibCarla/source/carla/road/Map.h index 9e3526dbc..9670ea99a 100644 --- a/LibCarla/source/carla/road/Map.h +++ b/LibCarla/source/carla/road/Map.h @@ -99,6 +99,10 @@ namespace road { /// map. The waypoints are placed at the entrance of each lane. std::vector> GenerateTopology() const; + MapData &GetMap() { + return _data; + } + private: const Lane *GetLane(Waypoint waypoint) const; diff --git a/LibCarla/source/test/client/test_road.cpp b/LibCarla/source/test/client/test_road.cpp index 9faf504b0..ee184590d 100644 --- a/LibCarla/source/test/client/test_road.cpp +++ b/LibCarla/source/test/client/test_road.cpp @@ -38,7 +38,7 @@ void test_geometry(const pugi::xml_document &xml, boost::optional& map) size_t total_geometries = 0; for (pugi::xml_node geometry_node : plan_view_nodes.children("geometry")){ float s = geometry_node.attribute("s").as_float(); - auto geometry = map->_data.GetRoad(road_id)->GetInfo(s); + auto geometry = map->GetMap().GetRoad(road_id)->GetInfo(s); if (geometry != nullptr) ++total_geometries; } @@ -55,7 +55,7 @@ void test_roads(const pugi::xml_document &xml, boost::optional& map) // Check total Roads auto roads_parser = open_drive_node.children("road"); size_t total_roads_parser = std::distance(roads_parser.begin(), roads_parser.end()); - size_t total_roads = map->_data.GetRoads().size(); + size_t total_roads = map->GetMap().GetRoads().size(); ASSERT_EQ(total_roads, total_roads_parser); for (pugi::xml_node road_node : roads_parser) { @@ -66,7 +66,7 @@ void test_roads(const pugi::xml_document &xml, boost::optional& map) // Check total Lane Sections auto lane_sections_parser = lanes_node.children("laneSection"); size_t total_lane_sections_parser = std::distance(lane_sections_parser.begin(), lane_sections_parser.end()); - size_t total_lane_sections = map->_data.GetRoad(road_id)->GetLaneSections().size(); + size_t total_lane_sections = map->GetMap().GetRoad(road_id)->GetLaneSections().size(); ASSERT_EQ(total_lane_sections, total_lane_sections_parser); for (pugi::xml_node lane_section_node : lane_sections_parser) { @@ -74,8 +74,8 @@ void test_roads(const pugi::xml_document &xml, boost::optional& map) // Check total Lanes float s = lane_section_node.attribute("s").as_float(); - auto ls_begin = map->_data.GetRoad(road_id)->GetLaneSectionsAt(s).begin(); - auto ls_end = map->_data.GetRoad(road_id)->GetLaneSectionsAt(s).end(); + auto ls_begin = map->GetMap().GetRoad(road_id)->GetLaneSectionsAt(s).begin(); + auto ls_end = map->GetMap().GetRoad(road_id)->GetLaneSectionsAt(s).end(); size_t total_lanes = 0u; for (auto& it = ls_begin; it != ls_end; ++it) { total_lanes = it->GetLanes().size(); @@ -98,7 +98,7 @@ void test_junctions(const pugi::xml_document &xml, boost::optional& map) pugi::xml_node open_drive_node = xml.child("OpenDRIVE"); // Check total number of junctions - auto& junctions = map->_data.GetJunctions(); + auto& junctions = map->GetMap().GetJunctions(); size_t total_junctions_parser = std::distance(open_drive_node.children("junction").begin(), open_drive_node.children("junction").end()); ASSERT_EQ(junctions.size(), total_junctions_parser); @@ -132,7 +132,7 @@ void print_roads(boost::optional& map) { std::ofstream file; file.open("roads.txt", std::ios::out | std::ios::trunc); - for (auto &road : map->_data.GetRoads()) { + for (auto &road : map->GetMap().GetRoads()) { file << "Road: " << road.second.GetId() << std::endl; for (auto §ion : road.second.GetLaneSections()) { file << " Section: " << section.GetDistance() << std::endl; @@ -184,7 +184,7 @@ void test_junctions(boost::optional& map) { Junction junction_1 {80u, {connection} }; - auto& junctions = map->_data.GetJunctions(); + auto& junctions = map->GetMap().GetJunctions(); for (auto& junction : junctions) { ASSERT_EQ(junction.second.GetId(), junction_1.id); ASSERT_EQ(junction.second.GetConnection(1)->id, 1u);