From 5a56d017f5517afc6515eccdd3077e2eb0db55bf Mon Sep 17 00:00:00 2001 From: Darafei Praliaskouski Date: Thu, 24 Jan 2013 19:21:15 +0300 Subject: [PATCH] don't let icon and text overlap --- map/draw_processor.cpp | 2 +- map/feature_styler.cpp | 37 +++++++++++++++++++++++++++++++------ map/feature_styler.hpp | 10 ++++++++-- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/map/draw_processor.cpp b/map/draw_processor.cpp index ce6f5a1fb7..ad7b0d2df6 100644 --- a/map/draw_processor.cpp +++ b/map/draw_processor.cpp @@ -254,7 +254,7 @@ namespace fwork else m_hasNonCoast = true; - size_t count = styles.m_count; + size_t count = styles.GetCount(); #ifdef PROFILER_DRAWING m_drawCount += count; diff --git a/map/feature_styler.cpp b/map/feature_styler.cpp index a28eaad188..8f0baaaa9f 100644 --- a/map/feature_styler.cpp +++ b/map/feature_styler.cpp @@ -1,7 +1,13 @@ #include "feature_styler.hpp" + #include "../indexer/drawing_rules.hpp" #include "../indexer/feature.hpp" #include "../indexer/feature_visibility.hpp" +#ifdef OMIM_PRODUCTION + #include "../indexer/drules_struct_lite.pb.h" +#else + #include "../indexer/drules_struct.pb.h" +#endif namespace { @@ -66,14 +72,12 @@ namespace feature } double priorityModifier; - if (area != 0) priorityModifier = min(1., area*10000.); // making area larger so it's not lost on double conversions else priorityModifier = static_cast(population) / 7E9; // dividing by planet population to get priorityModifier < 1 drule::MakeUnique(keys); - size_t const count = keys.size(); int layer = f.GetLayer(); bool isTransparent = false; @@ -83,24 +87,31 @@ namespace feature isTransparent = true; } - m_rules.resize(count); + bool hasIcon = false; + bool hasCaptionWithoutOffset = false; + size_t const count = keys.size(); + m_rules.resize(count); for (size_t i = 0; i < count; ++i) { double depth = keys[i].m_priority; - if (layer != 0) depth = (layer * drule::layer_base_priority) + fmod(depth, drule::layer_base_priority); if (keys[i].m_type == drule::symbol) + { depth = 16000; + hasIcon = true; + } + if (keys[i].m_type == drule::caption) { depth = 15000; if (m_geometryType == GEOM_POINT) depth = 15500; } + if (keys[i].m_type == drule::pathtext) depth = 17000; @@ -124,12 +135,26 @@ namespace feature m_rules[i] = di::DrawRule( drule::rules().Find(keys[i]), depth, isTransparent); - if (m_hasLineStyles && !m_hasPathText && !m_primaryText.empty()) + if ((m_geometryType == GEOM_LINE) && !m_hasPathText && !m_primaryText.empty()) if (m_rules[i].m_rule->GetCaption(0) != 0) m_hasPathText = true; + + if (keys[i].m_type == drule::caption) + if (m_rules[i].m_rule->GetCaption(0) != 0) + if (!m_rules[i].m_rule->GetCaption(0)->has_offset_y()) + hasCaptionWithoutOffset = true; } + if (hasIcon && hasCaptionWithoutOffset) + for (size_t i = 0; i < count; ++i) + { + if (keys[i].m_type == drule::symbol) + { + m_rules[i] = m_rules[m_rules.size() - 1]; + m_rules.pop_back(); + } + } + sort(m_rules.begin(), m_rules.end(), less_depth()); - m_count = m_rules.size(); } } diff --git a/map/feature_styler.hpp b/map/feature_styler.hpp index 0c78b1ade7..de52ffe585 100644 --- a/map/feature_styler.hpp +++ b/map/feature_styler.hpp @@ -1,8 +1,9 @@ #pragma once -#include "../std/vector.hpp" #include "drawer.hpp" +#include "../std/vector.hpp" + class FeatureType; namespace feature @@ -16,11 +17,11 @@ namespace feature typedef buffer_vector StylesContainerT; StylesContainerT m_rules; + bool m_isCoastline; bool m_hasLineStyles; bool m_hasPathText; int m_geometryType; - size_t m_count; string m_primaryText; string m_secondaryText; @@ -29,9 +30,14 @@ namespace feature double m_popRank; void GetStyles(FeatureType const & f, int const zoom); + inline bool IsEmpty() const { return m_rules.empty(); } + inline size_t GetCount() const + { + return m_rules.size(); + } }; }