diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 69d28a3394..84eb377eb6 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -51,7 +51,6 @@ public: m_TypeSmallVillage[2] = GetType("place", "farm"); } - /* void CorrectScaleForVisibility(TypesHolder const & types, int & scale) const { pair const scaleR = feature::DrawableScaleRangeForText(types); @@ -67,26 +66,19 @@ public: return ((scale != scaleNew) ? scales::GetRectForLevel(scaleNew, rect.Center(), 1.0) : rect); } - */ - m2::RectD GetViewport(TypesHolder const & types, m2::PointD const & center) const + m2::RectD GetViewport(TypesHolder const & types, m2::RectD const & limitRect) const { + if (types.GetGeoType() != feature::GEOM_POINT) + return CorrectRectForScales(types, limitRect); + int const upperScale = scales::GetUpperScale(); int scale = upperScale; for (size_t i = 0; i < types.Size(); ++i) scale = min(scale, GetScaleForType(types[i])); - if (scale == upperScale) - { - // get minimal draw text scale for feature type, that not mentioned in GetScaleForType - scale = feature::DrawableScaleRangeForText(types).first; - - // if no texts at all - show at maximum zoom - if (scale == -1) - scale = upperScale; - } - - return scales::GetRectForLevel(scale, center, 1.0); + CorrectScaleForVisibility(types, scale); + return scales::GetRectForLevel(scale, limitRect.Center(), 1.0); } uint8_t GetSearchRank(TypesHolder const & types, m2::PointD const & pt, uint32_t population) const @@ -214,9 +206,9 @@ FeatureEstimator const & GetFeatureEstimator() } // namespace feature::impl -m2::RectD GetFeatureViewport(TypesHolder const & types, m2::PointD const & center) +m2::RectD GetFeatureViewport(TypesHolder const & types, m2::RectD const & limRect) { - return impl::GetFeatureEstimator().GetViewport(types, center); + return impl::GetFeatureEstimator().GetViewport(types, limRect); } uint8_t GetSearchRank(TypesHolder const & types, m2::PointD const & pt, uint32_t population) diff --git a/indexer/feature_utils.hpp b/indexer/feature_utils.hpp index 93906eedbe..0691682e9e 100644 --- a/indexer/feature_utils.hpp +++ b/indexer/feature_utils.hpp @@ -10,7 +10,7 @@ namespace feature class TypesHolder; /// Get viewport to show given feature. Used in search. - m2::RectD GetFeatureViewport(TypesHolder const & types, m2::PointD const & center); + m2::RectD GetFeatureViewport(TypesHolder const & types, m2::RectD const & limRect); /// Get search rank for a feature. /// Roughly, rank + 1 means that feature is 1.x times more popular. diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp index ace904d9d2..9e9c7ff57d 100644 --- a/search/intermediate_result.cpp +++ b/search/intermediate_result.cpp @@ -96,6 +96,7 @@ PreResult2::PreResult2(FeatureType const & f, PreResult1 const & res, string const & displayName, string const & fileName) : m_types(f), m_str(displayName), + m_featureRect(f.GetLimitRect(FeatureType::WORST_GEOMETRY)), m_center(res.m_center), m_distance(res.m_distance), m_resultType(RESULT_FEATURE), @@ -189,7 +190,7 @@ Result PreResult2::GenerateFinalResult( + ' ' + strings::to_string(static_cast(m_searchRank)) #endif , - type, feature::GetFeatureViewport(m_types, m_center), m_distance); + type, feature::GetFeatureViewport(m_types, m_featureRect), m_distance); case RESULT_LATLON: return Result(m_str, info.m_name, info.m_flag, string(), 0, diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index 06dfff42e0..d4f8ad9c8b 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -129,6 +129,7 @@ private: void GetRegion(storage::CountryInfoGetter const * pInfo, storage::CountryInfo & info) const; } m_region; + m2::RectD m_featureRect; m2::PointD m_center; double m_distance; ResultType m_resultType;