forked from organicmaps/organicmaps-tmp
Merge pull request #2458 from bykoianko/master-searching-groups-in-downloader
[new downloader] Search in downloader in group mwms.
This commit is contained in:
commit
aa16f2aeda
4 changed files with 48 additions and 5 deletions
|
@ -1071,14 +1071,25 @@ bool Framework::Search(search::SearchParams const & params)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Framework::GetGroupCountryIdFromFeature(FeatureType const & ft, string & name) const
|
||||
{
|
||||
static vector<int8_t> const langIndices = {StringUtf8Multilang::GetLangIndex("en"),
|
||||
FeatureType::DEFAULT_LANG,
|
||||
StringUtf8Multilang::kInternationalCode};
|
||||
|
||||
for (auto const langIndex : langIndices)
|
||||
{
|
||||
if (!ft.GetName(langIndex, name))
|
||||
continue;
|
||||
if (Storage().IsCoutryIdCountryTreeInnerNode(name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Framework::SearchInDownloader(DownloaderSearchParams const & params)
|
||||
{
|
||||
// @TODO(bykoianko) It's necessary to implement searching in Storage
|
||||
// for group and leaf mwms based on country tree.
|
||||
|
||||
// Searching based on World.mwm.
|
||||
search::SearchParams searchParam;
|
||||
|
||||
searchParam.m_query = params.m_query;
|
||||
searchParam.m_inputLocale = params.m_inputLocale;
|
||||
searchParam.SetMode(search::Mode::World);
|
||||
|
@ -1091,6 +1102,27 @@ bool Framework::SearchInDownloader(DownloaderSearchParams const & params)
|
|||
{
|
||||
if (!it->HasPoint())
|
||||
continue;
|
||||
|
||||
if (it->GetResultType() != search::Result::RESULT_LATLON)
|
||||
{
|
||||
FeatureID const & fid = it->GetFeatureID();
|
||||
Index::FeaturesLoaderGuard loader(m_model.GetIndex(), fid.m_mwmId);
|
||||
FeatureType ft;
|
||||
loader.GetFeatureByIndex(fid.m_index, ft);
|
||||
ftypes::Type const type = ftypes::IsLocalityChecker::Instance().GetType(ft);
|
||||
|
||||
if (type == ftypes::COUNTRY || type == ftypes::STATE)
|
||||
{
|
||||
string groupFeatureName;
|
||||
if (GetGroupCountryIdFromFeature(ft, groupFeatureName))
|
||||
{
|
||||
downloaderSearchResults.m_results.emplace_back(groupFeatureName,
|
||||
it->GetString() /* m_matchedName */);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto const & mercator = it->GetFeatureCenter();
|
||||
TCountryId const & countryId = CountryInfoGetter().GetRegionCountryId(mercator);
|
||||
if (countryId == kInvalidCountryId)
|
||||
|
|
|
@ -214,6 +214,7 @@ public:
|
|||
//@}
|
||||
|
||||
storage::Storage & Storage() { return m_storage; }
|
||||
storage::Storage const & Storage() const { return m_storage; }
|
||||
storage::CountryInfoGetter & CountryInfoGetter() { return *m_infoGetter; }
|
||||
|
||||
/// @name Bookmarks, Tracks and other UserMarks
|
||||
|
@ -389,6 +390,7 @@ private:
|
|||
|
||||
void OnUpdateGpsTrackPointsCallback(vector<pair<size_t, location::GpsTrackInfo>> && toAdd,
|
||||
pair<size_t, size_t> const & toRemove);
|
||||
bool GetGroupCountryIdFromFeature(FeatureType const & ft, string & name) const;
|
||||
|
||||
public:
|
||||
using TSearchRequest = search::QuerySaver::TSearchRequest;
|
||||
|
|
|
@ -308,6 +308,14 @@ bool Storage::IsCoutryIdCountryTreeLeaf(TCountryId const & countryId) const
|
|||
return node != nullptr && node->ChildrenCount() == 0 /* countryId is a leaf. */;
|
||||
}
|
||||
|
||||
bool Storage::IsCoutryIdCountryTreeInnerNode(TCountryId const & countryId) const
|
||||
{
|
||||
if (!IsCountryIdValid(countryId))
|
||||
return false;
|
||||
TCountryTreeNode const * const node = m_countries.FindFirst(countryId);
|
||||
return node != nullptr && node->ChildrenCount() != 0 /* countryId is an inner node. */;
|
||||
}
|
||||
|
||||
TLocalAndRemoteSize Storage::CountrySizeInBytes(TCountryId const & countryId, MapOptions opt) const
|
||||
{
|
||||
QueuedCountry const * queuedCountry = FindCountryInQueue(countryId);
|
||||
|
|
|
@ -434,6 +434,7 @@ public:
|
|||
TCountryId FindCountryIdByFile(string const & name) const;
|
||||
|
||||
bool IsCoutryIdCountryTreeLeaf(TCountryId const & countryId) const;
|
||||
bool IsCoutryIdCountryTreeInnerNode(TCountryId const & countryId) const;
|
||||
|
||||
TLocalAndRemoteSize CountrySizeInBytes(TCountryId const & countryId, MapOptions opt) const;
|
||||
platform::CountryFile const & GetCountryFile(TCountryId const & countryId) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue