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
path: root/search
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2018-09-19 19:06:33 +0300
committerAleksey Belousov <beloal@users.noreply.github.com>2018-09-25 11:56:55 +0300
commitdbf2f9868cbd9b3fdee8948309410a56a66b1187 (patch)
tree79f8f8cdcf33cc41759aebd8a882f0468dbae764 /search
parent57751bbf4e1bef731775a464a065b88aae712efc (diff)
[types_strings][android][search] types localization logic for search results is moved from core to android
Diffstat (limited to 'search')
-rw-r--r--search/ranker.cpp4
-rw-r--r--search/result.cpp26
-rw-r--r--search/result.hpp10
-rw-r--r--search/search_quality/assessment_tool/result_view.cpp13
-rw-r--r--search/search_tests/results_tests.cpp7
5 files changed, 40 insertions, 20 deletions
diff --git a/search/ranker.cpp b/search/ranker.cpp
index 12dfa65e1d..d019948dc2 100644
--- a/search/ranker.cpp
+++ b/search/ranker.cpp
@@ -425,9 +425,7 @@ Result Ranker::MakeResult(RankerResult const & rankerResult, bool needAddress,
case RankerResult::Type::TYPE_BUILDING:
{
auto const type = rankerResult.GetBestType(m_params.m_preferredTypes);
- return Result(r.GetID(), r.GetCenter(), name, address,
- m_categories.GetReadableFeatureType(type, m_params.m_currentLocaleCode), type,
- r.GetMetadata());
+ return Result(r.GetID(), r.GetCenter(), name, address, type, r.GetMetadata());
}
case RankerResult::Type::TYPE_LATLON: return Result(r.GetCenter(), name, address);
}
diff --git a/search/result.cpp b/search/result.cpp
index 13689c6d0c..110ac9d381 100644
--- a/search/result.cpp
+++ b/search/result.cpp
@@ -3,6 +3,8 @@
#include "search/common.hpp"
#include "search/geometry_utils.hpp"
+#include "indexer/classificator.hpp"
+
#include "base/string_utils.hpp"
#include <sstream>
@@ -34,14 +36,12 @@ string Join(string const & s, Args &&... args)
// Result ------------------------------------------------------------------------------------------
Result::Result(FeatureID const & id, m2::PointD const & pt, string const & str,
- string const & address, string const & featureTypeName, uint32_t featureType,
- Metadata const & meta)
+ string const & address, uint32_t featureType, Metadata const & meta)
: m_resultType(Type::Feature)
, m_id(id)
, m_center(pt)
- , m_str(str.empty() ? featureTypeName : str)
+ , m_str(str)
, m_address(address)
- , m_featureTypeName(featureTypeName)
, m_featureType(featureType)
, m_metadata(meta)
{
@@ -62,7 +62,6 @@ Result::Result(Result const & res, string const & suggest)
, m_center(res.m_center)
, m_str(res.m_str)
, m_address(res.m_address)
- , m_featureTypeName(res.m_featureTypeName)
, m_featureType(res.m_featureType)
, m_suggestionStr(suggest)
, m_hightlightRanges(res.m_hightlightRanges)
@@ -86,6 +85,11 @@ FeatureID const & Result::GetFeatureID() const
return m_id;
}
+uint32_t Result::GetFeatureType() const
+{
+ return m_featureType;
+}
+
m2::PointD Result::GetFeatureCenter() const
{
ASSERT(HasPoint(), ());
@@ -146,10 +150,14 @@ void Result::PrependCity(string const & name)
string Result::ToStringForStats() const
{
+ string readableType;
+ if (GetResultType() == Type::Feature)
+ readableType = classif().GetReadableObjectName(m_featureType);
+
string s;
s.append(GetString());
s.append("|");
- s.append(GetFeatureTypeName());
+ s.append(readableType);
s.append("|");
s.append(IsSuggest() ? "1" : "0");
return s;
@@ -170,10 +178,14 @@ string DebugPrint(Result::Type type)
string DebugPrint(Result const & result)
{
+ string readableType;
+ if (result.GetResultType() == Result::Type::Feature)
+ readableType = classif().GetReadableObjectName(result.GetFeatureType());
+
ostringstream os;
os << "Result [";
os << "name: " << result.GetString() << ", ";
- os << "type: " << result.GetFeatureTypeName() << ", ";
+ os << "type: " << readableType << ", ";
os << "info: " << DebugPrint(result.GetRankingInfo());
os << "]";
return os.str();
diff --git a/search/result.hpp b/search/result.hpp
index a62d6265b2..41631e44d0 100644
--- a/search/result.hpp
+++ b/search/result.hpp
@@ -64,8 +64,7 @@ public:
// 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);
+ std::string const & address, uint32_t featureType, Metadata const & meta);
// For Type::LatLon.
Result(m2::PointD const & pt, std::string const & latlon, std::string const & address);
@@ -80,7 +79,6 @@ public:
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; }
float GetHotelRating() const { return m_metadata.m_hotelRating; }
std::string const & GetHotelApproximatePricing() const
@@ -99,6 +97,9 @@ public:
// Precondition: GetResultType() == Type::Feature.
FeatureID const & GetFeatureID() const;
+ // Precondition: GetResultType() == Type::Feature.
+ uint32_t GetFeatureType() const;
+
// Center point of a feature.
// Precondition: HasPoint() == true.
m2::PointD GetFeatureCenter() const;
@@ -139,8 +140,7 @@ private:
m2::PointD m_center;
std::string m_str;
std::string m_address;
- std::string m_featureTypeName;
- uint32_t m_featureType;
+ uint32_t m_featureType = 0;
std::string m_suggestionStr;
buffer_vector<std::pair<uint16_t, uint16_t>, 4> m_hightlightRanges;
diff --git a/search/search_quality/assessment_tool/result_view.cpp b/search/search_quality/assessment_tool/result_view.cpp
index e4dcd125cb..6e1248d082 100644
--- a/search/search_quality/assessment_tool/result_view.cpp
+++ b/search/search_quality/assessment_tool/result_view.cpp
@@ -3,6 +3,8 @@
#include "search/result.hpp"
#include "search/search_quality/assessment_tool/helpers.hpp"
+#include "indexer/classificator.hpp"
+
#include <memory>
#include <utility>
#include <vector>
@@ -39,6 +41,15 @@ string GetResultType(search::Sample::Result const & result)
{
return strings::JoinStrings(result.m_types, ", ");
}
+
+string GetResultType(search::Result const & result)
+{
+ string readableType;
+ if (result.GetResultType() == search::Result::Type::Feature)
+ return readableType = classif().GetReadableObjectName(result.GetFeatureType());
+
+ return "";
+}
} // namespace
ResultView::ResultView(string const & name, string const & type, string const & address,
@@ -52,7 +63,7 @@ ResultView::ResultView(string const & name, string const & type, string const &
}
ResultView::ResultView(search::Result const & result, QWidget & parent)
- : ResultView(result.GetString(), result.GetFeatureTypeName(), result.GetAddress(), parent)
+ : ResultView(result.GetString(), GetResultType(result), result.GetAddress(), parent)
{
}
diff --git a/search/search_tests/results_tests.cpp b/search/search_tests/results_tests.cpp
index 9aaf1ccd8d..78af3ae335 100644
--- a/search/search_tests/results_tests.cpp
+++ b/search/search_tests/results_tests.cpp
@@ -13,7 +13,7 @@ UNIT_TEST(Results_Sorting)
for (uint32_t i = 5; i != 0; --i)
{
r.AddResultNoChecks({{id, i}, {} /* pt */, {} /* str */, {} /* address */,
- {} /* featureTypeName */, {} /* featureType */, {} /* metadata */});
+ {} /* featureType */, {} /* metadata */});
}
for (auto it = r.begin(); it != r.end(); ++it)
@@ -42,7 +42,7 @@ UNIT_TEST(Result_PrependCity)
{
Result r(fid, m2::PointD::Zero(), "" /* str */, "Moscow, Russia" /* address */,
- "" /* featureTypeName */, 0 /* featureType */, meta);
+ 0 /* featureType */, meta);
r.PrependCity("Moscow");
TEST_EQUAL(r.GetAddress(), "Moscow, Russia", ());
@@ -50,8 +50,7 @@ UNIT_TEST(Result_PrependCity)
{
Result r(fid, m2::PointD::Zero(), "улица Михася Лынькова" /* str */,
- "Минская область, Беларусь" /* address */, "" /* featureTypeName */,
- 0 /* featureType */, meta);
+ "Минская область, Беларусь" /* address */, 0 /* featureType */, meta);
r.PrependCity("Минск");
TEST_EQUAL(r.GetAddress(), "Минск, Минская область, Беларусь", ());