From 5b1b472957a72620f4ab1e2aa488f67c983dbc06 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 19 Sep 2012 16:33:23 +0300 Subject: Fix feature's types while generating. Do not include non-drawable types for POINT, LINEAR and AREA geometry types. --- indexer/feature_visibility.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ indexer/feature_visibility.hpp | 7 +++++-- 2 files changed, 46 insertions(+), 2 deletions(-) (limited to 'indexer') diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index ee96d55a33..db0c5cc953 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -254,6 +254,47 @@ bool IsDrawableForIndex(FeatureBase const & f, int level) return false; } +namespace +{ + class CheckNonDrawableType + { + Classificator & m_c; + FeatureGeoType m_arr[3]; + size_t m_count; + + public: + CheckNonDrawableType(FeatureGeoType ft) + : m_c(classif()), m_count(0) + { + if (ft < FEATURE_TYPE_LINE_AREA) + m_arr[m_count++] = ft; + else + { + ASSERT_EQUAL ( ft, FEATURE_TYPE_LINE_AREA, () ); + m_arr[m_count++] = FEATURE_TYPE_LINE; + m_arr[m_count++] = FEATURE_TYPE_AREA; + } + } + + bool operator() (uint32_t t) + { + for (size_t i = 0; i < m_count; ++i) + { + IsDrawableLikeChecker doCheck(m_arr[i]); + if (m_c.ProcessObjects(t, doCheck)) + return false; + } + return true; + } + }; +} + +bool RemoveNoDrawableTypes(vector & types, FeatureGeoType ft) +{ + types.erase(remove_if(types.begin(), types.end(), CheckNonDrawableType(ft)), types.end()); + return !types.empty(); +} + int GetMinDrawableScale(FeatureBase const & f) { int const upBound = scales::GetUpperScale(); diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp index b4ba4c5f77..6f3fea925c 100644 --- a/indexer/feature_visibility.hpp +++ b/indexer/feature_visibility.hpp @@ -19,13 +19,16 @@ namespace feature enum FeatureGeoType { FEATURE_TYPE_POINT = 0, FEATURE_TYPE_LINE = 1, - FEATURE_TYPE_AREA = 2 + FEATURE_TYPE_AREA = 2, + FEATURE_TYPE_LINE_AREA = 3 }; bool IsDrawableAny(uint32_t type); - bool IsDrawableLike(vector const & type, FeatureGeoType ft); + bool IsDrawableLike(vector const & types, FeatureGeoType ft); bool IsDrawableForIndex(FeatureBase const & f, int level); + bool RemoveNoDrawableTypes(vector & types, FeatureGeoType ft); + int GetMinDrawableScale(FeatureBase const & f); /// @return [-1, -1] if no any text exists -- cgit v1.2.3