Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortatiana-kondakova <tatiana.kondakova@gmail.com>2018-03-29 12:38:13 +0300
committermpimenov <mpimenov@users.noreply.github.com>2018-04-09 15:59:05 +0300
commit8099883fd67e68c12bb59ffa34e749a5cf4e4c14 (patch)
treece77fb50ca53d81579c20aaa91ee1174f01cd3a9 /indexer
parent9021750e6dd899758facf22140d56c2d706aacc1 (diff)
Increase search rank for FC2018 objects
Diffstat (limited to 'indexer')
-rw-r--r--indexer/rank_table.cpp36
-rw-r--r--indexer/rank_table.hpp18
2 files changed, 42 insertions, 12 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
diff --git a/indexer/rank_table.hpp b/indexer/rank_table.hpp
index 756b477aaa..89786412c6 100644
--- a/indexer/rank_table.hpp
+++ b/indexer/rank_table.hpp
@@ -1,9 +1,9 @@
#pragma once
-#include "std/cstdint.hpp"
-#include "std/string.hpp"
-#include "std/unique_ptr.hpp"
-#include "std/vector.hpp"
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <vector>
class FilesContainerR;
class FilesContainerW;
@@ -70,7 +70,7 @@ public:
// *NOTE* Return value can outlive |rcont|. Also note that there is
// undefined behaviour if ranks section exists but internally
// damaged.
- static unique_ptr<RankTable> Load(FilesContainerR const & rcont);
+ static std::unique_ptr<RankTable> Load(FilesContainerR const & rcont);
// Maps whole section corresponding to a rank table and deserializes
// it. Returns nullptr if there're no ranks section, rank table's
@@ -81,7 +81,7 @@ public:
// destructed before |mcont| is closed. Also note that there're
// undefined behaviour if ranks section exists but internally
// damaged.
- static unique_ptr<RankTable> Load(FilesMappingContainer const & mcont);
+ static std::unique_ptr<RankTable> Load(FilesMappingContainer const & mcont);
};
// A builder class for rank tables.
@@ -89,7 +89,7 @@ class RankTableBuilder
{
public:
// Calculates search ranks for all features in an mwm.
- static void CalcSearchRanks(FilesContainerR & rcont, vector<uint8_t> & ranks);
+ static void CalcSearchRanks(FilesContainerR & rcont, std::vector<uint8_t> & ranks);
// Following methods create rank table for an mwm.
// * When rank table already exists and has proper endianness, does nothing.
@@ -101,11 +101,11 @@ public:
// Return true if rank table was successfully generated and written
// or already exists and has correct format.
static bool CreateIfNotExists(platform::LocalCountryFile const & localFile) noexcept;
- static bool CreateIfNotExists(string const & mapPath) noexcept;
+ static bool CreateIfNotExists(std::string const & mapPath) noexcept;
// Force creation of a rank table from array of ranks. Existing rank
// table is removed (if any). Note that |wcont| must be instantiated
// as FileWriter::OP_WRITE_EXISTING.
- static void Create(vector<uint8_t> const & ranks, FilesContainerW & wcont);
+ static void Create(std::vector<uint8_t> const & ranks, FilesContainerW & wcont);
};
} // namespace search