diff --git a/indexer/drawing_rule_def.cpp b/indexer/drawing_rule_def.cpp index 0cd10a4b99..1df08bf5a7 100644 --- a/indexer/drawing_rule_def.cpp +++ b/indexer/drawing_rule_def.cpp @@ -38,4 +38,61 @@ namespace drule beg = end + 1; } while (beg < count); } + + namespace + { + struct less_key + { + bool operator() (drule::Key const & r1, drule::Key const & r2) const + { + if (r1.m_type == r2.m_type) + { + // assume that unique algo leaves the first element (with max priority), others - go away + return (r1.m_priority > r2.m_priority); + } + else + return (r1.m_type < r2.m_type); + } + }; + + struct equal_key + { + bool operator() (drule::Key const & r1, drule::Key const & r2) const + { + // many line and area rules - is ok, other rules - one is enough + // By VNG: Why many area styles ??? Did I miss something ??? + if (r1.m_type == drule::line /*|| r1.m_type == drule::area*/) + return (r1 == r2); + else + return (r1.m_type == r2.m_type); + } + }; + + struct less_scale_type_depth + { + bool operator() (drule::Key const & r1, drule::Key const & r2) const + { + if (r1.m_scale == r2.m_scale) + { + if (r1.m_type == r2.m_type) + { + return (r1.m_priority < r2.m_priority); + } + else return (r1.m_type < r2.m_type); + } + else return (r1.m_scale < r2.m_scale); + } + }; + } + + void MakeUnique(vector & keys) + { + sort(keys.begin(), keys.end(), less_key()); + keys.erase(unique(keys.begin(), keys.end(), equal_key()), keys.end()); + } + + void SortByScaleTypeDepth(vector & keys) + { + sort(keys.begin(), keys.end(), less_scale_type_depth()); + } } diff --git a/indexer/drawing_rule_def.hpp b/indexer/drawing_rule_def.hpp index b697f43406..385320e2f8 100644 --- a/indexer/drawing_rule_def.hpp +++ b/indexer/drawing_rule_def.hpp @@ -1,6 +1,8 @@ #pragma once #include "../std/string.hpp" +#include "../std/vector.hpp" + namespace drule { @@ -33,4 +35,7 @@ namespace drule enum rule_geo_t { node = 1, way = 2 }; int const layer_base_priority = 2000; + + void MakeUnique(vector & keys); + void SortByScaleTypeDepth(vector & keys); } diff --git a/map/draw_processor.cpp b/map/draw_processor.cpp index d4ac38ddb4..3fde8aa709 100644 --- a/map/draw_processor.cpp +++ b/map/draw_processor.cpp @@ -229,38 +229,11 @@ namespace fwork return (r1.m_depth < r2.m_depth); } }; - - struct less_key - { - bool operator() (drule::Key const & r1, drule::Key const & r2) const - { - if (r1.m_type == r2.m_type) - { - // assume that unique algo leaves the first element (with max priority), others - go away - return (r1.m_priority > r2.m_priority); - } - else - return (r1.m_type < r2.m_type); - } - }; - - struct equal_key - { - bool operator() (drule::Key const & r1, drule::Key const & r2) const - { - // many line and area rules - is ok, other rules - one is enough - if (r1.m_type == drule::line || r1.m_type == drule::area) - return (r1 == r2); - else - return (r1.m_type == r2.m_type); - } - }; } void DrawProcessor::PreProcessKeys(vector & keys) const { - sort(keys.begin(), keys.end(), less_key()); - keys.erase(unique(keys.begin(), keys.end(), equal_key()), keys.end()); + drule::MakeUnique(keys); } #define GET_POINTS(f, for_each_fun, fun, assign_fun) \