diff --git a/platform/mwm_version.hpp b/platform/mwm_version.hpp index 7cfd8a1fdf..0ab81e4985 100644 --- a/platform/mwm_version.hpp +++ b/platform/mwm_version.hpp @@ -21,7 +21,8 @@ enum class Format v6, // October 2015 (offsets vector is in mwm now). v7, // November 2015 (supply different search index formats). v8, // February 2016 (long strings in metadata; store seconds since epoch in MwmVersion). - v9, // April 2017 (OSRM sections are deleted and replaced by cross mwm section. + // December 2016 (index graph section was added in version 161206, between v8 and v9). + v9, // April 2017 (OSRM sections are deleted and replaced by cross mwm section). lastFormat = v9 }; diff --git a/routing/car_router.cpp b/routing/car_router.cpp index 7115d9f927..0f8b292f58 100644 --- a/routing/car_router.cpp +++ b/routing/car_router.cpp @@ -241,7 +241,7 @@ IRouter::ResultCode FindSingleOsrmRoute(FeatureGraphNode const & source, } template -void ForEachCountryInfo(Index & index, ToDo && toDo) +bool ForEachCountryInfo(Index & index, ToDo && toDo) { vector> infos; index.GetMwmsInfo(infos); @@ -249,8 +249,13 @@ void ForEachCountryInfo(Index & index, ToDo && toDo) for (auto const & info : infos) { if (info->GetType() == MwmInfo::COUNTRY) - toDo(*info); + { + if (!toDo(*info)) + return false; + } } + + return true; } } // namespace @@ -600,43 +605,37 @@ bool CarRouter::DoesEdgeIndexExist(Index::MwmId const & mwmId) bool CarRouter::AllMwmsHaveRoutingIndex() const { - bool result = true; - - ForEachCountryInfo(m_index, [&](MwmInfo const & info) { - if (!version::MwmTraits(info.m_version).HasRoutingIndex()) - result = false; + return ForEachCountryInfo(m_index, [&](MwmInfo const & info) { + return version::MwmTraits(info.m_version).HasRoutingIndex(); }); - - return result; } bool CarRouter::ThereIsCrossMwmMix(Route & route) const { - bool oldMwmExists = false; - bool newMwmExists = false; + bool osrmMwmExists = false; + bool crossMwmExists = false; vector oldMwms; ForEachCountryInfo(m_index, [&](MwmInfo const & info) { if (version::MwmTraits(info.m_version).HasCrossMwmSection()) { - newMwmExists = true; + crossMwmExists = true; } else { - oldMwmExists = true; + osrmMwmExists = true; oldMwms.push_back(info.GetCountryName()); } + return true; }); - if (oldMwmExists && newMwmExists) - { - for (auto const & oldMwm : oldMwms) - route.AddAbsentCountry(oldMwm); + if (!osrmMwmExists || !crossMwmExists) + return false; - return true; - } + for (auto const & oldMwm : oldMwms) + route.AddAbsentCountry(oldMwm); - return false; + return true; } IRouter::ResultCode CarRouter::FindSingleRouteDispatcher(FeatureGraphNode const & source,