diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 58891fca49..a967354a35 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -633,6 +633,11 @@ IsCityChecker::IsCityChecker() m_types.push_back(classif().GetTypeByPath({"place", "city"})); } +IsCapitalChecker::IsCapitalChecker() : BaseChecker(3 /* level */) +{ + m_types.push_back(classif().GetTypeByPath({"place", "city", "capital"})); +} + IsPublicTransportStopChecker::IsPublicTransportStopChecker() { m_types.push_back(classif().GetTypeByPath({"highway", "bus_stop"})); diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index 47e64a04b8..e93cb8588a 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -366,6 +366,13 @@ public: DECLARE_CHECKER_INSTANCE(IsCityChecker); }; +class IsCapitalChecker : public BaseChecker +{ + IsCapitalChecker(); +public: + DECLARE_CHECKER_INSTANCE(IsCapitalChecker); +}; + class IsPublicTransportStopChecker : public BaseChecker { IsPublicTransportStopChecker(); diff --git a/search/ranker.cpp b/search/ranker.cpp index b348635f02..517258aa26 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -444,14 +444,17 @@ class RankerResultMaker } uint8_t NormalizeRank(uint8_t rank, Model::Type type, m2::PointD const & center, - string const & country) + string const & country, bool isCapital, bool isRelaxed) { + if (isRelaxed) + rank /= 5.0; + switch (type) { - case Model::TYPE_VILLAGE: return rank / 1.5; + case Model::TYPE_VILLAGE: return rank / 2.5; case Model::TYPE_CITY: { - if (m_ranker.m_params.m_viewport.IsPointInside(center)) + if (isCapital || m_ranker.m_params.m_viewport.IsPointInside(center)) return base::Clamp(static_cast(rank) * 2, 0, 0xFF); storage::CountryInfo info; @@ -462,8 +465,8 @@ class RankerResultMaker if (info.IsNotEmpty() && info.m_name == m_ranker.m_params.m_pivotRegion) return base::Clamp(static_cast(rank * 1.7), 0, 0xFF); } - case Model::TYPE_COUNTRY: - return rank / 1.5; + case Model::TYPE_STATE: return rank / 1.5; + case Model::TYPE_COUNTRY: return rank; default: return rank; } @@ -490,7 +493,8 @@ public: search::RankingInfo info; InitRankingInfo(*ft, center, preRankerResult, info); - info.m_rank = NormalizeRank(info.m_rank, info.m_type, center, country); + info.m_rank = NormalizeRank(info.m_rank, info.m_type, center, country, + ftypes::IsCapitalChecker::Instance()(*ft), !info.m_allTokensUsed); r.SetRankingInfo(move(info)); r.m_provenance = move(preRankerResult.GetProvenance());