diff options
author | tatiana-kondakova <tatiana.kondakova@gmail.com> | 2018-03-29 12:38:13 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-04-09 15:59:05 +0300 |
commit | 8099883fd67e68c12bb59ffa34e749a5cf4e4c14 (patch) | |
tree | ce77fb50ca53d81579c20aaa91ee1174f01cd3a9 /indexer/rank_table.cpp | |
parent | 9021750e6dd899758facf22140d56c2d706aacc1 (diff) |
Increase search rank for FC2018 objects
Diffstat (limited to 'indexer/rank_table.cpp')
-rw-r--r-- | indexer/rank_table.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/indexer/rank_table.cpp b/indexer/rank_table.cpp index a81a9cd35a..52b0d24cf6 100644 --- a/indexer/rank_table.cpp +++ b/indexer/rank_table.cpp @@ -1,5 +1,6 @@ #include "indexer/rank_table.hpp" +#include "indexer/classificator.hpp" #include "indexer/data_header.hpp" #include "indexer/feature_algo.hpp" #include "indexer/feature_impl.hpp" @@ -22,12 +23,17 @@ #include "base/assert.hpp" #include "base/logging.hpp" #include "base/macros.hpp" +#include "base/math.hpp" -#include "std/exception.hpp" -#include "std/utility.hpp" +#include <algorithm> +#include <exception> +#include <limits> +#include <utility> #include "defines.hpp" +using namespace std; + namespace search { namespace @@ -214,10 +220,34 @@ unique_ptr<RankTable> LoadRankTable(unique_ptr<TRegion> && region) return unique_ptr<RankTable>(); } +uint8_t CalcEventRank(FeatureType const & ft) +{ + // |fc2018Rank| value was adjusted for cases: + // - fc2018 objects should be in thetop for "stadium" query iff fc2018 mwm is in viewport. + // - fc2018 objects should be above apartments and other objects with same name. + // - fc2018 objects should be in the top for object name query at any viewport. + uint8_t const fc2018Rank = 16; + Classificator const & c = classif(); + auto const types = feature::TypesHolder(ft); + auto const fcType = + ftypes::BaseChecker::PrepareToMatch(c.GetTypeByPath({"event", "fc2018"}), 2 /* level */); + auto const fcCityType = + ftypes::BaseChecker::PrepareToMatch(c.GetTypeByPath({"event", "fc2018_city"}), 2 /* level */); + if (find(types.begin(), types.end(), fcType) != types.end() || + find(types.begin(), types.end(), fcCityType) != types.end()) + { + return fc2018Rank; + } + return 0; +} + // Calculates search rank for a feature. uint8_t CalcSearchRank(FeatureType const & ft) { - return feature::PopulationToRank(ftypes::GetPopulation(ft)); + auto const eventRank = CalcEventRank(ft); + auto const populationRank = feature::PopulationToRank(ftypes::GetPopulation(ft)); + + return my::clamp(eventRank + populationRank, 0, static_cast<int>(numeric_limits<uint8_t>::max())); } // Creates rank table if it does not exists in |rcont| or has wrong |