diff --git a/generator/feature_builder.hpp b/generator/feature_builder.hpp index bf8c98e40e..f77c4b6f79 100644 --- a/generator/feature_builder.hpp +++ b/generator/feature_builder.hpp @@ -54,10 +54,11 @@ public: /// Clear name if it's not visible in scale range [minS, maxS]. void RemoveNameIfInvisible(int minS = 0, int maxS = 1000); - template void RemoveTypesIf(FnT fn) + template bool RemoveTypesIf(FnT fn) { m_Params.m_Types.erase(remove_if(m_Params.m_Types.begin(), m_Params.m_Types.end(), fn), m_Params.m_Types.end()); + return m_Params.m_Types.empty(); } typedef vector buffer_t; diff --git a/generator/feature_merger.cpp b/generator/feature_merger.cpp index e75af41a2c..55d12e030f 100644 --- a/generator/feature_merger.cpp +++ b/generator/feature_merger.cpp @@ -303,7 +303,11 @@ MergedFeatureBuilder1 * FeatureTypesProcessor::operator() (FeatureBuilder1 const p->ForEachChangeTypes(do_change_types(*this)); // do preprocessing after types correction - feature::PreprocessForWorldMap(*p); + if (!feature::PreprocessForWorldMap(*p)) + { + delete p; + return 0; + } // zero all additional params for world merged features (names, ranks, ...) p->ZeroParams(); @@ -328,13 +332,16 @@ public: } }; -void PreprocessForWorldMap(FeatureBuilder1 & fb) +bool PreprocessForWorldMap(FeatureBuilder1 & fb) { int const upperScale = scales::GetUpperWorldScale(); - fb.RemoveTypesIf(IsInvisibleFn(upperScale)); + if (fb.RemoveTypesIf(IsInvisibleFn(upperScale))) + return false; fb.RemoveNameIfInvisible(0, upperScale); + + return true; } } diff --git a/generator/feature_merger.hpp b/generator/feature_merger.hpp index 9ef0c72cc1..5edbd0453a 100644 --- a/generator/feature_merger.hpp +++ b/generator/feature_merger.hpp @@ -118,5 +118,6 @@ public: namespace feature { - void PreprocessForWorldMap(FeatureBuilder1 & fb); + /// @return false If fb became invalid (no any suitable types). + bool PreprocessForWorldMap(FeatureBuilder1 & fb); } diff --git a/generator/world_map_generator.hpp b/generator/world_map_generator.hpp index 0060cf8b47..e69055cf01 100644 --- a/generator/world_map_generator.hpp +++ b/generator/world_map_generator.hpp @@ -92,11 +92,15 @@ public: if (m_worldBucket.NeedPushToWorld(fb)) { if (fb.GetGeomType() == feature::GEOM_LINE) - m_merger(m_typesCorrector(fb)); + { + MergedFeatureBuilder1 * p = m_typesCorrector(fb); + if (p) + m_merger(p); + } else { - feature::PreprocessForWorldMap(fb); - m_worldBucket.PushSure(fb); + if (feature::PreprocessForWorldMap(fb)); + m_worldBucket.PushSure(fb); } } } diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index 61a772c06b..4927d36ba0 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -179,6 +179,7 @@ void FeatureParams::SetType(uint32_t t) bool FeatureParams::PopAnyType(uint32_t & t) { + CHECK(!m_Types.empty(), ()); t = m_Types.back(); m_Types.pop_back(); return m_Types.empty();