forked from organicmaps/organicmaps
[search] Fix bug of center and viewport calculation for results.
This commit is contained in:
parent
4da36fc55a
commit
e5c471b033
2 changed files with 13 additions and 2 deletions
|
@ -105,6 +105,10 @@ PreResult2::PreResult2(FeatureType const & f, PreResult1 const & res,
|
|||
{
|
||||
ASSERT_GREATER(m_types.Size(), 0, ());
|
||||
|
||||
// It's better to get exact center for point feature.
|
||||
if (f.GetFeatureType() == feature::GEOM_POINT)
|
||||
m_center = m_featureRect.Center();
|
||||
|
||||
// get region info
|
||||
if (!fileName.empty())
|
||||
m_region.SetName(fileName);
|
||||
|
@ -189,8 +193,7 @@ Result PreResult2::GenerateFinalResult(
|
|||
#ifdef DEBUG
|
||||
+ ' ' + strings::to_string(static_cast<int>(m_searchRank))
|
||||
#endif
|
||||
,
|
||||
type, feature::GetFeatureViewport(m_types, m_featureRect), m_distance);
|
||||
, type, GetFinalViewport(), m_distance);
|
||||
|
||||
case RESULT_LATLON:
|
||||
return Result(m_str, info.m_name, info.m_flag, string(), 0,
|
||||
|
@ -342,6 +345,13 @@ string PreResult2::GetFeatureType(CategoriesHolder const * pCat, int8_t lang) co
|
|||
return s;
|
||||
}
|
||||
|
||||
m2::RectD PreResult2::GetFinalViewport() const
|
||||
{
|
||||
m2::RectD r = feature::GetFeatureViewport(m_types, m_featureRect);
|
||||
r.SetCenter(m_center);
|
||||
return r;
|
||||
}
|
||||
|
||||
void PreResult2::RegionInfo::GetRegion(
|
||||
storage::CountryInfoGetter const * pInfo, storage::CountryInfo & info) const
|
||||
{
|
||||
|
|
|
@ -104,6 +104,7 @@ public:
|
|||
|
||||
private:
|
||||
string GetFeatureType(CategoriesHolder const * pCat, int8_t lang) const;
|
||||
m2::RectD GetFinalViewport() const;
|
||||
|
||||
feature::TypesHolder m_types;
|
||||
uint32_t GetBestType() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue