diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index d76e6ed519..d1d040e85f 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -360,6 +360,8 @@ void RoutingManager::SetRouterImpl(RouterType type) VehicleType const vehicleType = GetVehicleType(type); + m_loadAltitudes = vehicleType != VehicleType::Car; + auto const countryFileGetter = [this](m2::PointD const & p) -> string { // TODO (@gorshenin): fix CountryInfoGetter to return CountryFile // instances instead of plain strings. @@ -385,7 +387,7 @@ void RoutingManager::SetRouterImpl(RouterType type) }; auto fetcher = make_unique(countryFileGetter, localFileChecker); - auto router = make_unique(vehicleType, m_callbacks.m_countryParentNameGetterFn, + auto router = make_unique(vehicleType, m_loadAltitudes, m_callbacks.m_countryParentNameGetterFn, countryFileGetter, getMwmRectByName, numMwmIds, MakeNumMwmTree(*numMwmIds, m_callbacks.m_countryInfoGetter()), m_routingSession, index); @@ -913,7 +915,10 @@ void RoutingManager::SetDrapeEngine(ref_ptr engine, bool is3dAl } } -bool RoutingManager::HasRouteAltitude() const { return m_routingSession.HasRouteAltitude(); } +bool RoutingManager::HasRouteAltitude() const +{ + return m_loadAltitudes && m_routingSession.HasRouteAltitude(); +} bool RoutingManager::GenerateRouteAltitudeChart(uint32_t width, uint32_t height, vector & imageRGBAData, diff --git a/map/routing_manager.hpp b/map/routing_manager.hpp index 9b7bf3e21b..bd501817f8 100644 --- a/map/routing_manager.hpp +++ b/map/routing_manager.hpp @@ -279,6 +279,7 @@ private: Callbacks m_callbacks; df::DrapeEngineSafePtr m_drapeEngine; routing::RouterType m_currentRouterType = routing::RouterType::Count; + bool m_loadAltitudes = false; routing::RoutingSession m_routingSession; Delegate & m_delegate; tracking::Reporter m_trackingReporter; diff --git a/routing/index_graph_loader.cpp b/routing/index_graph_loader.cpp index e50fd1832e..26e70e7e82 100644 --- a/routing/index_graph_loader.cpp +++ b/routing/index_graph_loader.cpp @@ -18,7 +18,7 @@ using namespace std; class IndexGraphLoaderImpl final : public IndexGraphLoader { public: - IndexGraphLoaderImpl(VehicleType vehicleType, shared_ptr numMwmIds, + IndexGraphLoaderImpl(VehicleType vehicleType, bool loadAltitudes, shared_ptr numMwmIds, shared_ptr vehicleModelFactory, shared_ptr estimator, Index & index); @@ -30,6 +30,7 @@ private: IndexGraph & Load(NumMwmId mwmId); VehicleMask m_vehicleMask; + bool m_loadAltitudes; Index & m_index; shared_ptr m_numMwmIds; shared_ptr m_vehicleModelFactory; @@ -37,10 +38,11 @@ private: unordered_map> m_graphs; }; -IndexGraphLoaderImpl::IndexGraphLoaderImpl(VehicleType vehicleType, shared_ptr numMwmIds, +IndexGraphLoaderImpl::IndexGraphLoaderImpl(VehicleType vehicleType, bool loadAltitudes, shared_ptr numMwmIds, shared_ptr vehicleModelFactory, shared_ptr estimator, Index & index) : m_vehicleMask(GetVehicleMask(vehicleType)) + , m_loadAltitudes(loadAltitudes) , m_index(index) , m_numMwmIds(numMwmIds) , m_vehicleModelFactory(vehicleModelFactory) @@ -71,7 +73,7 @@ IndexGraph & IndexGraphLoaderImpl::Load(NumMwmId numMwmId) m_vehicleModelFactory->GetVehicleModelForCountry(file.GetName()); auto graphPtr = make_unique( - GeometryLoader::Create(m_index, handle, vehicleModel, m_vehicleMask != kCarMask), + GeometryLoader::Create(m_index, handle, vehicleModel, m_loadAltitudes), m_estimator); IndexGraph & graph = *graphPtr; @@ -111,12 +113,12 @@ namespace routing { // static unique_ptr IndexGraphLoader::Create( - VehicleType vehicleType, shared_ptr numMwmIds, + VehicleType vehicleType, bool loadAltitudes, shared_ptr numMwmIds, shared_ptr vehicleModelFactory, shared_ptr estimator, Index & index) { - return make_unique(vehicleType, numMwmIds, vehicleModelFactory, estimator, - index); + return make_unique(vehicleType, loadAltitudes, numMwmIds, vehicleModelFactory, + estimator, index); } void DeserializeIndexGraph(MwmValue const & mwmValue, VehicleMask vehicleMask, IndexGraph & graph) diff --git a/routing/index_graph_loader.hpp b/routing/index_graph_loader.hpp index b286a40b61..affbdc239d 100644 --- a/routing/index_graph_loader.hpp +++ b/routing/index_graph_loader.hpp @@ -22,7 +22,7 @@ public: virtual void Clear() = 0; static std::unique_ptr Create( - VehicleType vehicleType, std::shared_ptr numMwmIds, + VehicleType vehicleType, bool loadAltitudes, std::shared_ptr numMwmIds, std::shared_ptr vehicleModelFactory, std::shared_ptr estimator, Index & index); }; diff --git a/routing/index_router.cpp b/routing/index_router.cpp index bfef6d1533..59c05793a6 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -287,12 +287,13 @@ double IndexRouter::BestEdgeComparator::GetSquaredDist(Edge const & edge) const } // IndexRouter ------------------------------------------------------------------------------------ -IndexRouter::IndexRouter(VehicleType vehicleType, +IndexRouter::IndexRouter(VehicleType vehicleType, bool loadAltitudes, CountryParentNameGetterFn const & countryParentNameGetterFn, TCountryFileFn const & countryFileFn, CourntryRectFn const & countryRectFn, shared_ptr numMwmIds, unique_ptr> numMwmTree, traffic::TrafficCache const & trafficCache, Index & index) : m_vehicleType(vehicleType) + , m_loadAltitudes(loadAltitudes) , m_name("astar-bidirectional-" + ToString(m_vehicleType)) , m_index(index) , m_vehicleModelFactory(CreateVehicleModelFactory(m_vehicleType, countryParentNameGetterFn)) @@ -675,7 +676,8 @@ WorldGraph IndexRouter::MakeWorldGraph() WorldGraph graph( 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), + IndexGraphLoader::Create(m_vehicleType, m_loadAltitudes, m_numMwmIds, m_vehicleModelFactory, + m_estimator, m_index), m_estimator); return graph; } diff --git a/routing/index_router.hpp b/routing/index_router.hpp index 91d58795f9..3a1568ca34 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -55,7 +55,7 @@ public: m2::PointD const m_direction; }; - IndexRouter(VehicleType vehicleType, CountryParentNameGetterFn const & countryParentNameGetterFn, + IndexRouter(VehicleType vehicleType, bool loadAltitudes, CountryParentNameGetterFn const & countryParentNameGetterFn, TCountryFileFn const & countryFileFn, CourntryRectFn const & countryRectFn, shared_ptr numMwmIds, unique_ptr> numMwmTree, traffic::TrafficCache const & trafficCache, Index & index); @@ -105,6 +105,7 @@ private: bool AreMwmsNear(NumMwmId startId, NumMwmId finishId) const; VehicleType m_vehicleType; + bool m_loadAltitudes; std::string const m_name; Index & m_index; std::shared_ptr m_vehicleModelFactory; diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index c73fd13e26..bd9b608650 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -103,7 +103,8 @@ namespace integration numMwmIds->RegisterFile(countryFile); } - auto indexRouter = make_unique(vehicleType, CountryParentNameGetterFn(), countryFileGetter, + auto indexRouter = make_unique(vehicleType, false /* load altitudes*/, + CountryParentNameGetterFn(), countryFileGetter, getMwmRectByName, numMwmIds, MakeNumMwmTree(*numMwmIds, infoGetter), trafficCache, index);