forked from organicmaps/organicmaps
[search] Show city name in search results.
This commit is contained in:
parent
07e407b360
commit
da54d1b28f
4 changed files with 57 additions and 5 deletions
|
@ -109,6 +109,17 @@ pair<uint16_t, uint16_t> const & Result::GetHighlightRange(size_t idx) const
|
|||
return m_hightlightRanges[idx];
|
||||
}
|
||||
|
||||
void Result::AppendCity(string const & name)
|
||||
{
|
||||
if (name.empty())
|
||||
return;
|
||||
|
||||
if (m_region.empty())
|
||||
m_region = name;
|
||||
else
|
||||
m_region += (", " + name);
|
||||
}
|
||||
|
||||
bool Results::AddResultCheckExisting(Result const & r)
|
||||
{
|
||||
if (find(m_vec.begin(), m_vec.end(), r) == m_vec.end())
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
pair<uint16_t, uint16_t> const & GetHighlightRange(size_t idx) const;
|
||||
inline size_t GetHighlightRangesCount() const { return m_hightlightRanges.size(); }
|
||||
|
||||
void AppendCity(string const & name);
|
||||
|
||||
private:
|
||||
FeatureID m_id;
|
||||
|
|
|
@ -78,7 +78,12 @@ Query::Query(Index const * pIndex,
|
|||
m_pCategories(pCategories),
|
||||
m_pStringsToSuggest(pStringsToSuggest),
|
||||
m_pInfoGetter(pInfoGetter),
|
||||
#ifdef HOUSE_SEARCH_TEST
|
||||
m_houseDetector(pIndex),
|
||||
#endif
|
||||
#ifdef FIND_LOCALITY_TEST
|
||||
m_locality(pIndex),
|
||||
#endif
|
||||
m_worldSearch(true),
|
||||
m_sortByViewport(false),
|
||||
m_position(empty_pos_value, empty_pos_value)
|
||||
|
@ -157,10 +162,20 @@ void Query::SetViewportByIndex(MWMVectorT const & mwmInfo, m2::RectD const & vie
|
|||
{
|
||||
m_viewport[idx] = viewport;
|
||||
UpdateViewportOffsets(mwmInfo, viewport, m_offsetsInViewport[idx]);
|
||||
|
||||
#ifdef FIND_LOCALITY_TEST
|
||||
m_locality.SetViewportByIndex(mwmInfo, viewport, idx);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearCache(idx);
|
||||
|
||||
#ifdef FIND_LOCALITY_TEST
|
||||
m_locality.ClearCache(idx);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Query::SetPreferredLanguage(string const & lang)
|
||||
|
@ -171,6 +186,10 @@ void Query::SetPreferredLanguage(string const & lang)
|
|||
// Default initialization.
|
||||
// If you want to reset input language, call SetInputLanguage before search.
|
||||
SetInputLanguage(code);
|
||||
|
||||
#ifdef FIND_LOCALITY_TEST
|
||||
m_locality.SetLanguage(code);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Query::SetInputLanguage(int8_t lang)
|
||||
|
@ -730,9 +749,12 @@ ftypes::Type Query::GetLocalityIndex(feature::TypesHolder const & types) const
|
|||
Type const type = IsLocalityChecker::Instance().GetType(types);
|
||||
switch (type)
|
||||
{
|
||||
case TOWN: return CITY;
|
||||
case VILLAGE: return NONE;
|
||||
default: return type;
|
||||
case TOWN:
|
||||
return CITY;
|
||||
case VILLAGE:
|
||||
return NONE;
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -930,11 +952,20 @@ public:
|
|||
};
|
||||
|
||||
|
||||
|
||||
Result Query::MakeResult(impl::PreResult2 const & r) const
|
||||
{
|
||||
Result res = r.GenerateFinalResult(m_pInfoGetter, m_pCategories, &m_prefferedTypes, GetLanguage(LANG_CURRENT));
|
||||
MakeResultHighlight(res);
|
||||
|
||||
#ifdef FIND_LOCALITY_TEST
|
||||
if (ftypes::IsLocalityChecker::Instance().GetType(r.GetTypes()) == ftypes::NONE)
|
||||
{
|
||||
string city;
|
||||
m_locality.GetLocality(res.GetFeatureCenter(), city);
|
||||
res.AppendCity(city);
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,16 @@
|
|||
|
||||
|
||||
#define HOUSE_SEARCH_TEST
|
||||
#define FIND_LOCALITY_TEST
|
||||
|
||||
#ifdef HOUSE_SEARCH_TEST
|
||||
#include "house_detector.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef FIND_LOCALITY_TEST
|
||||
#include "locality_finder.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
class FeatureType;
|
||||
class CategoriesHolder;
|
||||
|
@ -223,7 +228,11 @@ private:
|
|||
#ifdef HOUSE_SEARCH_TEST
|
||||
strings::UniString m_house;
|
||||
vector<FeatureID> m_streetID;
|
||||
search::HouseDetector m_houseDetector;
|
||||
HouseDetector m_houseDetector;
|
||||
#endif
|
||||
|
||||
#ifdef FIND_LOCALITY_TEST
|
||||
LocalityFinder m_locality;
|
||||
#endif
|
||||
|
||||
static int const MAX_SUGGESTS_COUNT = 5;
|
||||
|
|
Loading…
Add table
Reference in a new issue