diff options
author | vng <viktor.govako@gmail.com> | 2014-05-15 15:28:40 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:15:32 +0300 |
commit | 4ae69054f4c4035b30cd85f7085cfa0277241ab3 (patch) | |
tree | ac339d1ebda8b9dbc92aef1186640ab6b75e443d /search/result.cpp | |
parent | 80498aa751ffdb6a1c85c36a95e77f552ebf6aac (diff) |
[search] Implement suggestions for countries, cities, streets.
Diffstat (limited to 'search/result.cpp')
-rw-r--r-- | search/result.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/search/result.cpp b/search/result.cpp index d1b3249185..cf9e9d38f1 100644 --- a/search/result.cpp +++ b/search/result.cpp @@ -28,8 +28,8 @@ Result::Result(m2::PointD const & fCenter, { } -Result::Result(string const & str, string const & suggestionStr) - : m_str(str), m_suggestionStr(suggestionStr) +Result::Result(string const & str, string const & suggest) + : m_str(str), m_suggestionStr(suggest) { } @@ -70,23 +70,33 @@ char const * Result::GetSuggestionString() const bool Result::operator== (Result const & r) const { ResultType const type = GetResultType(); - if (type == r.GetResultType() && type != RESULT_SUGGESTION) + if (type == r.GetResultType()) { - // This function is used to filter duplicate results in cases: - // - emitted Wrold.mwm and Country.mwm - // - after additional search in all mwm - // so it's suitable here to test for 500m - return (m_str == r.m_str && m_region == r.m_region && - m_featureType == r.m_featureType && - PointDistance(m_center, r.m_center) < 500.0); + if (type == RESULT_SUGGESTION) + return m_suggestionStr == r.m_suggestionStr; + else + { + // This function is used to filter duplicate results in cases: + // - emitted World.mwm and Country.mwm + // - after additional search in all mwm + // so it's suitable here to test for 500m + return (m_str == r.m_str && m_region == r.m_region && + m_featureType == r.m_featureType && + PointDistance(m_center, r.m_center) < 500.0); + } } return false; } -void Results::AddResultCheckExisting(Result const & r) +bool Results::AddResultCheckExistingEx(Result const & r) { if (find(m_vec.begin(), m_vec.end(), r) == m_vec.end()) + { AddResult(r); + return true; + } + else + return false; } //////////////////////////////////////////////////////////////////////////////////// |