diff --git a/generator/routing_index_generator.cpp b/generator/routing_index_generator.cpp index 82ce22dde1..c446e8de10 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -400,6 +400,8 @@ bool BuildCrossMwmSection(string const & path, string const & mwmFile, string co connector.GetExits().size())); } + // We use leaps for cars only. To use leaps for other vehicle types add weights generation + // here and change WorldGraph mode selection rule in IndexRouter::CalculateSubroute. FillWeights(path, mwmFile, country, countryParentNameGetterFn, disableCrossMwmProgress, connectors[static_cast(VehicleType::Car)]); diff --git a/routing/cross_mwm_graph.cpp b/routing/cross_mwm_graph.cpp index 2248d156fa..449942e1c5 100644 --- a/routing/cross_mwm_graph.cpp +++ b/routing/cross_mwm_graph.cpp @@ -44,9 +44,8 @@ void CrossMwmGraph::ClosestSegment::Update(double distM, Segment const & bestSeg } // CrossMwmGraph ---------------------------------------------------------------------------------- -CrossMwmGraph::CrossMwmGraph(shared_ptr numMwmIds, - shared_ptr> numMwmTree, - shared_ptr vehicleModelFactory, +CrossMwmGraph::CrossMwmGraph(shared_ptr numMwmIds, shared_ptr> numMwmTree, + shared_ptr vehicleModelFactory, VehicleType vehicleType, CourntryRectFn const & countryRectFn, Index & index, RoutingIndexManager & indexManager) : m_index(index) @@ -54,7 +53,7 @@ CrossMwmGraph::CrossMwmGraph(shared_ptr numMwmIds, , m_numMwmTree(numMwmTree) , m_vehicleModelFactory(vehicleModelFactory) , m_countryRectFn(countryRectFn) - , m_crossMwmIndexGraph(index, numMwmIds) + , m_crossMwmIndexGraph(index, numMwmIds, vehicleType) , m_crossMwmOsrmGraph(numMwmIds, indexManager) { CHECK(m_numMwmIds, ()); diff --git a/routing/cross_mwm_graph.hpp b/routing/cross_mwm_graph.hpp index 5ce27ac6fd..fd60ad0d18 100644 --- a/routing/cross_mwm_graph.hpp +++ b/routing/cross_mwm_graph.hpp @@ -4,6 +4,7 @@ #include "routing/cross_mwm_osrm_graph.hpp" #include "routing/num_mwm_id.hpp" #include "routing/segment.hpp" +#include "routing/vehicle_mask.hpp" #include "routing_common/vehicle_model.hpp" @@ -33,7 +34,7 @@ public: }; CrossMwmGraph(std::shared_ptr numMwmIds, shared_ptr> numMwmTree, - std::shared_ptr vehicleModelFactory, + std::shared_ptr vehicleModelFactory, VehicleType vehicleType, CourntryRectFn const & countryRectFn, Index & index, RoutingIndexManager & indexManager); diff --git a/routing/cross_mwm_index_graph.hpp b/routing/cross_mwm_index_graph.hpp index f58fb5c857..4e29d8b83e 100644 --- a/routing/cross_mwm_index_graph.hpp +++ b/routing/cross_mwm_index_graph.hpp @@ -25,8 +25,8 @@ class CrossMwmIndexGraph final public: using ReaderSourceFile = ReaderSource; - CrossMwmIndexGraph(Index & index, std::shared_ptr numMwmIds) - : m_index(index), m_numMwmIds(numMwmIds) + CrossMwmIndexGraph(Index & index, std::shared_ptr numMwmIds, VehicleType vehicleType) + : m_index(index), m_numMwmIds(numMwmIds), m_vehicleType(vehicleType) { } @@ -76,12 +76,13 @@ private: if (it == m_connectors.end()) it = m_connectors.emplace(numMwmId, CrossMwmConnector(numMwmId)).first; - fn(VehicleType::Car, it->second, src); + fn(m_vehicleType, it->second, src); return it->second; } Index & m_index; std::shared_ptr m_numMwmIds; + VehicleType m_vehicleType; /// \note |m_connectors| contains cache with transition segments and leap edges. /// Each mwm in |m_connectors| may be in two conditions: diff --git a/routing/index_router.cpp b/routing/index_router.cpp index bc894261e7..a3f341e270 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -502,9 +502,20 @@ IRouter::ResultCode IndexRouter::CalculateSubroute(Checkpoints const & checkpoin return isLastSubroute ? IRouter::EndPointNotFound : IRouter::IntermediatePointNotFound; } - graph.SetMode(AreMwmsNear(startSegment.GetMwmId(), finishSegment.GetMwmId()) - ? WorldGraph::Mode::LeapsIfPossible - : WorldGraph::Mode::LeapsOnly); + // We use leaps for cars only. Other vehicle types do not have weights in their cross-mwm sections. + switch (m_vehicleType) + { + case VehicleType::Pedestrian: + case VehicleType::Bicycle: + graph.SetMode(WorldGraph::Mode::NoLeaps); + break; + case VehicleType::Car: + graph.SetMode(AreMwmsNear(startSegment.GetMwmId(), finishSegment.GetMwmId()) + ? WorldGraph::Mode::LeapsIfPossible + : WorldGraph::Mode::LeapsOnly); + break; + } + LOG(LINFO, ("Routing in mode:", graph.GetMode())); bool const isStartSegmentStrictForward = @@ -659,8 +670,8 @@ IRouter::ResultCode IndexRouter::AdjustRoute(Checkpoints const & checkpoints, WorldGraph IndexRouter::MakeWorldGraph() { WorldGraph graph( - make_unique(m_numMwmIds, m_numMwmTree, m_vehicleModelFactory, m_countryRectFn, - m_index, m_indexManager), + make_unique(m_numMwmIds, m_numMwmTree, m_vehicleModelFactory, m_vehicleType, + m_countryRectFn, m_index, m_indexManager), IndexGraphLoader::Create(m_vehicleType, m_numMwmIds, m_vehicleModelFactory, m_estimator, m_index), m_estimator); return graph;