From 7e2bcc9a00a8825ba7f0cac5900ba4a215041d7b Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 9 Sep 2011 17:26:08 +0300 Subject: [PATCH] Fix coastline feature processing: skip other types and additional checks after types manipulating. --- generator/feature_builder.cpp | 17 +++++++++++++++++ generator/feature_builder.hpp | 7 +++++++ generator/feature_generator.cpp | 7 ++++++- generator/feature_merger.hpp | 1 - indexer/feature_data.hpp | 1 + indexer/feature_visibility.hpp | 7 ++++++- 6 files changed, 37 insertions(+), 3 deletions(-) diff --git a/generator/feature_builder.cpp b/generator/feature_builder.cpp index dad16f1cd3..0dc2293395 100644 --- a/generator/feature_builder.cpp +++ b/generator/feature_builder.cpp @@ -75,6 +75,23 @@ void FeatureBuilder1::AddPolygon(vector & poly) m_Polygons.back().swap(poly); } +void FeatureBuilder1::DoCorrectForType(EGeomType type) +{ + if (m_Params.GetGeomType() == type && + !IsDrawableLike(m_Params.m_Types, static_cast(type))) + { + m_Params.RemoveGeomType(type); + } +} + +bool FeatureBuilder1::DoCorrect() +{ + DoCorrectForType(GEOM_AREA); + DoCorrectForType(GEOM_LINE); + + return (m_Params.GetGeomType() != GEOM_UNDEFINED); +} + FeatureBase FeatureBuilder1::GetFeatureBase() const { CHECK ( CheckValid(), (*this) ); diff --git a/generator/feature_builder.hpp b/generator/feature_builder.hpp index 7bb871d803..019c1268c4 100644 --- a/generator/feature_builder.hpp +++ b/generator/feature_builder.hpp @@ -43,6 +43,13 @@ public: inline void AddType(uint32_t type) { m_Params.AddType(type); } inline bool HasType(uint32_t t) const { return m_Params.IsTypeExist(t); } inline bool PopExactType(uint32_t type) { return m_Params.PopExactType(type); } + inline void SetType(uint32_t type) { m_Params.SetType(type); } + + /// Check for feature visibility according to it's types. + /// If feature is invisible, it's not correct. + /// This fuction is called after it's classificator types manipulating. + void DoCorrectForType(feature::EGeomType type); + bool DoCorrect(); typedef vector buffer_t; diff --git a/generator/feature_generator.cpp b/generator/feature_generator.cpp index 434634d32c..a941cbfd45 100644 --- a/generator/feature_generator.cpp +++ b/generator/feature_generator.cpp @@ -282,10 +282,15 @@ public: if (m_coasts) { if (fb.HasType(m_coastType)) + { + // leave only coastline type + fb.SetType(m_coastType); (*m_coasts)(fb); + } } - if (!fb.PopExactType(m_coastType)) + // remove coastline type + if (!fb.PopExactType(m_coastType) && fb.DoCorrect()) { if (m_world) (*m_world)(fb); diff --git a/generator/feature_merger.hpp b/generator/feature_merger.hpp index 54030beaee..f98029f819 100644 --- a/generator/feature_merger.hpp +++ b/generator/feature_merger.hpp @@ -31,7 +31,6 @@ public: inline m2::PointD FirstPoint() const { return GetGeometry().front(); } inline m2::PointD LastPoint() const { return GetGeometry().back(); } - inline void SetType(uint32_t type) { m_Params.SetType(type); } inline bool PopAnyType(uint32_t & type) { return m_Params.PopAnyType(type); } template void ForEachChangeTypes(ToDo toDo) diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp index 1c319eb684..3a1fe60b2d 100644 --- a/indexer/feature_data.hpp +++ b/indexer/feature_data.hpp @@ -14,6 +14,7 @@ namespace feature enum EGeomType { GEOM_UNDEFINED = -1, + // Note! do not change this values. Should be equal with FeatureGeoType. GEOM_POINT = 0, GEOM_LINE = 1, GEOM_AREA = 2 diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp index 208f5430ea..9a1f5a34fd 100644 --- a/indexer/feature_visibility.hpp +++ b/indexer/feature_visibility.hpp @@ -13,7 +13,12 @@ class FeatureBase; namespace feature { - enum FeatureGeoType { FEATURE_TYPE_POINT = 0, FEATURE_TYPE_LINE, FEATURE_TYPE_AREA }; + // Note! do not change this values. Should be equal with EGeomType. + enum FeatureGeoType { + FEATURE_TYPE_POINT = 0, + FEATURE_TYPE_LINE = 1, + FEATURE_TYPE_AREA = 2 + }; bool IsDrawableAny(uint32_t type); bool IsDrawableLike(vector const & type, FeatureGeoType ft);