From ba853272ef999acee86e340ef747873eb169b5a7 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 6 Apr 2016 16:41:53 +0300 Subject: [PATCH] =?UTF-8?q?[search]=20Don=E2=80=99t=20calculate=20address?= =?UTF-8?q?=20for=20viewport=20search=20result=20points.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/intermediate_result.cpp | 20 ++++++++++++-------- search/intermediate_result.hpp | 3 ++- search/search_query.cpp | 5 +++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp index fd9412a650..09a407b1c0 100644 --- a/search/intermediate_result.cpp +++ b/search/intermediate_result.cpp @@ -177,14 +177,14 @@ string FormatFullAddress(ReverseGeocoder::Address const & addr, string const & r Result PreResult2::GenerateFinalResult(storage::CountryInfoGetter const & infoGetter, CategoriesHolder const * pCat, set const * pTypes, int8_t locale, - ReverseGeocoder const & coder) const + ReverseGeocoder const * coder) const { string name = m_str; - if (name.empty()) + if (coder && name.empty()) { // Insert exact address (street and house number) instead of empty result name. ReverseGeocoder::Address addr; - coder.GetNearbyAddress(GetCenter(), addr); + coder->GetNearbyAddress(GetCenter(), addr); if (addr.GetDistance() == 0) name = FormatStreetAndHouse(addr); } @@ -192,12 +192,16 @@ Result PreResult2::GenerateFinalResult(storage::CountryInfoGetter const & infoGe uint32_t const type = GetBestType(pTypes); // Format full address only for suitable results. - string address = GetRegionName(infoGetter, type); - if (ftypes::IsAddressObjectChecker::Instance()(m_types)) + string address; + if (coder) { - ReverseGeocoder::Address addr; - coder.GetNearbyAddress(GetCenter(), addr); - address = FormatFullAddress(addr, address); + address = GetRegionName(infoGetter, type); + if (ftypes::IsAddressObjectChecker::Instance()(m_types)) + { + ReverseGeocoder::Address addr; + coder->GetNearbyAddress(GetCenter(), addr); + address = FormatFullAddress(addr, address); + } } switch (m_resultType) diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index 1431f9f70b..9593e1ed89 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -82,9 +82,10 @@ public: /// @param[in] pCat Categories need to display readable type string. /// @param[in] pTypes Set of preffered types that match input tokens by categories. /// @param[in] lang Current system language. + /// @param[in] coder May be nullptr - no need to calculate address. Result GenerateFinalResult(storage::CountryInfoGetter const & infoGetter, CategoriesHolder const * pCat, set const * pTypes, - int8_t locale, ReverseGeocoder const & coder) const; + int8_t locale, ReverseGeocoder const * coder) const; /// Filter equal features for different mwm's. class StrictEqualF diff --git a/search/search_query.cpp b/search/search_query.cpp index 413f575887..b469e376a9 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -544,7 +544,8 @@ void Query::FlushViewportResults(v2::Geocoder::Params const & params, Results & break; res.AddResultNoChecks((*(indV[i])).GenerateFinalResult(m_infoGetter, &m_categories, - &m_prefferedTypes, m_currentLocaleCode, m_reverseGeocoder)); + &m_prefferedTypes, m_currentLocaleCode, + nullptr /* Viewport results don't need calculated address */)); } } @@ -1029,7 +1030,7 @@ public: Result Query::MakeResult(impl::PreResult2 const & r) const { Result res = r.GenerateFinalResult(m_infoGetter, &m_categories, &m_prefferedTypes, - m_currentLocaleCode, m_reverseGeocoder); + m_currentLocaleCode, &m_reverseGeocoder); MakeResultHighlight(res); #ifdef FIND_LOCALITY_TEST