diff --git a/drape_frontend/stylist.cpp b/drape_frontend/stylist.cpp index cf9d509a0d..0041e46c6f 100644 --- a/drape_frontend/stylist.cpp +++ b/drape_frontend/stylist.cpp @@ -8,6 +8,7 @@ #include "indexer/scales.hpp" #include "std/bind.hpp" +#include "std/limits.hpp" namespace df { @@ -45,6 +46,8 @@ inline drule::rule_type_t Convert(Type t) } } +double constexpr kMinPriority = numeric_limits::lowest(); + // ==================================== // inline bool IsTypeOf(drule::Key const & key, int flags) @@ -385,4 +388,26 @@ bool InitStylist(FeatureType const & f, int const zoomLevel, bool buildings3d, S return true; } +double GetFeaturePriority(FeatureType const & f, int const zoomLevel) +{ + drule::KeysT keys; + pair const geomType = feature::GetDrawRule(f, zoomLevel, keys); + + FilterRulesByRuntimeSelector(f, zoomLevel, keys); + + feature::EGeomType const mainGeomType = feature::EGeomType(geomType.first); + + KeyFunctor keyFunctor(f, mainGeomType, zoomLevel, keys.size(), false /* isNameExists */); + for_each(keys.begin(), keys.end(), bind(&KeyFunctor::ProcessKey, &keyFunctor, _1)); + + double maxPriority = kMinPriority; + for (auto const & rule : keyFunctor.m_rules) + { + if (rule.second > maxPriority) + maxPriority = rule.second; + } + + return maxPriority; +} + } // namespace df diff --git a/drape_frontend/stylist.hpp b/drape_frontend/stylist.hpp index fd2b7df4aa..2540c68c39 100644 --- a/drape_frontend/stylist.hpp +++ b/drape_frontend/stylist.hpp @@ -86,4 +86,6 @@ bool InitStylist(FeatureType const & f, bool buildings3d, Stylist & s); +double GetFeaturePriority(FeatureType const & f, int const zoomLevel); + } // namespace df