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:
authorkshalnev <k.shalnev@gmail.com>2016-01-23 11:03:10 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:15:17 +0300
commita4ffb95e499ede06efced7636773d51f9820ce17 (patch)
treea30aff7b524f740194772154dbe5558fac1ffd62 /pedestrian_routing_tests
parentfc55aef503176f1c97b6c35a3ceb3b9a0c148886 (diff)
[old map downloader] Fixed pedestrian rounting tests
Diffstat (limited to 'pedestrian_routing_tests')
-rw-r--r--pedestrian_routing_tests/pedestrian_routing_tests.cpp85
1 files changed, 62 insertions, 23 deletions
diff --git a/pedestrian_routing_tests/pedestrian_routing_tests.cpp b/pedestrian_routing_tests/pedestrian_routing_tests.cpp
index 7b4e6c86f6..e815479620 100644
--- a/pedestrian_routing_tests/pedestrian_routing_tests.cpp
+++ b/pedestrian_routing_tests/pedestrian_routing_tests.cpp
@@ -9,21 +9,45 @@
#include "routing/pedestrian_model.hpp"
#include "routing/router_delegate.hpp"
+#include "storage/country_info_getter.hpp"
+
+#include "platform/platform.hpp"
+
#include "base/logging.hpp"
#include "base/macros.hpp"
#include "base/timer.hpp"
+#include "std/set.hpp"
#include "std/string.hpp"
#include "std/utility.hpp"
#include "std/vector.hpp"
+#include "defines.hpp"
+
using platform::CountryFile;
using platform::LocalCountryFile;
namespace
{
-string const MAP_NAME = "UK_England";
+// Test preconditions:
+// Files from the kMapFiles set with '.mwm' extension must be placed in ./omim/data folder
+
+set<string> const kMapFiles =
+{
+ "UK_England_East Midlands",
+ "UK_England_East of England_Essex",
+ "UK_England_East of England_Norfolk",
+ "UK_England_Greater London",
+ "UK_England_North East England",
+ "UK_England_North West England",
+ "UK_England_South East_Brighton",
+ "UK_England_South East_Oxford",
+ "UK_England_South West England_Bristol",
+ "UK_England_South West England_Cornwall",
+ "UK_England_West Midlands",
+ "UK_England_Yorkshire and the Humber"
+};
// Since for test purposes we compare routes lengths to check algorithms consistency,
// we should use simplified pedestrian model, where all available edges have max speed
@@ -58,21 +82,28 @@ private:
shared_ptr<routing::IVehicleModel> const m_model;
};
-unique_ptr<routing::IRouter> CreatePedestrianAStarTestRouter(Index & index)
+unique_ptr<storage::CountryInfoGetter> CreateCountryInfoGetter()
+{
+ Platform & platform = GetPlatform();
+ return unique_ptr<storage::CountryInfoGetter>(new storage::CountryInfoReader(platform.GetReader(PACKED_POLYGONS_MIGRATE_FILE),
+ platform.GetReader(COUNTRIES_MIGRATE_FILE)));
+}
+
+unique_ptr<routing::IRouter> CreatePedestrianAStarTestRouter(Index & index, storage::CountryInfoGetter & cig)
{
- auto UKGetter = [](m2::PointD const & /* point */){return "UK_England";};
+ auto fnUKGetter = [&](m2::PointD const & pt) { return cig.GetRegionFile(pt); };
unique_ptr<routing::IVehicleModelFactory> vehicleModelFactory(new SimplifiedPedestrianModelFactory());
unique_ptr<routing::IRoutingAlgorithm> algorithm(new routing::AStarRoutingAlgorithm());
- unique_ptr<routing::IRouter> router(new routing::RoadGraphRouter("test-astar-pedestrian", index, UKGetter, move(vehicleModelFactory), move(algorithm), nullptr));
+ unique_ptr<routing::IRouter> router(new routing::RoadGraphRouter("test-astar-pedestrian", index, fnUKGetter, move(vehicleModelFactory), move(algorithm), nullptr));
return router;
}
-unique_ptr<routing::IRouter> CreatePedestrianAStarBidirectionalTestRouter(Index & index)
+unique_ptr<routing::IRouter> CreatePedestrianAStarBidirectionalTestRouter(Index & index, storage::CountryInfoGetter & cig)
{
- auto UKGetter = [](m2::PointD const & /* point */){return "UK_England";};
+ auto fnUKGetter = [&](m2::PointD const & pt) { return cig.GetRegionFile(pt); };
unique_ptr<routing::IVehicleModelFactory> vehicleModelFactory(new SimplifiedPedestrianModelFactory());
unique_ptr<routing::IRoutingAlgorithm> algorithm(new routing::AStarBidirectionalRoutingAlgorithm());
- unique_ptr<routing::IRouter> router(new routing::RoadGraphRouter("test-astar-bidirectional-pedestrian", index, UKGetter, move(vehicleModelFactory), move(algorithm), nullptr));
+ unique_ptr<routing::IRouter> router(new routing::RoadGraphRouter("test-astar-bidirectional-pedestrian", index, fnUKGetter, move(vehicleModelFactory), move(algorithm), nullptr));
return router;
}
@@ -112,14 +143,16 @@ void TestRouter(routing::IRouter & router, m2::PointD const & startPos, m2::Poin
void TestRouters(Index & index, m2::PointD const & startPos, m2::PointD const & finalPos)
{
+ auto cig = CreateCountryInfoGetter();
+
// find route by A*-bidirectional algorithm
routing::Route routeFoundByAstarBidirectional("");
- unique_ptr<routing::IRouter> router = CreatePedestrianAStarBidirectionalTestRouter(index);
+ unique_ptr<routing::IRouter> router = CreatePedestrianAStarBidirectionalTestRouter(index, *cig.get());
TestRouter(*router, startPos, finalPos, routeFoundByAstarBidirectional);
// find route by A* algorithm
routing::Route routeFoundByAstar("");
- router = CreatePedestrianAStarTestRouter(index);
+ router = CreatePedestrianAStarTestRouter(index, *cig.get());
TestRouter(*router, startPos, finalPos, routeFoundByAstar);
@@ -132,14 +165,17 @@ void TestTwoPointsOnFeature(m2::PointD const & startPos, m2::PointD const & fina
{
classificator::Load();
- CountryFile countryFile(MAP_NAME);
- LocalCountryFile localFile = LocalCountryFile::MakeForTesting(MAP_NAME);
-
Index index;
- UNUSED_VALUE(index.RegisterMap(localFile));
- TEST(index.IsLoaded(countryFile), ());
- MwmSet::MwmId const id = index.GetMwmIdByCountryFile(countryFile);
- TEST(id.IsAlive(), ());
+
+ for (auto const & mapFile : kMapFiles)
+ {
+ CountryFile countryFile(mapFile);
+ LocalCountryFile localFile = LocalCountryFile::MakeForTesting(mapFile);
+ UNUSED_VALUE(index.RegisterMap(localFile));
+ TEST(index.IsLoaded(countryFile), ());
+ MwmSet::MwmId const id = index.GetMwmIdByCountryFile(countryFile);
+ TEST(id.IsAlive(), ());
+ }
vector<pair<routing::Edge, m2::PointD>> startEdges;
GetNearestPedestrianEdges(index, startPos, startEdges);
@@ -161,14 +197,17 @@ void TestTwoPoints(m2::PointD const & startPos, m2::PointD const & finalPos)
{
classificator::Load();
- CountryFile countryFile(MAP_NAME);
- LocalCountryFile localFile = LocalCountryFile::MakeForTesting(MAP_NAME);
-
Index index;
- UNUSED_VALUE(index.RegisterMap(localFile));
- TEST(index.IsLoaded(countryFile), ());
- MwmSet::MwmId const id = index.GetMwmIdByCountryFile(countryFile);
- TEST(id.IsAlive(), ());
+
+ for (auto const & mapFile : kMapFiles)
+ {
+ CountryFile countryFile(mapFile);
+ LocalCountryFile localFile = LocalCountryFile::MakeForTesting(mapFile);
+ UNUSED_VALUE(index.RegisterMap(localFile));
+ TEST(index.IsLoaded(countryFile), ());
+ MwmSet::MwmId const id = index.GetMwmIdByCountryFile(countryFile);
+ TEST(id.IsAlive(), ());
+ }
TestRouters(index, startPos, finalPos);
}