diff --git a/routing/routing_mapping.cpp b/routing/routing_mapping.cpp index 3bd757e153..46cb2222c9 100644 --- a/routing/routing_mapping.cpp +++ b/routing/routing_mapping.cpp @@ -139,7 +139,11 @@ void RoutingMapping::FreeCrossContext() TRoutingMappingPtr RoutingIndexManager::GetMappingByPoint(m2::PointD const & point) { - return GetMappingByName(m_countryFileFn(point)); + string const name = m_countryFileFn(point); + if (name.empty()) + return TRoutingMappingPtr(new RoutingMapping()); + + return GetMappingByName(name); } TRoutingMappingPtr RoutingIndexManager::GetMappingByName(string const & mapName) @@ -150,9 +154,8 @@ TRoutingMappingPtr RoutingIndexManager::GetMappingByName(string const & mapName) return mapIter->second; // Or load and check file. - TRoutingMappingPtr newMapping = - make_shared(mapName, m_index); - m_mapping.insert(make_pair(mapName, newMapping)); + TRoutingMappingPtr newMapping(new RoutingMapping(mapName, m_index)); + m_mapping[mapName] = newMapping; return newMapping; } diff --git a/routing/routing_mapping.hpp b/routing/routing_mapping.hpp index 88007e13b3..866de8ea9b 100644 --- a/routing/routing_mapping.hpp +++ b/routing/routing_mapping.hpp @@ -23,21 +23,20 @@ struct RoutingMapping OsrmFtSegMapping m_segMapping; CrossRoutingContextReader m_crossContext; - ///@param fName: mwm file path + /// Default constructor to create invalid instance for existing client code. + /// @postcondition IsValid() == false. + RoutingMapping() = default; + /// @param countryFile Country file name without extension. RoutingMapping(string const & countryFile, MwmSet * pIndex); - ~RoutingMapping(); void Map(); - void Unmap(); void LoadFacade(); - void FreeFacade(); void LoadCrossContext(); - void FreeCrossContext(); bool IsValid() const { return m_handle.IsAlive() && m_error == IRouter::ResultCode::NoError; }