From 90886f0e123ef3821ac74d4414bd265fe4a04f76 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 1 Jun 2011 01:48:03 +0300 Subject: [PATCH] - Don't store names for features with invisible texts. - Try to make better rank for drawing text font. --- indexer/feature.cpp | 33 ++++++++++++++++++++------------- indexer/feature.hpp | 2 +- indexer/feature_visibility.hpp | 11 +++++++++++ map/drawer_yg.hpp | 4 ++-- map/framework.cpp | 2 +- yg/font_desc.cpp | 6 ++---- yg/font_desc.hpp | 2 +- 7 files changed, 38 insertions(+), 22 deletions(-) diff --git a/indexer/feature.cpp b/indexer/feature.cpp index 59896d553f..cd2675e24f 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -148,6 +148,10 @@ bool FeatureBuilder1::PreSerialize() return false; } + // Clear name for features with invisible texts. + if (!m_Params.name.IsEmpty() && feature::MinDrawableScaleForText(GetFeatureBase()) == -1) + m_Params.name.Clear(); + return true; } @@ -984,22 +988,25 @@ string FeatureType::GetPreferredDrawableName(char const * priorities) const return res; } -uint8_t FeatureType::GetRank() const +uint32_t FeatureType::GetPopulation() const { if (!m_bCommonParsed) ParseCommon(); - /// @todo Move this check to generator (don't store rank for countries). - if (m_Params.rank > 0 && feature::IsCountry(m_Types[0])) - return 0; - - return m_Params.rank; -} - -uint32_t FeatureType::GetPopulation() const -{ - uint8_t const rank = GetRank(); - if (rank == 0) + if (m_Params.rank == 0) return 1; - return static_cast(min(double(uint32_t(-1)), pow(1.1, rank))); + + return static_cast(min(double(uint32_t(-1)), pow(1.1, m_Params.rank))); +} + +double FeatureType::GetPopulationDrawRank() const +{ + uint32_t const n = GetPopulation(); + if (n == 1) return 0.0; + + // Do not return rank for countries. + if (feature::IsCountry(m_Types, m_Types + GetTypesCount())) + return 0.5; + else + return min(3.0E6, static_cast(n)) / 3.0E6; } diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 491fe3242c..febdec9164 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -376,8 +376,8 @@ public: /// For test cases only. string DebugString(int scale) const; - uint8_t GetRank() const; uint32_t GetPopulation() const; + double GetPopulationDrawRank() const; /// @name Statistic functions. //@{ diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp index 37349c3f31..e07bc62c25 100644 --- a/indexer/feature_visibility.hpp +++ b/indexer/feature_visibility.hpp @@ -23,5 +23,16 @@ namespace feature int GetDrawRule(FeatureBase const & f, int level, vector & keys, string & names); bool IsHighway(vector const & types); + bool IsCountry(uint32_t type); + template + inline bool IsCountry(IterT beg, IterT end) + { + while (beg != end) + { + if (IsCountry(*beg++)) + return true; + } + return false; + } } diff --git a/map/drawer_yg.hpp b/map/drawer_yg.hpp index e8746654ec..982b77c006 100644 --- a/map/drawer_yg.hpp +++ b/map/drawer_yg.hpp @@ -32,14 +32,14 @@ namespace di class DrawInfo { public: - DrawInfo(string const & name, uint8_t rank) : m_name(name), m_rank(rank) {} + DrawInfo(string const & name, double rank) : m_name(name), m_rank(rank) {} list m_pathes; list m_areas; m2::PointD m_point; string m_name; - uint8_t m_rank; + double m_rank; }; struct DrawRule diff --git a/map/framework.cpp b/map/framework.cpp index 4ab3c8d1c4..e0cd85e5ce 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -163,7 +163,7 @@ namespace fwork shared_ptr ptr( new di::DrawInfo(f.GetPreferredDrawableName(languages::GetCurrentPriorities()), - f.GetRank())); + f.GetPopulationDrawRank())); DrawerYG * pDrawer = GetDrawer(); diff --git a/yg/font_desc.cpp b/yg/font_desc.cpp index 76a3d1fc95..f84f18a732 100644 --- a/yg/font_desc.cpp +++ b/yg/font_desc.cpp @@ -16,12 +16,10 @@ namespace yg m_isMasked(isMasked), m_maskColor(maskColor) {} - void FontDesc::SetRank(uint8_t rank) + void FontDesc::SetRank(double rank) { if (rank > 0) - m_size += static_cast(min(4.0E6, std::pow(1.1, double(rank))) / 2.0E6 * m_size); - //m_size += static_cast((double(rank) / 200.0) * m_size); - //m_size += (rank / 20); + m_size += static_cast(rank * m_size); } bool FontDesc::operator ==(FontDesc const & src) const diff --git a/yg/font_desc.hpp b/yg/font_desc.hpp index 536a2ea331..806dbf4322 100644 --- a/yg/font_desc.hpp +++ b/yg/font_desc.hpp @@ -15,7 +15,7 @@ namespace yg FontDesc(bool isStatic = true, int size = 10, yg::Color const & color = yg::Color(0, 0, 0, 255), bool isMasked = true, yg::Color const & maskColor = yg::Color(255, 255, 255, 255)); - void SetRank(uint8_t rank); + void SetRank(double rank); bool operator != (FontDesc const & src) const; bool operator == (FontDesc const & src) const;