diff --git a/map/framework.cpp b/map/framework.cpp index 848a19c4c1..22f1b236f7 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -567,11 +567,6 @@ void Framework::ShowTrack(Track const & track) ShowRectEx(track.GetLimitRect()); } -void Framework::ClearBookmarks() -{ - m_bmManager.ClearItems(); -} - namespace { diff --git a/map/framework.hpp b/map/framework.hpp index 9a9a4d4760..1b70acb867 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -252,8 +252,6 @@ public: void ShowBookmark(BookmarkAndCategory const & bnc); void ShowTrack(Track const & track); - void ClearBookmarks(); - bool AddBookmarksFile(string const & filePath); inline m2::PointD PtoG(m2::PointD const & p) const { return m_navigator.PtoG(p); } diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp index cf59edef33..1d9a66a546 100644 --- a/search/intermediate_result.cpp +++ b/search/intermediate_result.cpp @@ -186,54 +186,59 @@ namespace m_types[i] = c.GetTypeByPath(vector(arr[i], arr[i] + 2)); } - bool IsContinent(uint32_t t) const { return (m_types[0] == t); } - bool IsCountry(uint32_t t) const { return (m_types[1] == t); } + bool IsSkip(uint32_t type) const + { + for (uint8_t t : m_types) + if (t == type) + return true; + return false; + } }; } -Result PreResult2::GenerateFinalResult( - storage::CountryInfoGetter const * pInfo, - CategoriesHolder const * pCat, - set const * pTypes, - int8_t locale) const +string PreResult2::GetRegionName(storage::CountryInfoGetter const * pInfo, uint32_t fType) const { - storage::CountryInfo info; - - uint32_t const type = GetBestType(); - static SkipRegionInfo const checker; - if (!checker.IsContinent(type)) - { - m_region.GetRegion(pInfo, info); + if (checker.IsSkip(fType)) + return string(); - if (checker.IsCountry(type)) - info.m_name.clear(); - } + storage::CountryInfo info; + m_region.GetRegion(pInfo, info); + return move(info.m_name); +} + +Result PreResult2::GenerateFinalResult(storage::CountryInfoGetter const * pInfo, + CategoriesHolder const * pCat, + set const * pTypes, int8_t locale) const +{ + uint32_t const type = GetBestType(pTypes); + string const regionName = GetRegionName(pInfo, type); switch (m_resultType) { case RESULT_FEATURE: - return Result(m_id, GetCenter(), m_str, info.m_name, ReadableFeatureType(pCat, pTypes, locale) + return Result(m_id, GetCenter(), m_str, regionName, ReadableFeatureType(pCat, type, locale) #ifdef DEBUG + ' ' + strings::to_string(int(m_rank)) #endif , type, m_metadata); case RESULT_BUILDING: - return Result(GetCenter(), m_str, info.m_name, ReadableFeatureType(pCat, pTypes, locale)); + return Result(GetCenter(), m_str, regionName, ReadableFeatureType(pCat, type, locale)); default: ASSERT_EQUAL(m_resultType, RESULT_LATLON, ()); - return Result(GetCenter(), m_str, info.m_name, string()); + return Result(GetCenter(), m_str, regionName, string()); } } -Result PreResult2::GeneratePointResult( - CategoriesHolder const * pCat, - set const * pTypes, - int8_t locale) const +Result PreResult2::GeneratePointResult(storage::CountryInfoGetter const * pInfo, + CategoriesHolder const * pCat, + set const * pTypes, int8_t locale) const { - return Result(GetCenter(), m_str, ReadableFeatureType(pCat, pTypes, locale)); + uint8_t const type = GetBestType(pTypes); + return Result(m_id, GetCenter(), m_str, GetRegionName(pInfo, type), + ReadableFeatureType(pCat, type, locale)); } bool PreResult2::LessRank(PreResult2 const & r1, PreResult2 const & r2) @@ -334,13 +339,9 @@ uint32_t PreResult2::GetBestType(set const * pPrefferedTypes) const } string PreResult2::ReadableFeatureType(CategoriesHolder const * pCat, - set const * pTypes, - int8_t locale) const + uint32_t type, int8_t locale) const { - // @TODO print all types, not just one - uint32_t const type = GetBestType(pTypes); ASSERT_NOT_EQUAL(type, 0, ()); - if (pCat) { string name; diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index 08a96988de..f395141e2a 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -85,12 +85,11 @@ public: /// @param[in] lang Current system language. Result GenerateFinalResult(storage::CountryInfoGetter const * pInfo, CategoriesHolder const * pCat, - set const * pTypes, - int8_t lang) const; + set const * pTypes, int8_t locale) const; - Result GeneratePointResult(CategoriesHolder const * pCat, - set const * pTypes, - int8_t locale) const; + Result GeneratePointResult(storage::CountryInfoGetter const * pInfo, + CategoriesHolder const * pCat, + set const * pTypes, int8_t locale) const; static bool LessRank(PreResult2 const & r1, PreResult2 const & r2); static bool LessDistance(PreResult2 const & r1, PreResult2 const & r2); @@ -132,8 +131,7 @@ private: bool IsEqualCommon(PreResult2 const & r) const; string ReadableFeatureType(CategoriesHolder const * pCat, - set const * pTypes, - int8_t locale) const; + uint32_t type, int8_t locale) const; FeatureID m_id; feature::TypesHolder m_types; @@ -157,6 +155,8 @@ private: storage::CountryInfo & info) const; } m_region; + string GetRegionName(storage::CountryInfoGetter const * pInfo, uint32_t fType) const; + m2::PointD GetCenter() const { return m_region.m_point; } double m_distance; diff --git a/search/result.cpp b/search/result.cpp index 6f9a9b79fa..ae57ad26c3 100644 --- a/search/result.cpp +++ b/search/result.cpp @@ -15,14 +15,25 @@ Result::Result(FeatureID const & id, m2::PointD const & pt, string const & str, , m_featureType(featureType) , m_metadata(meta) { - // Features with empty names can be found after suggestion. - if (m_str.empty()) - m_str = type; + PatchNameIfNeeded(); } -Result::Result(m2::PointD const & pt, string const & str, string const & type) - : m_center(pt), m_str(str), m_type(type) +Result::Result(FeatureID const & id, m2::PointD const & pt, string const & str, + string const & region, string const & type) + : m_id(id) + , m_center(pt) + , m_str(str) + , m_region(region) + , m_type(type) { + PatchNameIfNeeded(); +} + +void Result::PatchNameIfNeeded() +{ + // Features with empty names can be found after suggestion. + if (m_str.empty()) + m_str = m_type; } Result::Result(m2::PointD const & pt, string const & str, diff --git a/search/result.hpp b/search/result.hpp index 57c8605577..abd4c92a45 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -39,8 +39,9 @@ public: Result(FeatureID const & id, m2::PointD const & pt, string const & str, string const & region, string const & type, uint32_t featureType, Metadata const & meta); - /// Used for point-like results on the map. - Result(m2::PointD const & pt, string const & str, string const & type); + /// Used for generation viewport results. + Result(FeatureID const & id, m2::PointD const & pt, string const & str, + string const & region, string const & type); /// @param[in] type Empty string - RESULT_LATLON, building address otherwise. Result(m2::PointD const & pt, string const & str, @@ -91,6 +92,8 @@ public: void AppendCity(string const & name); private: + void PatchNameIfNeeded(); + FeatureID m_id; m2::PointD m_center; string m_str, m_region, m_type; diff --git a/search/search_query.cpp b/search/search_query.cpp index d8412b59fc..2487b0f134 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -825,8 +825,8 @@ void Query::SearchViewportPoints(Results & res) if (IsCancelled()) break; - res.AddResultNoChecks( - (*(indV[i])).GeneratePointResult(m_pCategories, &m_prefferedTypes, m_currentLocaleCode)); + res.AddResultNoChecks((*(indV[i])).GeneratePointResult(m_pInfoGetter, m_pCategories, + &m_prefferedTypes, m_currentLocaleCode)); } } @@ -942,6 +942,10 @@ void Query::ProcessSuggestions(vector & vec, Results & res) const void Query::AddResultFromTrie(TTrieValue const & val, MwmSet::MwmId const & mwmID, ViewportID vID /*= DEFAULT_V*/) { + // If we are in viewport search mode, check actual "point-in-viewport" criteria. + if (m_queuesCount == 1 && !m_viewport[CURRENT_V].IsPointInside(val.m_pt)) + return; + impl::PreResult1 res(FeatureID(mwmID, val.m_featureId), val.m_rank, val.m_pt, GetPosition(vID), vID); diff --git a/storage/country_info.cpp b/storage/country_info.cpp index 5290cbf64c..e5d3ac1b72 100644 --- a/storage/country_info.cpp +++ b/storage/country_info.cpp @@ -104,9 +104,7 @@ namespace storage { vector points; serial::LoadOuterPath(src, serial::CodingParams(), points); - - rgnV.push_back(m2::RegionD()); - rgnV.back().Assign(points.begin(), points.end()); + rgnV.emplace_back(points.begin(), points.end()); } } @@ -135,7 +133,7 @@ namespace storage void CountryInfoGetter::GetRegionInfo(string const & id, CountryInfo & info) const { - map::const_iterator i = m_id2info.find(id); + auto i = m_id2info.find(id); // Take into account 'minsk-pass'. if (i == m_id2info.end()) return; @@ -151,12 +149,10 @@ namespace storage template void CountryInfoGetter::ForEachCountry(string const & prefix, ToDo toDo) const { - typedef vector::const_iterator IterT; - - for (IterT i = m_countries.begin(); i != m_countries.end(); ++i) + for (auto const & c : m_countries) { - if (i->m_name.find(prefix) == 0) - toDo(*i); + if (c.m_name.find(prefix) == 0) + toDo(c); } /// @todo Store sorted list of polygons in PACKED_POLYGONS_FILE.