forked from organicmaps/organicmaps
Search result improvements
This commit is contained in:
parent
49a69c5ced
commit
652a1c538f
10 changed files with 204 additions and 123 deletions
|
@ -60,6 +60,8 @@ set(
|
|||
routing_manager.hpp
|
||||
routing_mark.cpp
|
||||
routing_mark.hpp
|
||||
search_mark.cpp
|
||||
search_mark.hpp
|
||||
taxi_delegate.cpp
|
||||
taxi_delegate.hpp
|
||||
track.cpp
|
||||
|
|
|
@ -142,15 +142,6 @@ double const kDistEqualQueryMeters = 100.0;
|
|||
double const kLargeFontsScaleFactor = 1.6;
|
||||
size_t constexpr kMaxTrafficCacheSizeBytes = 64 /* Mb */ * 1024 * 1024;
|
||||
|
||||
// Must correspond SearchMarkType.
|
||||
vector<string> kSearchMarks =
|
||||
{
|
||||
"search-result",
|
||||
"search-booking",
|
||||
"search-adv",
|
||||
"search-cian", // TODO: delete me after Cian project is finished.
|
||||
};
|
||||
|
||||
// TODO!
|
||||
// To adjust GpsTrackFilter was added secret command "?gpstrackaccuracy:xxx;"
|
||||
// where xxx is a new value for horizontal accuracy.
|
||||
|
@ -961,8 +952,8 @@ void Framework::FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & inf
|
|||
|
||||
void Framework::FillSearchResultInfo(SearchMarkPoint const & smp, place_page::Info & info) const
|
||||
{
|
||||
if (smp.GetFoundFeature().IsValid())
|
||||
FillFeatureInfo(smp.GetFoundFeature(), info);
|
||||
if (smp.GetFeatureID().IsValid())
|
||||
FillFeatureInfo(smp.GetFeatureID(), info);
|
||||
else
|
||||
FillPointInfo(smp.GetPivot(), smp.GetMatchedName(), info);
|
||||
}
|
||||
|
@ -1635,15 +1626,8 @@ bool Framework::Search(search::SearchParams const & params)
|
|||
// Cancels previous search request (if any) and initiates new search request.
|
||||
CancelQuery(intent.m_handle);
|
||||
|
||||
{
|
||||
double eps = 0.0;
|
||||
for (size_t i = 0; i < SearchMarkType::SearchMarkTypesCount; i++)
|
||||
{
|
||||
m2::PointD const markSize = GetSearchMarkSize(static_cast<SearchMarkType>(i));
|
||||
eps = max(eps, max(markSize.x, markSize.y));
|
||||
}
|
||||
intent.m_params.m_minDistanceOnMapBetweenResults = eps;
|
||||
}
|
||||
double const eps = SearchMarkPoint::GetMaxSearchMarkDimension(m_currentModelView);
|
||||
intent.m_params.m_minDistanceOnMapBetweenResults = eps;
|
||||
|
||||
Search(intent);
|
||||
|
||||
|
@ -1836,19 +1820,19 @@ void Framework::FillSearchResultsMarks(search::Results::ConstIter begin,
|
|||
|
||||
if (isFeature && m_localAdsManager.Contains(r.GetFeatureID()))
|
||||
{
|
||||
mark->SetCustomSymbol("search-adv");
|
||||
mark->SetMarkType(SearchMarkType::LocalAds);
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: delete me after Cian project is finished.
|
||||
if (m_cianSearchMode)
|
||||
{
|
||||
mark->SetCustomSymbol("search-cian");
|
||||
mark->SetMarkType(SearchMarkType::Cian);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r.m_metadata.m_isSponsoredHotel)
|
||||
mark->SetCustomSymbol("search-booking");
|
||||
mark->SetMarkType(SearchMarkType::Booking);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1996,9 +1980,10 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
|
|||
if (m_connectToGpsTrack)
|
||||
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
|
||||
|
||||
m_drapeEngine->RequestSymbolsSize(kSearchMarks, [this](vector<m2::PointF> const & sizes)
|
||||
m_drapeEngine->RequestSymbolsSize(SearchMarkPoint::GetAllSymbolsNames(),
|
||||
[this](vector<m2::PointF> const & sizes)
|
||||
{
|
||||
GetPlatform().RunOnGuiThread([this, sizes](){ m_searchMarksSizes = sizes; });
|
||||
GetPlatform().RunOnGuiThread([this, sizes](){ SearchMarkPoint::SetSearchMarksSizes(sizes); });
|
||||
});
|
||||
|
||||
m_drapeApi.SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
|
@ -2803,18 +2788,6 @@ void Framework::BlockTapEvents(bool block)
|
|||
m_drapeEngine->BlockTapEvents(block);
|
||||
}
|
||||
|
||||
m2::PointD Framework::GetSearchMarkSize(SearchMarkType searchMarkType)
|
||||
{
|
||||
if (m_searchMarksSizes.empty())
|
||||
return m2::PointD();
|
||||
|
||||
ASSERT_LESS(static_cast<size_t>(searchMarkType), m_searchMarksSizes.size(), ());
|
||||
m2::PointF const pixelSize = m_searchMarksSizes[searchMarkType];
|
||||
|
||||
double const pixelToMercator = m_currentModelView.GetScale();
|
||||
return m2::PointD(pixelToMercator * pixelSize.x, pixelToMercator * pixelSize.y);
|
||||
}
|
||||
|
||||
namespace feature
|
||||
{
|
||||
string GetPrintableTypes(FeatureType const & ft)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "map/place_page_info.hpp"
|
||||
#include "map/routing_manager.hpp"
|
||||
#include "map/routing_mark.hpp"
|
||||
#include "map/search_mark.hpp"
|
||||
#include "map/track.hpp"
|
||||
#include "map/traffic_manager.hpp"
|
||||
#include "map/user.hpp"
|
||||
|
@ -339,8 +340,6 @@ public:
|
|||
BookmarkAndCategory FindBookmark(UserMark const * mark) const;
|
||||
BookmarkManager & GetBookmarkManager() { return m_bmManager; }
|
||||
|
||||
m2::PointD GetSearchMarkSize(SearchMarkType searchMarkType);
|
||||
|
||||
// Utilities
|
||||
void VisualizeRoadsInRect(m2::RectD const & rect);
|
||||
|
||||
|
@ -447,8 +446,6 @@ private:
|
|||
/// Here we store last selected feature to get its polygons in case of adding organization.
|
||||
mutable FeatureID m_selectedFeature;
|
||||
|
||||
vector<m2::PointF> m_searchMarksSizes;
|
||||
|
||||
private:
|
||||
vector<m2::TriangleD> GetSelectedFeatureTriangles() const;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ HEADERS += \
|
|||
reachable_by_taxi_checker.hpp \
|
||||
routing_manager.hpp \
|
||||
routing_mark.hpp \
|
||||
search_mark.hpp \
|
||||
taxi_delegate.hpp \
|
||||
track.hpp \
|
||||
traffic_manager.hpp \
|
||||
|
@ -68,6 +69,7 @@ SOURCES += \
|
|||
reachable_by_taxi_checker.cpp \
|
||||
routing_manager.cpp \
|
||||
routing_mark.cpp \
|
||||
search_mark.cpp \
|
||||
taxi_delegate.cpp \
|
||||
track.cpp \
|
||||
traffic_manager.cpp \
|
||||
|
|
117
map/search_mark.cpp
Normal file
117
map/search_mark.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
#include "map/search_mark.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
std::vector<m2::PointF> SearchMarkPoint::m_searchMarksSizes;
|
||||
|
||||
SearchMarkPoint::SearchMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
|
||||
: UserMark(ptOrg, container)
|
||||
{}
|
||||
|
||||
std::string SearchMarkPoint::GetSymbolName() const
|
||||
{
|
||||
if (m_isPreparing)
|
||||
{
|
||||
//TODO: set symbol for preparing state.
|
||||
return "non-found-search-result";
|
||||
}
|
||||
|
||||
auto const & symbols = GetAllSymbolsNames();
|
||||
auto const index = static_cast<size_t>(m_type);
|
||||
if (index >= static_cast<size_t>(SearchMarkType::Count))
|
||||
{
|
||||
ASSERT(false, ("Unknown search mark symbol."));
|
||||
return symbols[static_cast<size_t>(SearchMarkType::Default)];
|
||||
}
|
||||
return symbols[index];
|
||||
}
|
||||
|
||||
UserMark::Type SearchMarkPoint::GetMarkType() const
|
||||
{
|
||||
return UserMark::Type::SEARCH;
|
||||
}
|
||||
|
||||
void SearchMarkPoint::SetFoundFeature(FeatureID const & feature)
|
||||
{
|
||||
if (m_featureID == feature)
|
||||
return;
|
||||
|
||||
SetDirty();
|
||||
m_featureID = feature;
|
||||
}
|
||||
|
||||
void SearchMarkPoint::SetMatchedName(std::string const & name)
|
||||
{
|
||||
if (m_matchedName == name)
|
||||
return;
|
||||
|
||||
SetDirty();
|
||||
m_matchedName = name;
|
||||
}
|
||||
|
||||
void SearchMarkPoint::SetMarkType(SearchMarkType type)
|
||||
{
|
||||
if (m_type == type)
|
||||
return;
|
||||
|
||||
SetDirty();
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
void SearchMarkPoint::SetPreparing(bool isPreparing)
|
||||
{
|
||||
if (m_isPreparing == isPreparing)
|
||||
return;
|
||||
|
||||
SetDirty();
|
||||
m_isPreparing = isPreparing;
|
||||
}
|
||||
|
||||
// static
|
||||
std::vector<std::string> const & SearchMarkPoint::GetAllSymbolsNames()
|
||||
{
|
||||
static std::vector<std::string> const kSymbols =
|
||||
{
|
||||
"search-result", // Default.
|
||||
"search-booking", // Booking.
|
||||
"search-adv", // LocalAds.
|
||||
"search-cian", // TODO: delete me after Cian project is finished.
|
||||
|
||||
"non-found-search-result", // NotFound.
|
||||
};
|
||||
|
||||
return kSymbols;
|
||||
}
|
||||
|
||||
// static
|
||||
void SearchMarkPoint::SetSearchMarksSizes(std::vector<m2::PointF> const & sizes)
|
||||
{
|
||||
m_searchMarksSizes = sizes;
|
||||
}
|
||||
|
||||
// static
|
||||
double SearchMarkPoint::GetMaxSearchMarkDimension(ScreenBase const & modelView)
|
||||
{
|
||||
double dimension = 0.0;
|
||||
for (size_t i = 0; i < static_cast<size_t>(SearchMarkType::Count); ++i)
|
||||
{
|
||||
m2::PointD const markSize = GetSearchMarkSize(static_cast<SearchMarkType>(i), modelView);
|
||||
dimension = std::max(dimension, std::max(markSize.x, markSize.y));
|
||||
}
|
||||
return dimension;
|
||||
}
|
||||
|
||||
// static
|
||||
m2::PointD SearchMarkPoint::GetSearchMarkSize(SearchMarkType searchMarkType,
|
||||
ScreenBase const & modelView)
|
||||
{
|
||||
if (m_searchMarksSizes.empty())
|
||||
return {};
|
||||
|
||||
auto const index = static_cast<size_t>(searchMarkType);
|
||||
ASSERT_LESS(index, m_searchMarksSizes.size(), ());
|
||||
m2::PointF const pixelSize = m_searchMarksSizes[index];
|
||||
|
||||
double const pixelToMercator = modelView.GetScale();
|
||||
return {pixelToMercator * pixelSize.x, pixelToMercator * pixelSize.y};
|
||||
}
|
57
map/search_mark.hpp
Normal file
57
map/search_mark.hpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include "map/user_mark.hpp"
|
||||
|
||||
#include "indexer/feature_decl.hpp"
|
||||
|
||||
#include "geometry/point2d.hpp"
|
||||
#include "geometry/screenbase.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
enum class SearchMarkType
|
||||
{
|
||||
Default = 0,
|
||||
Booking,
|
||||
LocalAds,
|
||||
Cian, // TODO: delete me after Cian project is finished.
|
||||
|
||||
NotFound, // Service value used in developer tools.
|
||||
Count
|
||||
};
|
||||
|
||||
class SearchMarkPoint : public UserMark
|
||||
{
|
||||
public:
|
||||
SearchMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container);
|
||||
|
||||
std::string GetSymbolName() const override;
|
||||
UserMark::Type GetMarkType() const override;
|
||||
|
||||
FeatureID GetFeatureID() const override { return m_featureID; }
|
||||
void SetFoundFeature(FeatureID const & feature);
|
||||
|
||||
std::string const & GetMatchedName() const { return m_matchedName; }
|
||||
void SetMatchedName(std::string const & name);
|
||||
|
||||
void SetMarkType(SearchMarkType type);
|
||||
|
||||
void SetPreparing(bool isPreparing);
|
||||
|
||||
static std::vector<std::string> const & GetAllSymbolsNames();
|
||||
static void SetSearchMarksSizes(std::vector<m2::PointF> const & sizes);
|
||||
static double GetMaxSearchMarkDimension(ScreenBase const & modelView);
|
||||
|
||||
protected:
|
||||
static m2::PointD GetSearchMarkSize(SearchMarkType searchMarkType,
|
||||
ScreenBase const & modelView);
|
||||
|
||||
SearchMarkType m_type = SearchMarkType::Default;
|
||||
FeatureID m_featureID;
|
||||
// Used to pass exact search result matched string into a place page.
|
||||
std::string m_matchedName;
|
||||
bool m_isPreparing = false;
|
||||
|
||||
static std::vector<m2::PointF> m_searchMarksSizes;
|
||||
};
|
|
@ -48,41 +48,9 @@ ms::LatLon UserMark::GetLatLon() const
|
|||
return MercatorBounds::ToLatLon(m_ptOrg);
|
||||
}
|
||||
|
||||
SearchMarkPoint::SearchMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
|
||||
: UserMark(ptOrg, container)
|
||||
{
|
||||
}
|
||||
|
||||
string SearchMarkPoint::GetSymbolName() const
|
||||
{
|
||||
return m_customSymbol.empty() ? "search-result" : m_customSymbol;
|
||||
}
|
||||
|
||||
UserMark::Type SearchMarkPoint::GetMarkType() const
|
||||
{
|
||||
return UserMark::Type::SEARCH;
|
||||
}
|
||||
|
||||
void SearchMarkPoint::SetFoundFeature(FeatureID const & feature)
|
||||
{
|
||||
SetDirty();
|
||||
m_foundFeatureID = feature;
|
||||
}
|
||||
|
||||
void SearchMarkPoint::SetMatchedName(string const & name)
|
||||
{
|
||||
SetDirty();
|
||||
m_matchedName = name;
|
||||
}
|
||||
|
||||
void SearchMarkPoint::SetCustomSymbol(string const & symbol)
|
||||
{
|
||||
SetDirty();
|
||||
m_customSymbol = symbol;
|
||||
}
|
||||
|
||||
PoiMarkPoint::PoiMarkPoint(UserMarkContainer * container)
|
||||
: SearchMarkPoint(m2::PointD::Zero(), container) {}
|
||||
: UserMark(m2::PointD::Zero(), container)
|
||||
{}
|
||||
|
||||
UserMark::Type PoiMarkPoint::GetMarkType() const
|
||||
{
|
||||
|
@ -97,8 +65,7 @@ void PoiMarkPoint::SetPtOrg(m2::PointD const & ptOrg)
|
|||
|
||||
MyPositionMarkPoint::MyPositionMarkPoint(UserMarkContainer * container)
|
||||
: PoiMarkPoint(container)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
UserMark::Type MyPositionMarkPoint::GetMarkType() const
|
||||
{
|
||||
|
|
|
@ -14,13 +14,11 @@
|
|||
#include "std/utility.hpp"
|
||||
|
||||
class UserMarkContainer;
|
||||
class UserMarkCopy;
|
||||
|
||||
class UserMark : public df::UserPointMark
|
||||
{
|
||||
DISALLOW_COPY_AND_MOVE(UserMark);
|
||||
public:
|
||||
static uint16_t constexpr kDefaultUserMarkProirity = 0xFFFF;
|
||||
static uint16_t constexpr kDefaultUserMarkPriority = 0xFFFF;
|
||||
|
||||
enum class Type
|
||||
{
|
||||
|
@ -35,7 +33,6 @@ public:
|
|||
};
|
||||
|
||||
UserMark(m2::PointD const & ptOrg, UserMarkContainer * container);
|
||||
virtual ~UserMark() {}
|
||||
|
||||
// df::UserPointMark overrides.
|
||||
bool IsDirty() const override { return m_isDirty; }
|
||||
|
@ -47,7 +44,7 @@ public:
|
|||
float GetDepth() const override;
|
||||
df::RenderState::DepthLayer GetDepthLayer() const override;
|
||||
drape_ptr<dp::TitleDecl> GetTitleDecl() const override { return nullptr; }
|
||||
uint16_t GetPriority() const override { return kDefaultUserMarkProirity; }
|
||||
uint16_t GetPriority() const override { return kDefaultUserMarkPriority; }
|
||||
bool HasSymbolPriority() const override { return false; }
|
||||
bool HasTitlePriority() const override { return false; }
|
||||
int GetMinZoom() const override { return 1; }
|
||||
|
@ -67,45 +64,16 @@ protected:
|
|||
|
||||
private:
|
||||
mutable bool m_isDirty = true;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(UserMark);
|
||||
};
|
||||
|
||||
enum SearchMarkType
|
||||
{
|
||||
DefaultSearchMark = 0,
|
||||
BookingSearchMark,
|
||||
LocalAdsSearchMark,
|
||||
|
||||
SearchMarkTypesCount
|
||||
};
|
||||
|
||||
class SearchMarkPoint : public UserMark
|
||||
class PoiMarkPoint : public UserMark
|
||||
{
|
||||
public:
|
||||
SearchMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container);
|
||||
explicit PoiMarkPoint(UserMarkContainer * container);
|
||||
|
||||
string GetSymbolName() const override;
|
||||
UserMark::Type GetMarkType() const override;
|
||||
|
||||
FeatureID const & GetFoundFeature() const { return m_foundFeatureID; }
|
||||
void SetFoundFeature(FeatureID const & feature);
|
||||
|
||||
string const & GetMatchedName() const { return m_matchedName; }
|
||||
void SetMatchedName(string const & name);
|
||||
|
||||
string const & GetCustomSymbol() const { return m_customSymbol; }
|
||||
void SetCustomSymbol(string const & symbol);
|
||||
|
||||
protected:
|
||||
FeatureID m_foundFeatureID;
|
||||
// Used to pass exact search result matched string into a place page.
|
||||
string m_matchedName;
|
||||
string m_customSymbol;
|
||||
};
|
||||
|
||||
class PoiMarkPoint : public SearchMarkPoint
|
||||
{
|
||||
public:
|
||||
PoiMarkPoint(UserMarkContainer * container);
|
||||
string GetSymbolName() const override { return {}; }
|
||||
UserMark::Type GetMarkType() const override;
|
||||
|
||||
void SetPtOrg(m2::PointD const & ptOrg);
|
||||
|
@ -114,7 +82,7 @@ public:
|
|||
class MyPositionMarkPoint : public PoiMarkPoint
|
||||
{
|
||||
public:
|
||||
MyPositionMarkPoint(UserMarkContainer * container);
|
||||
explicit MyPositionMarkPoint(UserMarkContainer * container);
|
||||
|
||||
UserMark::Type GetMarkType() const override;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "map/framework.hpp"
|
||||
#include "map/user_mark_container.hpp"
|
||||
#include "map/search_mark.hpp"
|
||||
|
||||
#include "drape_frontend/drape_engine.hpp"
|
||||
#include "drape_frontend/tile_key.hpp"
|
||||
|
@ -12,7 +13,6 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
|
||||
class FindMarkFunctor
|
||||
{
|
||||
public:
|
||||
|
@ -51,8 +51,7 @@ df::MarkGroupID GenerateMarkGroupId(UserMarkContainer const * cont)
|
|||
{
|
||||
return reinterpret_cast<df::MarkGroupID>(cont);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
UserMarkContainer::UserMarkContainer(double layerDepth, UserMarkType type, Framework & fm)
|
||||
: m_framework(fm)
|
||||
|
@ -302,4 +301,3 @@ UserMark * ApiUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
|
|||
{
|
||||
return new ApiMarkPoint(ptOrg, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "map/bookmark_manager.hpp"
|
||||
#include "map/framework.hpp"
|
||||
#include "map/user_mark.hpp"
|
||||
#include "map/search_mark.hpp"
|
||||
|
||||
#include "search/result.hpp"
|
||||
#include "search/search_quality/assessment_tool/helpers.hpp"
|
||||
|
@ -264,7 +264,7 @@ void SampleView::ShowNonFoundResultsMarks(std::vector<search::Sample::Result> co
|
|||
|
||||
SearchMarkPoint * mark =
|
||||
static_cast<SearchMarkPoint *>(controller.CreateUserMark(result.m_pos));
|
||||
mark->SetCustomSymbol("non-found-search-result");
|
||||
mark->SetMarkType(SearchMarkType::NotFound);
|
||||
}
|
||||
controller.NotifyChanges();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue