forked from organicmaps/organicmaps
[search] Index generation: skip type 'building' for features with no names.
This commit is contained in:
parent
99179605b3
commit
fa598cd43e
3 changed files with 40 additions and 3 deletions
|
@ -23,6 +23,16 @@ string TypesHolder::DebugPrint() const
|
|||
return s;
|
||||
}
|
||||
|
||||
void TypesHolder::Remove(uint32_t t)
|
||||
{
|
||||
if (m_size > 0)
|
||||
{
|
||||
uint32_t * e = m_types + m_size;
|
||||
if (std::remove(m_types, e, t) != e)
|
||||
--m_size;
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureParamsBase::MakeZero()
|
||||
{
|
||||
layer = 0;
|
||||
|
|
|
@ -67,6 +67,7 @@ namespace feature
|
|||
//@{
|
||||
inline EGeomType GetGeoType() const { return m_geoType; }
|
||||
|
||||
inline bool Empty() const { return (m_size == 0); }
|
||||
inline size_t Size() const { return m_size; }
|
||||
inline uint32_t operator[] (size_t i) const
|
||||
{
|
||||
|
@ -84,6 +85,8 @@ namespace feature
|
|||
uint32_t const * e = m_types + m_size;
|
||||
return (find(m_types, e, t) != e);
|
||||
}
|
||||
|
||||
void Remove(uint32_t t);
|
||||
//@}
|
||||
|
||||
string DebugPrint() const;
|
||||
|
|
|
@ -206,9 +206,12 @@ class FeatureInserter
|
|||
}
|
||||
}
|
||||
|
||||
vector<uint32_t> m_skip;
|
||||
|
||||
public:
|
||||
AvoidEmptyName()
|
||||
{
|
||||
// Get types which not shoud be indexed without names.
|
||||
char const * arr1[][1] = { { "highway" }, { "natural" }, { "waterway"}, { "landuse" } };
|
||||
|
||||
char const * arr2[][2] = {
|
||||
|
@ -222,9 +225,19 @@ class FeatureInserter
|
|||
|
||||
FillMatch(arr1);
|
||||
FillMatch(arr2);
|
||||
|
||||
// Get types which shoud be skipped for features without names.
|
||||
char const * arrSkip1[][1] = { { "building" } };
|
||||
|
||||
Classificator const & c = classif();
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arrSkip1); ++i)
|
||||
{
|
||||
vector<string> v(arrSkip1[i], arrSkip1[i] + 1);
|
||||
m_skip.push_back(c.GetTypeByPath(v));
|
||||
}
|
||||
}
|
||||
|
||||
bool IsExist(feature::TypesHolder const & types) const
|
||||
bool IsMatch(feature::TypesHolder const & types) const
|
||||
{
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
for (size_t j = 0; j < ARRAY_SIZE(m_match); ++j)
|
||||
|
@ -238,6 +251,12 @@ class FeatureInserter
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SkipTypes(feature::TypesHolder & types)
|
||||
{
|
||||
for (size_t i = 0; i < m_skip.size(); ++i)
|
||||
types.Remove(m_skip[i]);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -261,13 +280,18 @@ public:
|
|||
if (!f.ForEachNameRef(inserter))
|
||||
{
|
||||
static AvoidEmptyName check;
|
||||
if (check.IsExist(types))
|
||||
if (check.IsMatch(types))
|
||||
{
|
||||
// Do not add such features without names to suggestion list.
|
||||
// Do not add features without names to index.
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip types for features without names.
|
||||
check.SkipTypes(types);
|
||||
}
|
||||
|
||||
if (types.Empty()) return;
|
||||
|
||||
// add names of categories of the feature
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue