diff options
author | tatiana-kondakova <tatiana.kondakova@gmail.com> | 2017-08-16 19:49:37 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2017-08-18 13:10:33 +0300 |
commit | 751010b8042ace262b04532be8210b44e6decbae (patch) | |
tree | 9c919ab7b160b4db321bcd5992e633349e5297d7 | |
parent | d0d51150fb3733b0414571e30a14b2abf9373f8a (diff) |
Do not use leaps for pedestrian and bicycle routingpy-modules-0.2.4
-rw-r--r-- | generator/routing_index_generator.cpp | 2 | ||||
-rw-r--r-- | routing/cross_mwm_graph.cpp | 4 | ||||
-rw-r--r-- | routing/cross_mwm_graph.hpp | 3 | ||||
-rw-r--r-- | routing/cross_mwm_index_graph.hpp | 7 | ||||
-rw-r--r-- | routing/index_router.cpp | 21 |
5 files changed, 26 insertions, 11 deletions
diff --git a/generator/routing_index_generator.cpp b/generator/routing_index_generator.cpp index 77a66cfea2..a47ecec627 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -386,6 +386,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, disableCrossMwmProgress, connectors[static_cast<size_t>(VehicleType::Car)]); diff --git a/routing/cross_mwm_graph.cpp b/routing/cross_mwm_graph.cpp index 56507269bd..37f2174516 100644 --- a/routing/cross_mwm_graph.cpp +++ b/routing/cross_mwm_graph.cpp @@ -45,7 +45,7 @@ void CrossMwmGraph::ClosestSegment::Update(double distM, Segment const & bestSeg // CrossMwmGraph ---------------------------------------------------------------------------------- CrossMwmGraph::CrossMwmGraph(shared_ptr<NumMwmIds> numMwmIds, shared_ptr<m4::Tree<NumMwmId>> numMwmTree, - shared_ptr<VehicleModelFactory> vehicleModelFactory, + shared_ptr<VehicleModelFactory> vehicleModelFactory, VehicleType vehicleType, CourntryRectFn const & countryRectFn, Index & index, RoutingIndexManager & indexManager) : m_index(index) @@ -53,7 +53,7 @@ CrossMwmGraph::CrossMwmGraph(shared_ptr<NumMwmIds> numMwmIds, shared_ptr<m4::Tre , 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 cb7deea232..453e0a14a9 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> numMwmIds, shared_ptr<m4::Tree<NumMwmId>> numMwmTree, - std::shared_ptr<VehicleModelFactory> vehicleModelFactory, + std::shared_ptr<VehicleModelFactory> 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<FilesContainerR::TReader>; - CrossMwmIndexGraph(Index & index, std::shared_ptr<NumMwmIds> numMwmIds) - : m_index(index), m_numMwmIds(numMwmIds) + CrossMwmIndexGraph(Index & index, std::shared_ptr<NumMwmIds> 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<NumMwmIds> 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 ebbb7dfb53..cf31ffb906 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -493,9 +493,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 = @@ -650,8 +661,8 @@ IRouter::ResultCode IndexRouter::AdjustRoute(Checkpoints const & checkpoints, WorldGraph IndexRouter::MakeWorldGraph() { WorldGraph graph( - make_unique<CrossMwmGraph>(m_numMwmIds, m_numMwmTree, m_vehicleModelFactory, m_countryRectFn, - m_index, m_indexManager), + make_unique<CrossMwmGraph>(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; |