From 2ed05b3b482e3d39fb6987f9550cc616ce89ae0c Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 23 Dec 2013 18:39:49 +0300 Subject: [PATCH] [generator] Fixed bug with point drawing types for area objects. --- .../generator_tests/feature_builder_test.cpp | 15 +++++++++++++++ indexer/feature_visibility.cpp | 15 +++++++++++++-- indexer/feature_visibility.hpp | 5 ++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/generator/generator_tests/feature_builder_test.cpp b/generator/generator_tests/feature_builder_test.cpp index 643293233a..02db1b53c0 100644 --- a/generator/generator_tests/feature_builder_test.cpp +++ b/generator/generator_tests/feature_builder_test.cpp @@ -2,6 +2,7 @@ #include "../feature_builder.hpp" +#include "../../indexer/feature_visibility.hpp" #include "../../indexer/classificator_loader.hpp" #include "../../indexer/classificator.hpp" @@ -66,3 +67,17 @@ UNIT_TEST(FBuilder_ManyTypes) TEST(fb2.CheckValid(), ()); TEST_EQUAL(fb1, fb2, ()); } + +UNIT_TEST(FVisibility_RemoveNoDrawableTypes) +{ + classificator::Load(); + Classificator const & c = classif(); + + vector types; + types.push_back(c.GetTypeByPath(vector(1, "building"))); + char const * arr[] = { "amenity", "theatre" }; + types.push_back(c.GetTypeByPath(vector(arr, arr + 2))); + + TEST(feature::RemoveNoDrawableTypes(types, feature::FEATURE_TYPE_AREA), ()); + TEST_EQUAL(types.size(), 2, ()); +} diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index 024947077f..f3dc91d1c0 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -288,8 +288,19 @@ namespace bool operator() (uint32_t t) { IsDrawableLikeChecker doCheck(m_type); - // return true if need to delete - return !m_c.ProcessObjects(t, doCheck); + if (m_c.ProcessObjects(t, doCheck)) + return false; + + // IsDrawableLikeChecker checks only unique area styles, + // so we need to take into account point styles too. + if (m_type == FEATURE_TYPE_AREA) + { + IsDrawableLikeChecker doCheck(FEATURE_TYPE_POINT); + if (m_c.ProcessObjects(t, doCheck)) + return false; + } + + return true; } }; } diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp index c7d75b5588..0965991ecc 100644 --- a/indexer/feature_visibility.hpp +++ b/indexer/feature_visibility.hpp @@ -28,10 +28,9 @@ namespace feature bool IsDrawableAny(uint32_t type); bool IsDrawableForIndex(FeatureBase const & f, int level); - /// @name Be carefull with FEATURE_TYPE_AREA. - /// It's check only unique area styles, be it also can draw symbol or caption. - //@{ + /// For FEATURE_TYPE_AREA need to have at least one area-filling type. bool IsDrawableLike(vector const & types, FeatureGeoType ft); + /// For FEATURE_TYPE_AREA removes line-drawing only types. bool RemoveNoDrawableTypes(vector & types, FeatureGeoType ft); //@}