forked from organicmaps/organicmaps-tmp
[search] Optimized features retrieval for street synonyms.
This commit is contained in:
parent
a93cb21573
commit
74b9f3ab0a
4 changed files with 35 additions and 3 deletions
|
@ -525,8 +525,9 @@ bool Retrieval::InitBucketStrategy(Bucket & bucket, double scale)
|
|||
|
||||
try
|
||||
{
|
||||
addressFeatures = RetrieveAddressFeatures(*bucket.m_handle.GetValue<MwmValue>(),
|
||||
*this /* cancellable */, m_params);
|
||||
addressFeatures =
|
||||
RetrieveAddressFeatures(*bucket.m_handle.GetValue<MwmValue>(), *this /* cancellable */,
|
||||
m_params);
|
||||
}
|
||||
catch (CancelException &)
|
||||
{
|
||||
|
|
|
@ -120,6 +120,12 @@ SearchQueryParams::TSynonymsVector const & SearchQueryParams::GetTokens(size_t i
|
|||
return i < m_tokens.size() ? m_tokens[i] : m_prefixTokens;
|
||||
}
|
||||
|
||||
SearchQueryParams::TSynonymsVector & SearchQueryParams::GetTokens(size_t i)
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL(i, m_tokens.size(), ());
|
||||
return i < m_tokens.size() ? m_tokens[i] : m_prefixTokens;
|
||||
}
|
||||
|
||||
template <class ToDo>
|
||||
void SearchQueryParams::ForEachToken(ToDo && toDo)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ struct SearchQueryParams
|
|||
inline bool IsLangExist(int8_t l) const { return (m_langs.count(l) > 0); }
|
||||
|
||||
TSynonymsVector const & GetTokens(size_t i) const;
|
||||
TSynonymsVector & GetTokens(size_t i);
|
||||
|
||||
private:
|
||||
template <class ToDo>
|
||||
|
|
|
@ -168,6 +168,14 @@ void GetEnglishName(FeatureType const & ft, string & name)
|
|||
}
|
||||
}
|
||||
|
||||
bool IsStreetCategory(strings::UniString const & category)
|
||||
{
|
||||
static auto const kCategoriesList = GetStreetCategories();
|
||||
static set<strings::UniString> const kCategoriesSet(kCategoriesList.begin(),
|
||||
kCategoriesList.end());
|
||||
return kCategoriesSet.count(category) != 0;
|
||||
}
|
||||
|
||||
template <typename TFn>
|
||||
void ForEachStreetCategory(TFn && fn)
|
||||
{
|
||||
|
@ -304,6 +312,19 @@ void Geocoder::SetParams(Params const & params)
|
|||
if (!m_params.m_prefixTokens.empty())
|
||||
++m_numTokens;
|
||||
|
||||
// Remove all category synonyms for streets, as they're extracted
|
||||
// individually via LoadStreets.
|
||||
for (size_t i = 0; i < m_numTokens; ++i)
|
||||
{
|
||||
auto & synonyms = m_params.GetTokens(i);
|
||||
if (!synonyms.empty() && IsStreetSynonym(synonyms.front()))
|
||||
{
|
||||
auto b = synonyms.begin();
|
||||
auto e = synonyms.end();
|
||||
synonyms.erase(remove_if(b + 1, e, &IsStreetCategory), e);
|
||||
}
|
||||
}
|
||||
|
||||
LOG(LDEBUG, ("Languages =", m_params.m_langs));
|
||||
}
|
||||
|
||||
|
@ -423,7 +444,10 @@ void Geocoder::GoImpl(vector<shared_ptr<MwmInfo>> & infos, bool inViewport)
|
|||
ASSERT(m_addressFeatures[i], ());
|
||||
|
||||
if (viewportCBV)
|
||||
m_addressFeatures[i] = coding::CompressedBitVector::Intersect(*m_addressFeatures[i], *viewportCBV);
|
||||
{
|
||||
m_addressFeatures[i] =
|
||||
coding::CompressedBitVector::Intersect(*m_addressFeatures[i], *viewportCBV);
|
||||
}
|
||||
}
|
||||
|
||||
m_streets = LoadStreets(*m_context);
|
||||
|
|
Loading…
Add table
Reference in a new issue