diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index c73c66115a..2635527b2c 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -471,11 +471,12 @@ void RuleDrawer::operator()(FeatureType & f) } #endif + /// @todo Call feature::GetMinDrawableScale() here. int minVisibleScale = 0; auto insertShape = [this, &minVisibleScale](drape_ptr && shape) { - int const index = static_cast(shape->GetType()); - ASSERT_LESS(index, static_cast(m_mapShapes.size()), ()); + size_t const index = shape->GetType(); + ASSERT_LESS(index, m_mapShapes.size(), ()); shape->SetFeatureMinZoom(minVisibleScale); m_mapShapes[index].push_back(std::move(shape)); diff --git a/indexer/feature.cpp b/indexer/feature.cpp index d6d775d6d1..5dcb5a4875 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -691,6 +691,8 @@ m2::RectD FeatureType::GetLimitRect(int scale) if (m_triangles.empty() && m_points.empty() && (GetGeomType() != GeomType::Point)) { + ASSERT(false, ()); + // This function is called during indexing, when we need // to check visibility according to feature sizes. // So, if no geometry for this scale, assume that rect has zero dimensions. @@ -700,6 +702,14 @@ m2::RectD FeatureType::GetLimitRect(int scale) return m_limitRect; } +m2::RectD const & FeatureType::GetLimitRectChecked() const +{ + /// @todo Replace with ASSERTs later. + CHECK(m_parsed.m_points && m_parsed.m_triangles, (m_id)); + CHECK(m_limitRect.IsValid(), (m_id)); + return m_limitRect; +} + bool FeatureType::IsEmptyGeometry(int scale) { ParseGeometryAndTriangles(scale); diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 11b16984db..a3d379fce2 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -86,6 +86,7 @@ public: enum { BEST_GEOMETRY = -1, WORST_GEOMETRY = -2 }; m2::RectD GetLimitRect(int scale); + m2::RectD const & GetLimitRectChecked() const; bool IsEmptyGeometry(int scale); diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index 28aabc0042..b86dc48598 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -191,7 +191,7 @@ namespace return base::IsExist(arrTypes, type); } /// @} -} // namespace +} // namespace bool IsCategoryNondrawableType(uint32_t type) { @@ -215,24 +215,9 @@ bool CanGenerateLike(vector const & types, GeomType geomType) return false; } -bool IsDrawableForIndex(FeatureType & ft, int level) +namespace { - return IsDrawableForIndexGeometryOnly(ft, level) && - IsDrawableForIndexClassifOnly(TypesHolder(ft), level); -} - -bool IsDrawableForIndex(TypesHolder const & types, m2::RectD limitRect, int level) -{ - return IsDrawableForIndexGeometryOnly(types, limitRect, level) && - IsDrawableForIndexClassifOnly(types, level); -} - -bool IsDrawableForIndexGeometryOnly(FeatureType & ft, int level) -{ - return IsDrawableForIndexGeometryOnly(TypesHolder(ft), - ft.GetLimitRect(FeatureType::BEST_GEOMETRY), level); -} -bool IsDrawableForIndexGeometryOnly(TypesHolder const & types, m2::RectD limitRect, int level) +bool IsDrawableForIndexGeometryOnly(TypesHolder const & types, m2::RectD const & limitRect, int level) { Classificator const & c = classif(); @@ -259,6 +244,24 @@ bool IsDrawableForIndexClassifOnly(TypesHolder const & types, int level) return false; } +} // namespace + +bool IsDrawableForIndex(FeatureType & ft, int level) +{ + return IsDrawableForIndexGeometryOnly(ft, level) && + IsDrawableForIndexClassifOnly(TypesHolder(ft), level); +} + +bool IsDrawableForIndex(TypesHolder const & types, m2::RectD const & limitRect, int level) +{ + return IsDrawableForIndexGeometryOnly(types, limitRect, level) && + IsDrawableForIndexClassifOnly(types, level); +} + +bool IsDrawableForIndexGeometryOnly(FeatureType & ft, int level) +{ + return IsDrawableForIndexGeometryOnly(TypesHolder(ft), ft.GetLimitRectChecked(), level); +} bool IsUsefulType(uint32_t t, GeomType geomType, bool emptyName) { @@ -293,10 +296,10 @@ bool RemoveUselessTypes(vector & types, GeomType geomType, bool emptyN int GetMinDrawableScale(FeatureType & ft) { - return GetMinDrawableScale(TypesHolder(ft), ft.GetLimitRect(FeatureType::BEST_GEOMETRY)); + return GetMinDrawableScale(TypesHolder(ft), ft.GetLimitRectChecked()); } -int GetMinDrawableScale(TypesHolder const & types, m2::RectD limitRect) +int GetMinDrawableScale(TypesHolder const & types, m2::RectD const & limitRect) { int const upBound = scales::GetUpperStyleScale(); @@ -309,7 +312,8 @@ int GetMinDrawableScale(TypesHolder const & types, m2::RectD limitRect) return -1; } -int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD limitRect) +/* +int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD const & limitRect) { int const upBound = scales::GetUpperStyleScale(); @@ -321,6 +325,7 @@ int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD limitRe return -1; } +*/ int GetMinDrawableScaleClassifOnly(TypesHolder const & types) { @@ -445,4 +450,4 @@ bool TypeSetChecker::IsEqual(uint32_t type) const ftype::TruncValue(type, m_level); return (m_type == type); } -} // namespace feature +} // namespace feature diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp index cab998262b..48b8c6c986 100644 --- a/indexer/feature_visibility.hpp +++ b/indexer/feature_visibility.hpp @@ -1,14 +1,9 @@ #pragma once #include "indexer/drawing_rule_def.hpp" -#include "indexer/feature.hpp" #include "indexer/feature_decl.hpp" -#include "base/base.hpp" - -#include #include -#include #include #include @@ -21,15 +16,15 @@ namespace feature bool IsCategoryNondrawableType(uint32_t type); bool IsUsefulType(uint32_t type); bool IsDrawableForIndex(FeatureType & ft, int level); - bool IsDrawableForIndex(TypesHolder const & types, m2::RectD limitRect, int level); + bool IsDrawableForIndex(TypesHolder const & types, m2::RectD const & limitRect, int level); // The separation into ClassifOnly and GeometryOnly versions is needed to speed up // the geometrical index (see indexer/scale_index_builder.hpp). // Technically, the GeometryOnly version uses the classificator, but it only does // so when checking against coastlines. - bool IsDrawableForIndexClassifOnly(TypesHolder const & types, int level); + //bool IsDrawableForIndexClassifOnly(TypesHolder const & types, int level); bool IsDrawableForIndexGeometryOnly(FeatureType & ft, int level); - bool IsDrawableForIndexGeometryOnly(TypesHolder const & types, m2::RectD limitRect, int level); + //bool IsDrawableForIndexGeometryOnly(TypesHolder const & types, m2::RectD const & limitRect, int level); /// @name Generator check functions. /// @{ @@ -43,8 +38,8 @@ namespace feature /// @} int GetMinDrawableScale(FeatureType & ft); - int GetMinDrawableScale(TypesHolder const & types, m2::RectD limitRect); - int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD limitRect); + int GetMinDrawableScale(TypesHolder const & types, m2::RectD const & limitRect); + //int GetMinDrawableScaleGeometryOnly(TypesHolder const & types, m2::RectD limitRect); int GetMinDrawableScaleClassifOnly(TypesHolder const & types); /// @return [-1, -1] if range is not drawable @@ -66,7 +61,6 @@ namespace feature std::pair GetDrawableScaleRangeForRules(TypesHolder const & types, int rules); //@} - /// @return (geometry type, is coastline) void GetDrawRule(TypesHolder const & types, int level, drule::KeysT & keys); void GetDrawRule(std::vector const & types, int level, GeomType geomType, drule::KeysT & keys); void FilterRulesByRuntimeSelector(FeatureType & f, int zoomLevel, drule::KeysT & keys); @@ -95,4 +89,4 @@ namespace feature return IsEqualR(v.begin(), v.end()); } }; -} +} // namespace feature