From 43447130128f1ba4430b95698ace2ac5250652ef Mon Sep 17 00:00:00 2001 From: kshalnev Date: Mon, 15 Feb 2016 23:21:47 +0300 Subject: [PATCH] Fixed dynamic selector --- drape_frontend/stylist.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drape_frontend/stylist.cpp b/drape_frontend/stylist.cpp index 01ad456be6..23e071d833 100644 --- a/drape_frontend/stylist.cpp +++ b/drape_frontend/stylist.cpp @@ -69,16 +69,6 @@ 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: @@ -105,6 +95,11 @@ 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)) @@ -122,9 +117,6 @@ 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(); @@ -135,6 +127,8 @@ 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; @@ -361,8 +355,6 @@ 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,6 +387,9 @@ 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) @@ -413,8 +408,6 @@ 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;