Using index graph for routing integration tests of bicycle and pedestrian routing.

This commit is contained in:
Vladimir Byko-Ianko 2017-09-12 09:04:55 +03:00 committed by Yuri Gorshenin
parent 2351a7ac25
commit 6a4bb62948
5 changed files with 24 additions and 56 deletions

View file

@ -26,8 +26,8 @@ UNIT_TEST(RussiaMoscowNahimovskyLongRoute)
UNIT_TEST(RussiaDomodedovoSteps)
{
integration::CalculateRouteAndTestRouteLength(
integration::GetBicycleComponents(), MercatorBounds::FromLatLon(55.44020, 37.77409), {0., 0.},
MercatorBounds::FromLatLon(55.43972, 37.77254), 123.0);
integration::GetBicycleComponents(), MercatorBounds::FromLatLon(55.44010, 37.77416), {0., 0.},
MercatorBounds::FromLatLon(55.43975, 37.77272), 123.0);
}
UNIT_TEST(SwedenStockholmCyclewayPriority)

View file

@ -29,6 +29,7 @@ void TestAltitudeOfAllMwmFeatures(string const & countryId, TAltitude const alti
{
Index index;
platform::LocalCountryFile const country = platform::LocalCountryFile::MakeForTesting(countryId);
TEST_NOT_EQUAL(country.GetFiles(), MapOptions::Nothing, (country));
pair<MwmSet::MwmId, MwmSet::RegResult> const regResult = index.RegisterMap(country);
TEST_EQUAL(regResult.second, MwmSet::RegResult::Success, ());

View file

@ -123,7 +123,7 @@ namespace
UNIT_TEST(RussiaMoscowGerPanfilovtsev22SolodchaPravdiRouteTest)
{
integration::CalculateRouteAndTestRouteLength(
integration::GetCarComponents(), {37.409929478750627, 67.644798619710073}, {0., 0.},
integration::GetCarComponents(), {37.409929478750627, 67.644798619710073}, {0., 0.},
{39.836562407458047, 65.774372510437971}, 239426.);
}
@ -172,8 +172,8 @@ namespace
UNIT_TEST(RussiaMoscowStartAtTwowayFeatureTest)
{
integration::CalculateRouteAndTestRouteLength(
integration::GetCarComponents(), MercatorBounds::FromLatLon(55.771, 37.5184), {0., 0.},
MercatorBounds::FromLatLon(55.7718, 37.5178), 147.4);
integration::GetCarComponents(), MercatorBounds::FromLatLon(55.771, 37.5184), {0., 0.},
MercatorBounds::FromLatLon(55.7718, 37.5178), 147.4);
}
// Strange map edits in Africa borders. Routing not linked now.
@ -274,8 +274,8 @@ namespace
UNIT_TEST(RussiaMoscowLenigradskiy39GeroevPanfilovtsev22SubrouteTest)
{
TRouteResult const routeResult = integration::CalculateRoute(
integration::GetCarComponents(), MercatorBounds::FromLatLon(55.7971, 37.53804), {0., 0.},
MercatorBounds::FromLatLon(55.8579, 37.40990));
integration::GetCarComponents(), MercatorBounds::FromLatLon(55.7971, 37.53804), {0., 0.},
MercatorBounds::FromLatLon(55.8579, 37.40990));
IRouter::ResultCode const result = routeResult.second;
TEST_EQUAL(result, IRouter::NoError, ());
@ -290,8 +290,8 @@ namespace
UNIT_TEST(USALosAnglesAriaTwentyninePalmsHighwayTimeTest)
{
TRouteResult const routeResult = integration::CalculateRoute(
integration::GetCarComponents(), MercatorBounds::FromLatLon(34.0739, -115.3212), {0.0, 0.0},
MercatorBounds::FromLatLon(34.0928, -115.5930));
integration::GetCarComponents(), MercatorBounds::FromLatLon(34.0739, -115.3212), {0.0, 0.0},
MercatorBounds::FromLatLon(34.0928, -115.5930));
Route const & route = *routeResult.first;
IRouter::ResultCode const result = routeResult.second;
TEST_EQUAL(result, IRouter::NoError, ());

View file

@ -83,7 +83,8 @@ namespace integration
unique_ptr<IndexRouter> CreateCarRouter(Index & index,
storage::CountryInfoGetter const & infoGetter,
traffic::TrafficCache const & trafficCache,
vector<LocalCountryFile> const & localFiles)
vector<LocalCountryFile> const & localFiles,
VehicleType vehicleType)
{
auto const countryFileGetter = [&infoGetter](m2::PointD const & pt) {
return infoGetter.GetRegionCountryId(pt);
@ -101,8 +102,7 @@ namespace integration
if (mwmId.GetInfo()->GetType() == MwmInfo::COUNTRY && countryFile.GetName() != "minsk-pass")
numMwmIds->RegisterFile(countryFile);
}
auto vehicleType = VehicleType::Car;
auto indexRouter = make_unique<IndexRouter>(vehicleType, CountryParentNameGetterFn(), countryFileGetter,
getMwmRectByName, numMwmIds,
MakeNumMwmTree(*numMwmIds, infoGetter), trafficCache, index);
@ -130,13 +130,13 @@ namespace integration
return unique_ptr<IRouter>(move(router));
}
class CarRouterComponents : public IRouterComponents
class VehicleRouterComponents : public IRouterComponents
{
public:
CarRouterComponents(vector<LocalCountryFile> const & localFiles)
VehicleRouterComponents(vector<LocalCountryFile> const & localFiles, VehicleType vehicleType)
: IRouterComponents(localFiles)
, m_indexRouter(CreateCarRouter(m_featuresFetcher->GetIndex(), *m_infoGetter, m_trafficCache,
localFiles))
localFiles, vehicleType))
{
}
@ -147,40 +147,7 @@ namespace integration
unique_ptr<IndexRouter> m_indexRouter;
};
class PedestrianRouterComponents : public IRouterComponents
{
public:
PedestrianRouterComponents(vector<LocalCountryFile> const & localFiles)
: IRouterComponents(localFiles)
, m_router(CreateAStarRouter(m_featuresFetcher->GetIndex(), *m_infoGetter, localFiles,
CreatePedestrianAStarBidirectionalRouter))
{
}
IRouter * GetRouter() const override { return m_router.get(); }
private:
unique_ptr<IRouter> m_router;
};
class BicycleRouterComponents : public IRouterComponents
{
public:
BicycleRouterComponents(vector<LocalCountryFile> const & localFiles)
: IRouterComponents(localFiles)
, m_router(CreateAStarRouter(m_featuresFetcher->GetIndex(), *m_infoGetter, localFiles,
CreateBicycleAStarBidirectionalRouter))
{
}
IRouter * GetRouter() const override { return m_router.get(); }
private:
unique_ptr<IRouter> m_router;
};
template <typename TRouterComponents>
shared_ptr<TRouterComponents> CreateAllMapsComponents()
shared_ptr<VehicleRouterComponents> CreateAllMapsComponents(VehicleType vehicleType)
{
// Setting stored paths from testingmain.cpp
Platform & pl = GetPlatform();
@ -198,26 +165,26 @@ namespace integration
for (auto & file : localFiles)
file.SyncWithDisk();
ASSERT(!localFiles.empty(), ());
return shared_ptr<TRouterComponents>(new TRouterComponents(localFiles));
return make_shared<VehicleRouterComponents>(localFiles, vehicleType);
}
IRouterComponents & GetCarComponents()
{
static auto const instance = CreateAllMapsComponents<CarRouterComponents>();
static auto const instance = CreateAllMapsComponents(VehicleType::Car);
ASSERT(instance, ());
return *instance;
}
IRouterComponents & GetPedestrianComponents()
{
static auto const instance = CreateAllMapsComponents<PedestrianRouterComponents>();
static auto const instance = CreateAllMapsComponents(VehicleType::Pedestrian);
ASSERT(instance, ());
return *instance;
}
IRouterComponents & GetBicycleComponents()
{
static auto const instance = CreateAllMapsComponents<BicycleRouterComponents>();
static auto const instance = CreateAllMapsComponents(VehicleType::Bicycle);
ASSERT(instance, ());
return *instance;
}

View file

@ -103,9 +103,9 @@ UNIT_TEST(RussiaMoscowSalameiNerisUturnTurnTest)
UNIT_TEST(RussiaMoscowTrikotagniAndPohodniRoundaboutTurnTest)
{
TRouteResult const routeResult = integration::CalculateRoute(
integration::GetCarComponents(),
MercatorBounds::FromLatLon(55.83118, 37.40515), {0., 0.},
MercatorBounds::FromLatLon(55.83384, 37.40521));
integration::GetCarComponents(),
MercatorBounds::FromLatLon(55.83118, 37.40515), {0., 0.},
MercatorBounds::FromLatLon(55.83384, 37.40521));
Route const & route = *routeResult.first;
IRouter::ResultCode const result = routeResult.second;