forked from organicmaps/organicmaps
[feature] Updated visibility functions.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
parent
3607c8d5e9
commit
dd8ec3bde7
5 changed files with 47 additions and 36 deletions
|
@ -471,11 +471,12 @@ void RuleDrawer::operator()(FeatureType & f)
|
|||
}
|
||||
#endif
|
||||
|
||||
/// @todo Call feature::GetMinDrawableScale() here.
|
||||
int minVisibleScale = 0;
|
||||
auto insertShape = [this, &minVisibleScale](drape_ptr<MapShape> && shape)
|
||||
{
|
||||
int const index = static_cast<int>(shape->GetType());
|
||||
ASSERT_LESS(index, static_cast<int>(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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace
|
|||
return base::IsExist(arrTypes, type);
|
||||
}
|
||||
/// @}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
bool IsCategoryNondrawableType(uint32_t type)
|
||||
{
|
||||
|
@ -215,24 +215,9 @@ bool CanGenerateLike(vector<uint32_t> 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<uint32_t> & 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
|
||||
|
|
|
@ -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 <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -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<int, int> 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<uint32_t> 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
|
||||
|
|
Loading…
Add table
Reference in a new issue