diff options
author | vng <viktor.govako@gmail.com> | 2015-08-13 12:42:48 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:01:30 +0300 |
commit | 57c1e9741fb23d11bf1ea1b020001a01b75b26fc (patch) | |
tree | ca2d1597f9a69a24a25e93a53f533cda166d677b /routing | |
parent | 027e9a8f1eb4a1064edc8462d03704cc56cc603b (diff) |
[routing] Fixed bug when no country under point for routing initialization.
Diffstat (limited to 'routing')
-rw-r--r-- | routing/routing_mapping.cpp | 11 | ||||
-rw-r--r-- | routing/routing_mapping.hpp | 9 |
2 files changed, 11 insertions, 9 deletions
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<RoutingMapping>(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; } |