Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2018-01-26 15:07:42 +0300
committermpimenov <mpimenov@users.noreply.github.com>2018-02-19 20:26:27 +0300
commit4a8a03815ce10f3364aaa3d06d0913bd2f15655c (patch)
treee9174c407e57a634adfaaa65f74625728cd7f3f7 /routing
parentb7b60eef4d4ebc335cbfadd7f8bd168665cf523a (diff)
Fixing routing_benchmarks and using IndexRouter instead of RoadGraphRouter in it.
Diffstat (limited to 'routing')
-rw-r--r--routing/routing_benchmarks/CMakeLists.txt6
-rw-r--r--routing/routing_benchmarks/helpers.cpp44
-rw-r--r--routing/routing_benchmarks/helpers.hpp57
-rw-r--r--routing/routing_integration_tests/routing_test_tools.cpp1
4 files changed, 64 insertions, 44 deletions
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 <limits>
+
+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<string> const & neededMaps)
- : m_mode(mode)
+ : m_mode(mode), m_neededMaps(neededMaps), m_numMwmIds(my::make_unique<routing::NumMwmIds>())
{
classificator::Load();
Platform & platform = GetPlatform();
m_cig = storage::CountryInfoReader::CreateCountryInfoReader(platform);
- vector<platform::LocalCountryFile> localFiles;
- platform::FindAllLocalMapsAndCleanup(numeric_limits<int64_t>::max(), localFiles);
+ platform::FindAllLocalMapsAndCleanup(numeric_limits<int64_t>::max(), m_localFiles);
set<string> 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<string> 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<routing::AStarBidirectionalRoutingAlgorithm>("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<routing::AStarRoutingAlgorithm>("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<routing::IRouter> RoutingTest::CreateRouter(string const & name)
+{
+ vector<platform::LocalCountryFile> 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<routing::IRouter> router = integration::CreateVehicleRouter(
+ m_index, *m_cig, m_trafficCache, neededLocalFiles, routing::VehicleType::Pedestrian);
+ return router;
+}
+
void RoutingTest::GetNearestEdges(m2::PointD const & pt,
vector<pair<routing::Edge, routing::Junction>> & 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 <memory>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
class RoutingTest
{
public:
- RoutingTest(routing::IRoadGraph::Mode mode, set<string> const & neededMaps);
+ RoutingTest(routing::IRoadGraph::Mode mode, std::set<std::string> const & neededMaps);
virtual ~RoutingTest() = default;
@@ -31,29 +33,22 @@ public:
void TestTwoPointsOnFeature(m2::PointD const & startPos, m2::PointD const & finalPos);
protected:
- virtual unique_ptr<routing::IDirectionsEngine> CreateDirectionsEngine(
- shared_ptr<routing::NumMwmIds> numMwmIds) = 0;
- virtual unique_ptr<routing::VehicleModelFactoryInterface> CreateModelFactory() = 0;
-
- template <typename Algorithm>
- unique_ptr<routing::IRouter> CreateRouter(string const & name)
- {
- auto getter = [&](m2::PointD const & pt) { return m_cig->GetRegionCountryId(pt); };
- unique_ptr<routing::IRoutingAlgorithm> algorithm(new Algorithm());
- unique_ptr<routing::IRouter> router(
- new routing::RoadGraphRouter(name, m_index, getter, m_mode, CreateModelFactory(),
- move(algorithm), CreateDirectionsEngine(m_numMwmIds)));
- return router;
- }
+ virtual std::unique_ptr<routing::IDirectionsEngine> CreateDirectionsEngine(
+ std::shared_ptr<routing::NumMwmIds> numMwmIds) = 0;
+ virtual std::unique_ptr<routing::VehicleModelFactoryInterface> CreateModelFactory() = 0;
+ std::unique_ptr<routing::IRouter> CreateRouter(std::string const & name);
void GetNearestEdges(m2::PointD const & pt,
- vector<pair<routing::Edge, routing::Junction>> & edges);
+ std::vector<std::pair<routing::Edge, routing::Junction>> & edges);
routing::IRoadGraph::Mode const m_mode;
Index m_index;
+ traffic::TrafficCache m_trafficCache;
- shared_ptr<routing::NumMwmIds> m_numMwmIds;
- unique_ptr<storage::CountryInfoGetter> m_cig;
+ std::vector<platform::LocalCountryFile> m_localFiles;
+ std::set<std::string> const & m_neededMaps;
+ std::shared_ptr<routing::NumMwmIds> m_numMwmIds;
+ std::unique_ptr<storage::CountryInfoGetter> m_cig;
};
template <typename Model>
@@ -85,13 +80,13 @@ public:
SimplifiedModelFactory() : m_model(make_shared<SimplifiedModel>()) {}
// VehicleModelFactoryInterface overrides:
- shared_ptr<routing::VehicleModelInterface> GetVehicleModel() const override { return m_model; }
- shared_ptr<routing::VehicleModelInterface> GetVehicleModelForCountry(
- string const & /*country*/) const override
+ std::shared_ptr<routing::VehicleModelInterface> GetVehicleModel() const override { return m_model; }
+ std::shared_ptr<routing::VehicleModelInterface> GetVehicleModelForCountry(
+ std::string const & /* country */) const override
{
return m_model;
}
private:
- shared_ptr<SimplifiedModel> const m_model;
+ std::shared_ptr<SimplifiedModel> 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);
}