From a3d1ed83c35e64f4ce16a0af56c55c3c3b27cb54 Mon Sep 17 00:00:00 2001 From: mvglasow Date: Sat, 18 Oct 2025 16:34:32 +0300 Subject: [PATCH] [routing][traffic] Different routing options in navigation and decoder mode Signed-off-by: mvglasow --- libs/routing/index_router.cpp | 7 ++++++- libs/routing/index_router.hpp | 8 ++++++++ libs/traffxml/traff_decoder.cpp | 5 +++++ libs/traffxml/traff_decoder.hpp | 7 +++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libs/routing/index_router.cpp b/libs/routing/index_router.cpp index 643dd61be..c67d9dee0 100644 --- a/libs/routing/index_router.cpp +++ b/libs/routing/index_router.cpp @@ -1091,10 +1091,15 @@ RouterResultCode IndexRouter::AdjustRoute(Checkpoints const & checkpoints, m2::P return RouterResultCode::NoError; } +RoutingOptions IndexRouter::GetRoutingOptions() +{ + return RoutingOptions::LoadCarOptionsFromSettings(); +} + unique_ptr IndexRouter::MakeWorldGraph() { // Use saved routing options for all types (car, bicycle, pedestrian). - RoutingOptions const routingOptions = RoutingOptions::LoadCarOptionsFromSettings(); + RoutingOptions const routingOptions = GetRoutingOptions(); /// @DebugNote // Add avoid roads here for debug purpose. // routingOptions.Add(RoutingOptions::Road::Motorway); diff --git a/libs/routing/index_router.hpp b/libs/routing/index_router.hpp index 1dc6d88f9..4fbcd078f 100644 --- a/libs/routing/index_router.hpp +++ b/libs/routing/index_router.hpp @@ -175,6 +175,14 @@ protected: */ virtual Mode GetMode() { return Mode::Navigation; } + /** + * @brief Returns current routing options. + * + * In this class, the routing options are the one set in the GUI. Subclasses may override this + * method to provide different routing options. + */ + virtual RoutingOptions GetRoutingOptions(); + private: RouterResultCode CalculateSubrouteJointsMode(IndexGraphStarter & starter, RouterDelegate const & delegate, std::shared_ptr const & progress, diff --git a/libs/traffxml/traff_decoder.cpp b/libs/traffxml/traff_decoder.cpp index ad2683356..1c3b82a17 100644 --- a/libs/traffxml/traff_decoder.cpp +++ b/libs/traffxml/traff_decoder.cpp @@ -674,6 +674,11 @@ RoutingTraffDecoder::DecoderRouter::DecoderRouter(CountryParentNameGetterFn cons //, m_directionsEngine(CreateDirectionsEngine(m_vehicleType, m_numMwmIds, m_dataSource)) // TODO we don’t need directions, can we disable that? {} +routing::RoutingOptions RoutingTraffDecoder::DecoderRouter::GetRoutingOptions() +{ + return routing::RoutingOptions(); +} + RoutingTraffDecoder::RoutingTraffDecoder(DataSource & dataSource, CountryInfoGetterFn countryInfoGetter, const CountryParentNameGetterFn & countryParentNameGetter, std::map & messageCache) diff --git a/libs/traffxml/traff_decoder.hpp b/libs/traffxml/traff_decoder.hpp index faf5c51cb..c728f8309 100644 --- a/libs/traffxml/traff_decoder.hpp +++ b/libs/traffxml/traff_decoder.hpp @@ -266,6 +266,13 @@ public: */ IndexRouter::Mode GetMode() { return IndexRouter::Mode::Decoding; } + /** + * @brief Returns current routing options. + * + * For traffic decoding purposes, all roads are allowed. + */ + routing::RoutingOptions GetRoutingOptions() override; + private: };