diff options
author | Yury Melnichek <melnichek@gmail.com> | 2011-09-29 16:07:46 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:25:02 +0300 |
commit | 0226c8c3eb1eebdc427cd62250fd0ce8900dbdc5 (patch) | |
tree | b11b459568105f0cf9ab9495f3b39f8998fbc388 /indexer/feature_utils.cpp | |
parent | b22c5fe71928744f41b3ee3825c826da8bf79ce6 (diff) |
Move GetSearchRank() from FeatureType to an external function.
Diffstat (limited to 'indexer/feature_utils.cpp')
-rw-r--r-- | indexer/feature_utils.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index d71524d17f..60fad6e9a5 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -4,14 +4,17 @@ #include "../base/base.hpp" #include "../std/vector.hpp" -namespace +namespace feature { -class FeatureViewportEstimator +namespace impl +{ + +class FeatureEstimator { public: - FeatureViewportEstimator() + FeatureEstimator() { m_TypeContinent = GetType("place", "continent"); m_TypeCountry = GetType("place", "country"); @@ -42,6 +45,14 @@ public: maxSizeMeters.x, maxSizeMeters.y); } + uint8_t GetSearchRank(FeatureType const & feature) const + { + uint32_t const population = feature.GetPopulation(); + return static_cast<uint8_t>(log(double(population)) / log(1.1)); + } + +private: + // Returns width and height (lon and lat) for a given type. m2::PointD GetSizeForType(uint32_t const type, FeatureType const & feature) const { @@ -66,8 +77,6 @@ public: return m2::PointD(0, 0); } -private: - static uint32_t GetType(string const & s1, string const & s2 = string(), string const & s3 = string()) @@ -87,10 +96,22 @@ private: uint32_t m_TypeVillage; }; -} // unnamed namespace +FeatureEstimator const & GetFeatureEstimator() +{ + static FeatureEstimator const featureEstimator; + return featureEstimator; +} + +} // namespace feature::impl -m2::RectD feature::GetFeatureViewport(FeatureType const & feature) +m2::RectD GetFeatureViewport(FeatureType const & feature) { - static FeatureViewportEstimator const featureViewportEstimator; - return featureViewportEstimator.GetViewport(feature); + return impl::GetFeatureEstimator().GetViewport(feature); } + +uint8_t GetSearchRank(FeatureType const & feature) +{ + return impl::GetFeatureEstimator().GetSearchRank(feature); +} + +} // namespace feature |