diff --git a/drape_frontend/stylist.cpp b/drape_frontend/stylist.cpp index 7a459dd3cc..b91392d97e 100644 --- a/drape_frontend/stylist.cpp +++ b/drape_frontend/stylist.cpp @@ -69,6 +69,16 @@ bool IsMiddleTunnel(int const layer, double const depth) return layer != feature::LAYER_EMPTY && depth < 19000; } +void FilterRulesByRuntimeSelector(FeatureType const & f, int zoomLevel, drule::KeysT & keys) +{ + keys.erase_if([&f, zoomLevel](drule::Key const & key)->bool + { + drule::BaseRule const * const rule = drule::rules().Find(key); + ASSERT(rule != nullptr, ()); + return !rule->TestFeature(f, zoomLevel); + }); +} + class KeyFunctor { public: @@ -95,11 +105,6 @@ public: void ProcessKey(drule::Key const & key) { - drule::BaseRule const * const dRule = drule::rules().Find(key); - - if (!dRule->TestFeature(m_f, m_zoomLevel)) - return; - double depth = key.m_priority; if (IsMiddleTunnel(m_depthLayer, depth) && IsTypeOf(key, Line | Area | Waymarker)) @@ -117,6 +122,9 @@ public: else if (IsTypeOf(key, Area)) depth -= m_priorityModifier; + drule::BaseRule const * const dRule = drule::rules().Find(key); + m_rules.push_back(make_pair(dRule, depth)); + if (dRule->GetCaption(0) != nullptr) { InitCaptionDescription(); @@ -127,8 +135,6 @@ public: m_pointStyleFound |= (IsTypeOf(key, Symbol | Circle) || isNonEmptyCaption); m_lineStyleFound |= IsTypeOf(key, Line); m_auxCaptionFound |= (dRule->GetCaption(1) != nullptr); - - m_rules.push_back(make_pair(dRule, depth)); } bool m_pointStyleFound; @@ -363,6 +369,8 @@ bool InitStylist(FeatureType const & f, int const zoomLevel, bool buildings3d, S drule::KeysT keys; pair const geomType = feature::GetDrawRule(types, zoomLevel, keys); + FilterRulesByRuntimeSelector(f, zoomLevel, keys); + if (keys.empty()) return false; @@ -395,9 +403,6 @@ bool InitStylist(FeatureType const & f, int const zoomLevel, bool buildings3d, S for (auto const & key : keys) keyFunctor.ProcessKey(key); - if (keyFunctor.m_rules.empty()) - return false; - if (keyFunctor.m_pointStyleFound) s.RaisePointStyleFlag(); if (keyFunctor.m_lineStyleFound) @@ -416,6 +421,8 @@ 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); CaptionDescription descr;