forked from organicmaps/organicmaps
[search] Process feature types like 2-level types (trim 3 level).
This commit is contained in:
parent
c0d319f011
commit
99b8b11f7f
4 changed files with 19 additions and 15 deletions
|
@ -283,14 +283,7 @@ void FeatureTypesProcessor::CorrectType(uint32_t & t) const
|
|||
|
||||
// 1. get normalized type:
|
||||
// highway-motorway-bridge => highway-motorway
|
||||
uint32_t normal = ftype::GetEmptyValue();
|
||||
uint8_t v;
|
||||
if (!ftype::GetValue(t, 0, v)) return;
|
||||
ftype::PushValue(normal, v);
|
||||
if (!ftype::GetValue(t, 1, v)) return;
|
||||
ftype::PushValue(normal, v);
|
||||
|
||||
t = normal;
|
||||
ftype::TruncValue(t, 2);
|
||||
|
||||
// 2. get mapping type:
|
||||
map<uint32_t, uint32_t>::const_iterator i = m_mapping.find(t);
|
||||
|
|
|
@ -256,12 +256,18 @@ public:
|
|||
// add names of categories of the feature
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
{
|
||||
uint32_t type = types[i];
|
||||
|
||||
// Leave only 2 level of type - for example, do not distinguish:
|
||||
// highway-primary-oneway or amenity-parking-fee.
|
||||
ftype::TruncValue(type, 2);
|
||||
|
||||
// Do index only for visible types in mwm.
|
||||
pair<int, int> const r = feature::DrawableScaleRangeForType(types[i]);
|
||||
pair<int, int> const r = feature::DrawableScaleRangeForType(type);
|
||||
if (my::between_s(m_scales.first, m_scales.second, r.first) ||
|
||||
my::between_s(m_scales.first, m_scales.second, r.second))
|
||||
{
|
||||
inserter.AddToken(search::CATEGORIES_LANG, search::FeatureTypeToString(types[i]));
|
||||
inserter.AddToken(search::CATEGORIES_LANG, search::FeatureTypeToString(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,6 +304,15 @@ string PreResult2::DebugPrint() const
|
|||
return res;
|
||||
}
|
||||
|
||||
uint32_t PreResult2::GetBestType() const
|
||||
{
|
||||
/// @todo Need to process all types.
|
||||
|
||||
uint32_t t = m_types.GetBestType();
|
||||
ftype::TruncValue(t, 2);
|
||||
return t;
|
||||
}
|
||||
|
||||
string PreResult2::GetFeatureType(CategoriesHolder const * pCat, int8_t lang) const
|
||||
{
|
||||
ASSERT_EQUAL(m_resultType, RESULT_FEATURE, ());
|
||||
|
|
|
@ -106,11 +106,7 @@ private:
|
|||
string GetFeatureType(CategoriesHolder const * pCat, int8_t lang) const;
|
||||
|
||||
feature::TypesHolder m_types;
|
||||
inline uint32_t GetBestType() const
|
||||
{
|
||||
/// @todo Need to process all types.
|
||||
return m_types.GetBestType();
|
||||
}
|
||||
uint32_t GetBestType() const;
|
||||
|
||||
string m_str, m_completionString;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue