Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/jni/com/mapswithme/maps/SearchEngine.cpp2
-rw-r--r--iphone/Maps/Core/Search/MWMSearch.mm2
-rw-r--r--map/booking_filter.cpp10
-rw-r--r--map/framework.cpp14
-rw-r--r--qt/search_panel.cpp2
-rw-r--r--search/downloader_search_callback.cpp2
-rw-r--r--search/result.cpp196
-rw-r--r--search/result.hpp196
-rw-r--r--search/search_integration_tests/processor_test.cpp2
-rw-r--r--search/search_quality/assessment_tool/context.cpp2
-rw-r--r--search/search_quality/assessment_tool/main_model.cpp2
-rw-r--r--search/search_quality/assessment_tool/result_view.cpp2
-rw-r--r--search/search_quality/features_collector_tool/features_collector_tool.cpp2
-rw-r--r--search/search_quality/matcher.cpp2
14 files changed, 215 insertions, 221 deletions
diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp
index e3fb7e17be..692b0920ab 100644
--- a/android/jni/com/mapswithme/maps/SearchEngine.cpp
+++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp
@@ -371,7 +371,7 @@ jobject ToJavaResult(Result & result, bool isLocalAdsCustomer, bool hasPosition,
}
jni::TScopedLocalRef featureId(env, usermark_helper::CreateFeatureId(env, result.GetFeatureID()));
- jni::TScopedLocalRef featureType(env, jni::ToJavaString(env, result.GetFeatureType()));
+ jni::TScopedLocalRef featureType(env, jni::ToJavaString(env, result.GetFeatureTypeName()));
jni::TScopedLocalRef address(env, jni::ToJavaString(env, result.GetAddress()));
jni::TScopedLocalRef dist(env, jni::ToJavaString(env, distance));
jni::TScopedLocalRef cuisine(env, jni::ToJavaString(env, result.GetCuisine()));
diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm
index ee2396edd5..a4407dc490 100644
--- a/iphone/Maps/Core/Search/MWMSearch.mm
+++ b/iphone/Maps/Core/Search/MWMSearch.mm
@@ -226,7 +226,7 @@ using Observers = NSHashTable<Observer>;
+ (BOOL)isBookingAvailableWithContainerIndex:(NSUInteger)index
{
auto const & result = [self resultWithContainerIndex:index];
- if (result.GetResultType() != search::Result::ResultType::RESULT_FEATURE)
+ if (result.GetResultType() != search::Result::Type::Feature)
return NO;
auto const & resultFeatureID = result.GetFeatureID();
auto const & bookingAvailableIDs = [MWMSearch manager]->m_bookingAvailableFeatureIDs;
diff --git a/map/booking_filter.cpp b/map/booking_filter.cpp
index e2e2b63241..d1e30a9a2a 100644
--- a/map/booking_filter.cpp
+++ b/map/booking_filter.cpp
@@ -94,11 +94,8 @@ void PrepareData(Index const & index, search::Results const & results,
for (auto const & r : results)
{
- if (!r.m_metadata.m_isSponsoredHotel ||
- r.GetResultType() != search::Result::ResultType::RESULT_FEATURE)
- {
+ if (!r.m_metadata.m_isSponsoredHotel || r.GetResultType() != search::Result::Type::Feature)
continue;
- }
features.push_back(r.GetFeatureID());
hotelToResults.emplace_back(r);
@@ -153,11 +150,8 @@ void GetAvailableFeaturesFromCacheImpl(Index const & index, search::Results cons
for (auto const & r : results)
{
- if (!r.m_metadata.m_isSponsoredHotel ||
- r.GetResultType() != search::Result::ResultType::RESULT_FEATURE)
- {
+ if (!r.m_metadata.m_isSponsoredHotel || r.GetResultType() != search::Result::Type::Feature)
continue;
- }
features.push_back(r.GetFeatureID());
}
diff --git a/map/framework.cpp b/map/framework.cpp
index a942c74cb6..91b6a0d1c0 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -1489,18 +1489,18 @@ void Framework::SelectSearchResult(search::Result const & result, bool animation
int scale;
switch (result.GetResultType())
{
- case Result::RESULT_FEATURE:
+ case Result::Type::Feature:
FillFeatureInfo(result.GetFeatureID(), info);
scale = GetFeatureViewportScale(info.GetTypes());
break;
- case Result::RESULT_LATLON:
+ case Result::Type::LatLon:
FillPointInfo(result.GetFeatureCenter(), result.GetString(), info);
scale = scales::GetUpperComfortScale();
break;
- case Result::RESULT_SUGGEST_PURE:
- case Result::RESULT_SUGGEST_FROM_FEATURE: ASSERT(false, ("Suggests should not be here.")); return;
+ case Result::Type::SuggestFromFeature:
+ case Result::Type::PureSuggest: ASSERT(false, ("Suggests should not be here.")); return;
}
info.SetAdsEngine(m_adsEngine.get());
@@ -1615,7 +1615,7 @@ void Framework::FillSearchResultsMarks(bool clear, search::Results::ConstIter be
auto mark = static_cast<SearchMarkPoint *>(controller.CreateUserMark(r.GetFeatureCenter()));
ASSERT_EQUAL(mark->GetMarkType(), UserMark::Type::SEARCH, ());
- auto const isFeature = r.GetResultType() == search::Result::RESULT_FEATURE;
+ auto const isFeature = r.GetResultType() == search::Result::Type::Feature;
if (isFeature)
mark->SetFoundFeature(r.GetFeatureID());
mark->SetMatchedName(r.GetString());
@@ -3238,9 +3238,7 @@ bool Framework::ParseSearchQueryCommand(search::SearchParams const & params)
bool Framework::IsLocalAdsCustomer(search::Result const & result) const
{
- if (result.IsSuggest())
- return false;
- if (result.GetResultType() != search::Result::ResultType::RESULT_FEATURE)
+ if (result.GetResultType() != search::Result::Type::Feature)
return false;
return m_localAdsManager.Contains(result.GetFeatureID());
}
diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp
index 053629ff2f..7b8ea04972 100644
--- a/qt/search_panel.cpp
+++ b/qt/search_panel.cpp
@@ -113,7 +113,7 @@ void SearchPanel::OnSearchResults(uint64_t timestamp, search::Results const & re
m_pTable->setCellWidget(rowCount, 1, new QLabel(strHigh));
m_pTable->setItem(rowCount, 2, CreateItem(QString::fromStdString(res.GetAddress())));
- if (res.GetResultType() == search::Result::RESULT_FEATURE)
+ if (res.GetResultType() == search::Result::Type::Feature)
{
m_pTable->setItem(rowCount, 0, CreateItem(QString::fromStdString(res.GetFeatureType())));
m_pTable->setItem(rowCount, 3, CreateItem(m_pDrawWidget->GetDistance(res).c_str()));
diff --git a/search/downloader_search_callback.cpp b/search/downloader_search_callback.cpp
index 06326d5052..cb55b1aa89 100644
--- a/search/downloader_search_callback.cpp
+++ b/search/downloader_search_callback.cpp
@@ -57,7 +57,7 @@ void DownloaderSearchCallback::operator()(search::Results const & results)
if (!result.HasPoint())
continue;
- if (result.GetResultType() != search::Result::RESULT_LATLON)
+ if (result.GetResultType() != search::Result::Type::LatLon)
{
FeatureID const & fid = result.GetFeatureID();
Index::FeaturesLoaderGuard loader(m_index, fid.m_mwmId);
diff --git a/search/result.cpp b/search/result.cpp
index 810301f729..12eee13da9 100644
--- a/search/result.cpp
+++ b/search/result.cpp
@@ -3,29 +3,55 @@
#include "search/common.hpp"
#include "search/geometry_utils.hpp"
+#include <algorithm>
+
+using namespace std;
+
namespace search
{
+namespace
+{
+// Following methods joins only non-empty arguments in order with
+// comma.
+string Join(string const & s)
+{
+ return s;
+}
+
+template <typename... Args>
+string Join(string const & s, Args &&... args)
+{
+ auto const tail = Join(forward<Args>(args)...);
+ if (s.empty())
+ return tail;
+ if (tail.empty())
+ return s;
+ return s + ", " + tail;
+}
+} // namespace
+
// Result ------------------------------------------------------------------------------------------
Result::Result(FeatureID const & id, m2::PointD const & pt, string const & str,
- string const & address, string const & type, uint32_t featureType,
+ string const & address, string const & featureTypeName, uint32_t featureType,
Metadata const & meta)
- : m_id(id)
+ : m_resultType(Type::Feature)
+ , m_id(id)
, m_center(pt)
- , m_str(str.empty() ? type : str) //!< Features with empty names can be found after suggestion.
+ , m_str(str.empty() ? featureTypeName : str)
, m_address(address)
- , m_type(type)
+ , m_featureTypeName(featureTypeName)
, m_featureType(featureType)
, m_metadata(meta)
{
}
Result::Result(m2::PointD const & pt, string const & latlon, string const & address)
- : m_center(pt), m_str(latlon), m_address(address)
+ : m_resultType(Type::LatLon), m_center(pt), m_str(latlon), m_address(address)
{
}
Result::Result(string const & str, string const & suggest)
- : m_str(str), m_suggestionStr(suggest)
+ : m_resultType(Type::PureSuggest), m_str(str), m_suggestionStr(suggest)
{
}
@@ -34,42 +60,27 @@ Result::Result(Result const & res, string const & suggest)
, m_center(res.m_center)
, m_str(res.m_str)
, m_address(res.m_address)
- , m_type(res.m_type)
+ , m_featureTypeName(res.m_featureTypeName)
, m_featureType(res.m_featureType)
, m_suggestionStr(suggest)
, m_hightlightRanges(res.m_hightlightRanges)
{
-}
-
-Result::ResultType Result::GetResultType() const
-{
- bool const idValid = m_id.IsValid();
-
- if (!m_suggestionStr.empty())
- return (idValid ? RESULT_SUGGEST_FROM_FEATURE : RESULT_SUGGEST_PURE);
-
- if (idValid)
- return RESULT_FEATURE;
- else
- return RESULT_LATLON;
+ m_resultType = m_id.IsValid() ? Type::SuggestFromFeature : Type::PureSuggest;
}
bool Result::IsSuggest() const
{
- return !m_suggestionStr.empty();
+ return m_resultType == Type::SuggestFromFeature || m_resultType == Type::PureSuggest;
}
bool Result::HasPoint() const
{
- return (GetResultType() != RESULT_SUGGEST_PURE);
+ return m_resultType != Type::PureSuggest;
}
FeatureID const & Result::GetFeatureID() const
{
-#if defined(DEBUG)
- auto const type = GetResultType();
- ASSERT(type == RESULT_FEATURE, (type));
-#endif
+ ASSERT(m_resultType == Type::Feature, (m_resultType));
return m_id;
}
@@ -79,24 +90,23 @@ m2::PointD Result::GetFeatureCenter() const
return m_center;
}
-char const * Result::GetSuggestionString() const
+string const & Result::GetSuggestionString() const
{
ASSERT(IsSuggest(), ());
- return m_suggestionStr.c_str();
+ return m_suggestionStr;
}
bool Result::IsEqualSuggest(Result const & r) const
{
- return (m_suggestionStr == r.m_suggestionStr);
+ return m_suggestionStr == r.m_suggestionStr;
}
bool Result::IsEqualFeature(Result const & r) const
{
- ResultType const type = GetResultType();
- if (type != r.GetResultType())
+ if (m_resultType != r.m_resultType)
return false;
- ASSERT_EQUAL(type, Result::RESULT_FEATURE, ());
+ ASSERT_EQUAL(m_resultType, Result::Type::Feature, ());
ASSERT(m_id.IsValid() && r.m_id.IsValid(), ());
if (m_id == r.m_id)
@@ -106,9 +116,8 @@ bool Result::IsEqualFeature(Result const & r) const
// - 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_address == r.m_address &&
- m_featureType == r.m_featureType &&
- PointDistance(m_center, r.m_center) < 500.0);
+ return m_str == r.m_str && m_address == r.m_address && m_featureType == r.m_featureType &&
+ PointDistance(m_center, r.m_center) < 500.0;
}
void Result::AddHighlightRange(pair<uint16_t, uint16_t> const & range)
@@ -134,12 +143,31 @@ string Result::ToStringForStats() const
string s;
s.append(GetString());
s.append("|");
- s.append(GetFeatureType());
+ s.append(GetFeatureTypeName());
s.append("|");
s.append(IsSuggest() ? "1" : "0");
return s;
}
+string DebugPrint(Result::Type type)
+{
+ switch (type)
+ {
+ case Result::Type::Feature: return "Feature";
+ case Result::Type::LatLon: return "LatLon";
+ case Result::Type::PureSuggest: return "PureSuggest";
+ case Result::Type::SuggestFromFeature: return "SuggestFromFeature";
+ }
+
+ return "Unknown";
+}
+
+string DebugPrint(Result const & result)
+{
+ return "Result { Name: " + result.GetString() + "; Type: " + result.GetFeatureTypeName() +
+ "; Info: " + DebugPrint(result.GetRankingInfo()) + " }";
+}
+
// Results -----------------------------------------------------------------------------------------
Results::Results()
{
@@ -149,16 +177,8 @@ Results::Results()
bool Results::AddResult(Result && result)
{
// Find first feature result.
- auto it = find_if(m_results.begin(), m_results.end(), [](Result const & r)
- {
- switch (r.GetResultType())
- {
- case Result::RESULT_FEATURE:
- return true;
- default:
- return false;
- }
- });
+ auto it = find_if(m_results.begin(), m_results.end(),
+ [](Result const & r) { return r.GetResultType() == Result::Type::Feature; });
if (result.IsSuggest())
{
@@ -205,18 +225,13 @@ void Results::Clear()
size_t Results::GetSuggestsCount() const
{
- size_t res = 0;
- for (size_t i = 0; i < GetCount(); i++)
- {
- if (m_results[i].IsSuggest())
- ++res;
- else
- {
- // Suggests always go first, so we can exit here.
- break;
- }
- }
- return res;
+ size_t i = 0;
+
+ // Suggests always go first, so we need to compute length of prefix
+ // of suggests.
+ while (i < m_results.size() && m_results[i].IsSuggest())
+ ++i;
+ return i;
}
void Results::InsertResult(vector<Result>::iterator where, Result && result)
@@ -244,8 +259,7 @@ string AddressInfo::GetPinName() const
{
if (IsEmptyName() && !m_types.empty())
return m_types[0];
- else
- return m_name.empty() ? m_house : m_name;
+ return m_name.empty() ? m_house : m_name;
}
string AddressInfo::GetPinType() const
@@ -262,54 +276,35 @@ string AddressInfo::FormatPinText() const
if (type.empty())
return ret;
- return (ret.empty() ? type : (ret + " (" + type + ')'));
+ return ret.empty() ? type : (ret + " (" + type + ')');
}
-string AddressInfo::FormatHouseAndStreet(AddressType type /* = DEFAULT */) const
+string AddressInfo::FormatHouseAndStreet(Type type /* = Type::Default */) const
{
- // Check whether we can format address according to the query type and actual address distance.
- /// @todo We can add "Near" prefix here in future according to the distance.
+ // Check whether we can format address according to the query type
+ // and actual address distance.
+
+ // TODO (@m, @y): we can add "Near" prefix here in future according
+ // to the distance.
if (m_distanceMeters > 0.0)
{
- if (type == SEARCH_RESULT && m_distanceMeters > 50.0)
- return string();
+ if (type == Type::SearchResult && m_distanceMeters > 50.0)
+ return {};
if (m_distanceMeters > 200.0)
- return string();
- }
-
- string result = m_street;
- if (!m_house.empty())
- {
- if (!result.empty())
- result += ", ";
- result += m_house;
+ return {};
}
- return result;
+ return Join(m_street, m_house);
}
-string AddressInfo::FormatAddress(AddressType type /* = DEFAULT */) const
+string AddressInfo::FormatAddress(Type type /* = Type::Default */) const
{
- string result = FormatHouseAndStreet(type);
- if (!m_city.empty())
- {
- if (!result.empty())
- result += ", ";
- result += m_city;
- }
- if (!m_country.empty())
- {
- if (!result.empty())
- result += ", ";
- result += m_country;
- }
- return result;
+ return Join(FormatHouseAndStreet(type), m_city, m_country);
}
-string AddressInfo::FormatNameAndAddress(AddressType type /* = DEFAULT */) const
+string AddressInfo::FormatNameAndAddress(Type type /* = Type::Default */) const
{
- string const addr = FormatAddress(type);
- return (m_name.empty() ? addr : m_name + ", " + addr);
+ return Join(m_name, FormatAddress(type));
}
string AddressInfo::FormatTypes() const
@@ -317,7 +312,7 @@ string AddressInfo::FormatTypes() const
string result;
for (size_t i = 0; i < m_types.size(); ++i)
{
- ASSERT ( !m_types.empty(), () );
+ ASSERT(!m_types.empty(), ());
if (!result.empty())
result += ' ';
result += m_types[i];
@@ -328,9 +323,10 @@ string AddressInfo::FormatTypes() const
string AddressInfo::GetBestType() const
{
if (m_types.empty())
- return string();
+ return {};
- /// @todo Probably, we should skip some "common" types here like in TypesHolder::SortBySpec.
+ /// @TODO(@m, @y): probably, we should skip some "common" types here
+ /// like in TypesHolder::SortBySpec.
ASSERT(!m_types[0].empty(), ());
return m_types[0];
}
@@ -349,10 +345,4 @@ string DebugPrint(AddressInfo const & info)
{
return info.FormatNameAndAddress();
}
-
-string DebugPrint(Result const & result)
-{
- return "Result { Name: " + result.GetString() + "; Type: " + result.GetFeatureType() +
- "; Info: " + DebugPrint(result.GetRankingInfo()) + " }";
-}
} // namespace search
diff --git a/search/result.hpp b/search/result.hpp
index 3fbd313b7f..5d8219ab55 100644
--- a/search/result.hpp
+++ b/search/result.hpp
@@ -6,12 +6,15 @@
#include "editor/yes_no_unknown.hpp"
#include "geometry/point2d.hpp"
-#include "geometry/rect2d.hpp"
+#include "base/assert.hpp"
#include "base/buffer_vector.hpp"
-#include "std/string.hpp"
-
+#include <cstddef>
+#include <cstdint>
+#include <string>
+#include <utility>
+#include <vector>
namespace search
{
@@ -19,54 +22,59 @@ namespace search
class Result
{
public:
- enum ResultType
+ enum class Type
{
- RESULT_FEATURE,
- RESULT_LATLON,
- RESULT_SUGGEST_PURE,
- RESULT_SUGGEST_FROM_FEATURE
+ Feature,
+ LatLon,
+ PureSuggest,
+ SuggestFromFeature
};
- /// Metadata for search results. Considered valid if m_resultType == RESULT_FEATURE.
+ // Metadata for search results. Considered valid if GetResultType() == Type::Feature.
struct Metadata
{
- string m_cuisine; // Valid only if not empty. Used for restaurants.
+ // Valid only if not empty, Used for restaurants.
+ std::string m_cuisine;
// Following fields are used for hotels only.
- string m_hotelApproximatePricing;
- string m_hotelRating;
+ std::string m_hotelApproximatePricing;
+ std::string m_hotelRating;
int m_stars = 0;
bool m_isSponsoredHotel = false;
bool m_isHotel = false;
- osm::YesNoUnknown m_isOpenNow = osm::Unknown; // Valid for any result.
+ // Valid for any result.
+ osm::YesNoUnknown m_isOpenNow = osm::Unknown;
bool m_isInitialized = false;
};
- /// For RESULT_FEATURE.
- Result(FeatureID const & id, m2::PointD const & pt, string const & str, string const & address,
- string const & type, uint32_t featureType, Metadata const & meta);
+ // For Type::Feature.
+ Result(FeatureID const & id, m2::PointD const & pt, std::string const & str,
+ std::string const & address, std::string const & featureTypeName, uint32_t featureType,
+ Metadata const & meta);
+
+ // For Type::LatLon.
+ Result(m2::PointD const & pt, std::string const & latlon, std::string const & address);
- /// For RESULT_LATLON.
- Result(m2::PointD const & pt, string const & latlon, string const & address);
+ // For Type::PureSuggest.
+ Result(std::string const & str, std::string const & suggest);
- /// For RESULT_SUGGESTION_PURE.
- Result(string const & str, string const & suggest);
+ // For Type::SuggestFromFeature.
+ Result(Result const & res, std::string const & suggest);
- /// For RESULT_SUGGESTION_FROM_FEATURE.
- Result(Result const & res, string const & suggest);
+ Type GetResultType() const { return m_resultType; }
- /// Strings that is displayed in the GUI.
- //@{
- string const & GetString() const { return m_str; }
- string const & GetAddress() const { return m_address; }
- string const & GetFeatureType() const { return m_type; }
- string const & GetCuisine() const { return m_metadata.m_cuisine; }
- string const & GetHotelRating() const { return m_metadata.m_hotelRating; }
- string const & GetHotelApproximatePricing() const { return m_metadata.m_hotelApproximatePricing; }
+ std::string const & GetString() const { return m_str; }
+ std::string const & GetAddress() const { return m_address; }
+ std::string const & GetFeatureTypeName() const { return m_featureTypeName; }
+ std::string const & GetCuisine() const { return m_metadata.m_cuisine; }
+ std::string const & GetHotelRating() const { return m_metadata.m_hotelRating; }
+ std::string const & GetHotelApproximatePricing() const
+ {
+ return m_metadata.m_hotelApproximatePricing;
+ }
bool IsHotel() const { return m_metadata.m_isHotel; }
- //@}
osm::YesNoUnknown IsOpenNow() const { return m_metadata.m_isOpenNow; }
int GetStarsCount() const { return m_metadata.m_stars; }
@@ -74,77 +82,79 @@ public:
bool IsSuggest() const;
bool HasPoint() const;
- /// Type of the result.
- ResultType GetResultType() const;
-
- /// Feature id in mwm.
- /// @precondition GetResultType() == RESULT_FEATURE
+ // Feature id in mwm.
+ // Precondition: GetResultType() == Type::Feature.
FeatureID const & GetFeatureID() const;
- /// Center point of a feature.
- /// @precondition HasPoint() == true
+ // Center point of a feature.
+ // Precondition: HasPoint() == true.
m2::PointD GetFeatureCenter() const;
- /// String to write in the search box.
- /// @precondition IsSuggest() == true
- char const * GetSuggestionString() const;
+ // String to write in the search box.
+ // Precondition: IsSuggest() == true.
+ std::string const & GetSuggestionString() const;
bool IsEqualSuggest(Result const & r) const;
bool IsEqualFeature(Result const & r) const;
- void AddHighlightRange(pair<uint16_t, uint16_t> const & range);
- pair<uint16_t, uint16_t> const & GetHighlightRange(size_t idx) const;
- inline size_t GetHighlightRangesCount() const { return m_hightlightRanges.size(); }
+ void AddHighlightRange(std::pair<uint16_t, uint16_t> const & range);
+ std::pair<uint16_t, uint16_t> const & GetHighlightRange(size_t idx) const;
+ size_t GetHighlightRangesCount() const { return m_hightlightRanges.size(); }
void AppendCity(string const & name);
int32_t GetPositionInResults() const { return m_positionInResults; }
void SetPositionInResults(int32_t pos) { m_positionInResults = pos; }
- inline RankingInfo const & GetRankingInfo() const { return m_info; }
+ RankingInfo const & GetRankingInfo() const { return m_info; }
- template <typename TInfo>
- inline void SetRankingInfo(TInfo && info)
+ template <typename Info>
+ void SetRankingInfo(Info && info)
{
- m_info = forward<TInfo>(info);
+ m_info = forward<Info>(info);
}
- // Returns a representation of this result that is
- // sent to the statistics servers and later used to measure
- // the quality of our search engine.
+ // Returns a representation of this result that is sent to the
+ // statistics servers and later used to measure the quality of our
+ // search engine.
string ToStringForStats() const;
private:
+ Type m_resultType;
+
FeatureID m_id;
m2::PointD m_center;
- string m_str;
- string m_address;
- string m_type;
+ std::string m_str;
+ std::string m_address;
+ std::string m_featureTypeName;
uint32_t m_featureType;
- string m_suggestionStr;
- buffer_vector<pair<uint16_t, uint16_t>, 4> m_hightlightRanges;
+ std::string m_suggestionStr;
+ buffer_vector<std::pair<uint16_t, uint16_t>, 4> m_hightlightRanges;
RankingInfo m_info;
- // The position that this result occupied in the vector returned
- // by a search query. -1 if undefined.
+ // The position that this result occupied in the vector returned by
+ // a search query. -1 if undefined.
int32_t m_positionInResults = -1;
public:
Metadata m_metadata;
};
+std::string DebugPrint(search::Result::Type type);
+std::string DebugPrint(search::Result const & result);
+
class Results
{
public:
- using Iter = vector<Result>::iterator;
- using ConstIter = vector<Result>::const_iterator;
+ using Iter = std::vector<Result>::iterator;
+ using ConstIter = std::vector<Result>::const_iterator;
Results();
- inline bool IsEndMarker() const { return m_status != Status::None; }
- inline bool IsEndedNormal() const { return m_status == Status::EndedNormal; }
- inline bool IsEndedCancelled() const { return m_status == Status::EndedCancelled; }
+ bool IsEndMarker() const { return m_status != Status::None; }
+ bool IsEndedNormal() const { return m_status == Status::EndedNormal; }
+ bool IsEndedCancelled() const { return m_status == Status::EndedCancelled; }
void SetEndMarker(bool cancelled)
{
@@ -153,33 +163,34 @@ public:
bool AddResult(Result && result);
- // Fast version of AddResult() that doesn't do any duplicates checks.
+ // Fast version of AddResult() that doesn't do any duplicates
+ // checks.
void AddResultNoChecks(Result && result);
void AddResultsNoChecks(ConstIter first, ConstIter last);
void Clear();
- inline Iter begin() { return m_results.begin(); }
- inline Iter end() { return m_results.end(); }
- inline ConstIter begin() const { return m_results.cbegin(); }
- inline ConstIter end() const { return m_results.cend(); }
+ Iter begin() { return m_results.begin(); }
+ Iter end() { return m_results.end(); }
+ ConstIter begin() const { return m_results.cbegin(); }
+ ConstIter end() const { return m_results.cend(); }
- inline size_t GetCount() const { return m_results.size(); }
+ size_t GetCount() const { return m_results.size(); }
size_t GetSuggestsCount() const;
- inline Result & operator[](size_t i)
+ Result & operator[](size_t i)
{
ASSERT_LESS(i, m_results.size(), ());
return m_results[i];
}
- inline Result const & operator[](size_t i) const
+ Result const & operator[](size_t i) const
{
ASSERT_LESS(i, m_results.size(), ());
return m_results[i];
}
- inline void Swap(Results & rhs) { m_results.swap(rhs.m_results); }
+ void Swap(Results & rhs) { m_results.swap(rhs.m_results); }
private:
enum class Status
@@ -193,42 +204,43 @@ private:
//
// *NOTE* all iterators, references and pointers to |m_results| are
// invalid after the call.
- void InsertResult(vector<Result>::iterator where, Result && result);
+ void InsertResult(std::vector<Result>::iterator where, Result && result);
- vector<Result> m_results;
+ std::vector<Result> m_results;
Status m_status;
};
struct AddressInfo
{
- string m_country;
- string m_city;
- string m_street;
- string m_house;
- string m_name;
- vector<string> m_types;
+ enum class Type { Default, SearchResult };
+
+ std::string m_country;
+ std::string m_city;
+ std::string m_street;
+ std::string m_house;
+ std::string m_name;
+ std::vector<std::string> m_types;
double m_distanceMeters = -1.0;
- string GetPinName() const; // Caroline
- string GetPinType() const; // shop
+ std::string GetPinName() const; // Caroline
+ std::string GetPinType() const; // shop
- string FormatPinText() const; // Caroline (clothes shop)
- string FormatTypes() const; // clothes shop
- string GetBestType() const;
+ std::string FormatPinText() const; // Caroline (clothes shop)
+ std::string FormatTypes() const; // clothes shop
+ std::string GetBestType() const;
bool IsEmptyName() const;
- enum AddressType { DEFAULT, SEARCH_RESULT };
// 7 vulica Frunze
- string FormatHouseAndStreet(AddressType type = DEFAULT) const;
+ std::string FormatHouseAndStreet(Type type = Type::Default) const;
+
// 7 vulica Frunze, Minsk, Belarus
- string FormatAddress(AddressType type = DEFAULT) const;
+ std::string FormatAddress(Type type = Type::Default) const;
+
// Caroline, 7 vulica Frunze, Minsk, Belarus
- string FormatNameAndAddress(AddressType type = DEFAULT) const;
+ std::string FormatNameAndAddress(Type type = Type::Default) const;
void Clear();
-
- friend string DebugPrint(AddressInfo const & info);
};
-string DebugPrint(search::Result const & result);
+std::string DebugPrint(AddressInfo const & info);
} // namespace search
diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp
index 34ec570102..bf480f3d64 100644
--- a/search/search_integration_tests/processor_test.cpp
+++ b/search/search_integration_tests/processor_test.cpp
@@ -834,7 +834,7 @@ UNIT_CLASS_TEST(ProcessorTest, TestCoords)
TEST_EQUAL(results.size(), 1, ());
auto const & result = results[0];
- TEST_EQUAL(result.GetResultType(), Result::RESULT_LATLON, ());
+ TEST_EQUAL(result.GetResultType(), Result::Type::LatLon, ());
TEST(result.HasPoint(), ());
m2::PointD const expected = MercatorBounds::FromLatLon(51.681644, 39.183481);
diff --git a/search/search_quality/assessment_tool/context.cpp b/search/search_quality/assessment_tool/context.cpp
index 595541b093..caf82c0d42 100644
--- a/search/search_quality/assessment_tool/context.cpp
+++ b/search/search_quality/assessment_tool/context.cpp
@@ -86,7 +86,7 @@ search::Sample Context::MakeSample(search::FeatureLoader & loader) const
auto const & result = m_foundResults[i];
// No need in non-feature results.
- if (result.GetResultType() != search::Result::RESULT_FEATURE)
+ if (result.GetResultType() != search::Result::Type::Feature)
continue;
FeatureType ft;
diff --git a/search/search_quality/assessment_tool/main_model.cpp b/search/search_quality/assessment_tool/main_model.cpp
index 4650bd4e82..aaf9e98816 100644
--- a/search/search_quality/assessment_tool/main_model.cpp
+++ b/search/search_quality/assessment_tool/main_model.cpp
@@ -393,7 +393,7 @@ void MainModel::ForAnyMatchingEntry(Context & context, FeatureID const & id, Fn
for (size_t i = 0; i < foundResults.GetCount(); ++i)
{
auto const & result = foundResults[i];
- if (result.GetResultType() != search::Result::RESULT_FEATURE)
+ if (result.GetResultType() != search::Result::Type::Feature)
continue;
if (result.GetFeatureID() == id)
return fn(context.m_foundResultsEdits, i);
diff --git a/search/search_quality/assessment_tool/result_view.cpp b/search/search_quality/assessment_tool/result_view.cpp
index 8e8c8607ce..f8bd07e62f 100644
--- a/search/search_quality/assessment_tool/result_view.cpp
+++ b/search/search_quality/assessment_tool/result_view.cpp
@@ -53,7 +53,7 @@ ResultView::ResultView(string const & name, string const & type, string const &
}
ResultView::ResultView(search::Result const & result, QWidget & parent)
- : ResultView(result.GetString(), result.GetFeatureType(), result.GetAddress(), parent)
+ : ResultView(result.GetString(), result.GetFeatureTypeName(), result.GetAddress(), parent)
{
}
diff --git a/search/search_quality/features_collector_tool/features_collector_tool.cpp b/search/search_quality/features_collector_tool/features_collector_tool.cpp
index 1de7bf3a01..b718be9a64 100644
--- a/search/search_quality/features_collector_tool/features_collector_tool.cpp
+++ b/search/search_quality/features_collector_tool/features_collector_tool.cpp
@@ -190,7 +190,7 @@ int main(int argc, char * argv[])
for (size_t j = 0; j < results.size(); ++j)
{
- if (results[j].GetResultType() != Result::RESULT_FEATURE)
+ if (results[j].GetResultType() != Result::Type::Feature)
continue;
auto const & info = results[j].GetRankingInfo();
cout << i << ",";
diff --git a/search/search_quality/matcher.cpp b/search/search_quality/matcher.cpp
index b015843dad..467ba078fa 100644
--- a/search/search_quality/matcher.cpp
+++ b/search/search_quality/matcher.cpp
@@ -87,7 +87,7 @@ bool Matcher::Matches(Sample::Result const & golden, FeatureType & ft)
bool Matcher::Matches(Sample::Result const & golden, search::Result const & actual)
{
- if (actual.GetResultType() != Result::RESULT_FEATURE)
+ if (actual.GetResultType() != Result::Type::Feature)
return false;
FeatureType ft;