diff --git a/routing/routing_benchmarks/CMakeLists.txt b/routing/routing_benchmarks/CMakeLists.txt index 510db77709..751a3b701f 100644 --- a/routing/routing_benchmarks/CMakeLists.txt +++ b/routing/routing_benchmarks/CMakeLists.txt @@ -2,6 +2,8 @@ project(routing_benchmarks) set( SRC + ../routing_integration_tests/routing_test_tools.cpp + ../routing_integration_tests/routing_test_tools.hpp bicycle_routing_tests.cpp helpers.cpp helpers.hpp @@ -16,9 +18,12 @@ omim_link_libraries( routing traffic routing_common + transit search storage + mwm_diff indexer + traffic platform editor oauthcpp @@ -28,6 +33,7 @@ omim_link_libraries( base jansson protobuf + bsdiff stats_client succinct pugixml diff --git a/routing/routing_benchmarks/helpers.cpp b/routing/routing_benchmarks/helpers.cpp index 10944754aa..a2d7c6c2cb 100644 --- a/routing/routing_benchmarks/helpers.cpp +++ b/routing/routing_benchmarks/helpers.cpp @@ -7,6 +7,8 @@ #include "routing/route.hpp" #include "routing/router_delegate.hpp" +#include "routing_integration_tests/routing_test_tools.hpp" + #include "indexer/classificator_loader.hpp" #include "indexer/mwm_set.hpp" @@ -18,9 +20,12 @@ #include "base/logging.hpp" #include "base/math.hpp" +#include "base/stl_add.hpp" #include "base/timer.hpp" -#include "std/limits.hpp" +#include + +using namespace std; namespace { @@ -58,23 +63,22 @@ m2::PointD GetPointOnEdge(routing::Edge const & e, double posAlong) } // namespace RoutingTest::RoutingTest(routing::IRoadGraph::Mode mode, set const & neededMaps) - : m_mode(mode) + : m_mode(mode), m_neededMaps(neededMaps), m_numMwmIds(my::make_unique()) { classificator::Load(); Platform & platform = GetPlatform(); m_cig = storage::CountryInfoReader::CreateCountryInfoReader(platform); - vector localFiles; - platform::FindAllLocalMapsAndCleanup(numeric_limits::max(), localFiles); + platform::FindAllLocalMapsAndCleanup(numeric_limits::max(), m_localFiles); set registeredMaps; - for (auto const & localFile : localFiles) + for (auto const & localFile : m_localFiles) { m_numMwmIds->RegisterFile(localFile.GetCountryFile()); auto const & name = localFile.GetCountryName(); - if (neededMaps.count(name) == 0) + if (m_neededMaps.count(name) == 0) continue; UNUSED_VALUE(m_index.RegisterMap(localFile)); @@ -87,9 +91,9 @@ RoutingTest::RoutingTest(routing::IRoadGraph::Mode mode, set const & nee registeredMaps.insert(name); } - if (registeredMaps != neededMaps) + if (registeredMaps != m_neededMaps) { - for (auto const & file : neededMaps) + for (auto const & file : m_neededMaps) { if (registeredMaps.count(file) == 0) LOG(LERROR, ("Can't find map:", file)); @@ -103,22 +107,21 @@ void RoutingTest::TestRouters(m2::PointD const & startPos, m2::PointD const & fi // Find route by A*-bidirectional algorithm. routing::Route routeFoundByAstarBidirectional(""); { - auto router = - CreateRouter("test-astar-bidirectional"); + auto router = CreateRouter("test-astar-bidirectional"); TestRouter(*router, startPos, finalPos, routeFoundByAstarBidirectional); } // Find route by A* algorithm. routing::Route routeFoundByAstar(""); { - auto router = CreateRouter("test-astar"); + auto router = CreateRouter("test-astar"); TestRouter(*router, startPos, finalPos, routeFoundByAstar); } double constexpr kEpsilon = 1e-6; TEST(my::AlmostEqualAbs(routeFoundByAstar.GetTotalDistanceMeters(), - routeFoundByAstarBidirectional.GetTotalDistanceMeters(), kEpsilon), - ()); + routeFoundByAstarBidirectional.GetTotalDistanceMeters(), kEpsilon), + ()); } void RoutingTest::TestTwoPointsOnFeature(m2::PointD const & startPos, m2::PointD const & finalPos) @@ -139,6 +142,21 @@ void RoutingTest::TestTwoPointsOnFeature(m2::PointD const & startPos, m2::PointD TestRouters(startPosOnFeature, finalPosOnFeature); } +unique_ptr RoutingTest::CreateRouter(string const & name) +{ + vector neededLocalFiles; + neededLocalFiles.reserve(m_neededMaps.size()); + for (auto const & lf : m_localFiles) + { + if (m_neededMaps.count(lf.GetCountryName()) != 0) + neededLocalFiles.push_back(lf); + } + + unique_ptr router = integration::CreateVehicleRouter( + m_index, *m_cig, m_trafficCache, neededLocalFiles, routing::VehicleType::Pedestrian); + return router; +} + void RoutingTest::GetNearestEdges(m2::PointD const & pt, vector> & edges) { diff --git a/routing/routing_benchmarks/helpers.hpp b/routing/routing_benchmarks/helpers.hpp index 1a3f7120d8..c46c6a18d3 100644 --- a/routing/routing_benchmarks/helpers.hpp +++ b/routing/routing_benchmarks/helpers.hpp @@ -1,29 +1,31 @@ #pragma once +#include "routing/index_router.hpp" #include "routing/road_graph.hpp" #include "routing/router.hpp" -#include "routing/road_graph_router.hpp" +#include "routing/vehicle_mask.hpp" #include "routing_common/num_mwm_id.hpp" #include "routing_common/vehicle_model.hpp" -#include "indexer/index.hpp" - #include "storage/country_info_getter.hpp" +#include "traffic/traffic_cache.hpp" + +#include "indexer/index.hpp" + #include "geometry/point2d.hpp" -#include "std/set.hpp" -#include "std/shared_ptr.hpp" -#include "std/string.hpp" -#include "std/unique_ptr.hpp" -#include "std/utility.hpp" -#include "std/vector.hpp" +#include +#include +#include +#include +#include class RoutingTest { public: - RoutingTest(routing::IRoadGraph::Mode mode, set const & neededMaps); + RoutingTest(routing::IRoadGraph::Mode mode, std::set const & neededMaps); virtual ~RoutingTest() = default; @@ -31,29 +33,22 @@ public: void TestTwoPointsOnFeature(m2::PointD const & startPos, m2::PointD const & finalPos); protected: - virtual unique_ptr CreateDirectionsEngine( - shared_ptr numMwmIds) = 0; - virtual unique_ptr CreateModelFactory() = 0; - - template - unique_ptr CreateRouter(string const & name) - { - auto getter = [&](m2::PointD const & pt) { return m_cig->GetRegionCountryId(pt); }; - unique_ptr algorithm(new Algorithm()); - unique_ptr router( - new routing::RoadGraphRouter(name, m_index, getter, m_mode, CreateModelFactory(), - move(algorithm), CreateDirectionsEngine(m_numMwmIds))); - return router; - } + virtual std::unique_ptr CreateDirectionsEngine( + std::shared_ptr numMwmIds) = 0; + virtual std::unique_ptr CreateModelFactory() = 0; + std::unique_ptr CreateRouter(std::string const & name); void GetNearestEdges(m2::PointD const & pt, - vector> & edges); + std::vector> & edges); routing::IRoadGraph::Mode const m_mode; Index m_index; + traffic::TrafficCache m_trafficCache; - shared_ptr m_numMwmIds; - unique_ptr m_cig; + std::vector m_localFiles; + std::set const & m_neededMaps; + std::shared_ptr m_numMwmIds; + std::unique_ptr m_cig; }; template @@ -85,13 +80,13 @@ public: SimplifiedModelFactory() : m_model(make_shared()) {} // VehicleModelFactoryInterface overrides: - shared_ptr GetVehicleModel() const override { return m_model; } - shared_ptr GetVehicleModelForCountry( - string const & /*country*/) const override + std::shared_ptr GetVehicleModel() const override { return m_model; } + std::shared_ptr GetVehicleModelForCountry( + std::string const & /* country */) const override { return m_model; } private: - shared_ptr const m_model; + std::shared_ptr const m_model; }; diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index 6482ed23e2..aabacbd439 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -104,6 +104,7 @@ namespace integration { auto const & countryFile = f.GetCountryFile(); auto const mwmId = index.GetMwmIdByCountryFile(countryFile); + CHECK(mwmId.IsAlive(), ()); if (mwmId.GetInfo()->GetType() == MwmInfo::COUNTRY && countryFile.GetName() != "minsk-pass") numMwmIds->RegisterFile(countryFile); }