From 867425921b83e4e13578f2550884806ad62947eb Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 2 Dec 2013 14:11:41 +0100 Subject: [PATCH] [generator] Skip features with helper types only ("oneway"). --- generator/osm_element.hpp | 34 ++++++++++++++++++++++++++- indexer/feature_visibility.cpp | 43 ---------------------------------- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/generator/osm_element.hpp b/generator/osm_element.hpp index eb5d150cce..91be8124a9 100644 --- a/generator/osm_element.hpp +++ b/generator/osm_element.hpp @@ -6,6 +6,7 @@ #include "ways_merger.hpp" #include "../indexer/feature_visibility.hpp" +#include "../indexer/classificator.hpp" #include "../base/string_utils.hpp" #include "../base/logging.hpp" @@ -238,6 +239,36 @@ protected: ft.SetAreaAddHoles(processor.GetHoles()); } + class UselessSingleTypes + { + vector m_types; + + bool IsUseless(uint32_t t) const + { + return (find(m_types.begin(), m_types.end(), t) != m_types.end()); + } + + public: + UselessSingleTypes() + { + Classificator const & c = classif(); + + char const * arr[][1] = { { "oneway" }, { "lit" } }; + for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) + m_types.push_back(c.GetTypeByPath(vector(arr[i], arr[i] + 1))); + } + + bool IsValid(vector const & types) const + { + size_t const count = types.size(); + size_t uselessCount = 0; + for (size_t i = 0; i < count; ++i) + if (IsUseless(types[i])) + ++uselessCount; + return (count > uselessCount); + } + }; + bool ParseType(XMLElement * p, uint64_t & id, FeatureParams & fValue) { CHECK ( strings::to_uint64(p->attrs["id"], id), (p->attrs["id"]) ); @@ -262,7 +293,8 @@ protected: fValue.FinishAddingTypes(); // unrecognized feature by classificator - return fValue.IsValid(); + static UselessSingleTypes checker; + return fValue.IsValid() && checker.IsValid(fValue.m_Types); } class multipolygons_emitter diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index f6f058f7e2..4d9c09fcce 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -138,34 +138,6 @@ namespace }; } -namespace -{ - class UselessCheckPatch - { - uint32_t m_oneway, m_highway; - - public: - UselessCheckPatch(Classificator const & c) - { - vector v; - v.push_back("oneway"); - m_oneway = c.GetTypeByPath(v); - - v.clear(); - v.push_back("highway"); - m_highway = c.GetTypeByPath(v); - } - - bool IsHighway(uint32_t t) const - { - ftype::TruncValue(t, 1); - return (t == m_highway); - } - - bool IsOneway(uint32_t t) const { return (t == m_oneway); } - }; -} - pair GetDrawRule(FeatureBase const & f, int level, drule::KeysT & keys, string & names) { @@ -174,28 +146,13 @@ pair GetDrawRule(FeatureBase const & f, int level, ASSERT ( keys.empty(), () ); Classificator const & c = classif(); - static UselessCheckPatch patch(c); - - bool hasHighway = false; - for (size_t i = 0; i < types.Size(); ++i) - if (patch.IsHighway(types[i])) - { - hasHighway = true; - break; - } - DrawRuleGetter doRules(level, types.GetGeoType(), keys #ifdef DEBUG , names #endif ); for (size_t i = 0; i < types.Size(); ++i) - { - if (!hasHighway && patch.IsOneway(types[i])) - continue; - (void)c.ProcessObjects(types[i], doRules); - } return make_pair(types.GetGeoType(), types.Has(c.GetCoastType())); }