[search] Fixed search in viewport filtering.

This commit is contained in:
Yuri Gorshenin 2016-09-22 13:59:06 +03:00
parent 87312eac64
commit 461f973706
8 changed files with 29 additions and 14 deletions

View file

@ -24,7 +24,6 @@ namespace search
{
/// All constants in meters.
double const DIST_EQUAL_RESULTS = 100.0;
double const DIST_SAME_STREET = 5000.0;
char const * const kEmptyRatingSymbol = "-";
char const * const kPricingSymbol = "$";
@ -241,12 +240,17 @@ Result PreResult2::GenerateFinalResult(storage::CountryInfoGetter const & infoGe
}
}
bool PreResult2::StrictEqualF::operator() (PreResult2 const & r) const
PreResult2::StrictEqualF::StrictEqualF(PreResult2 const & r, double const epsMeters)
: m_r(r), m_epsMeters(epsMeters)
{
}
bool PreResult2::StrictEqualF::operator()(PreResult2 const & r) const
{
if (m_r.m_resultType == r.m_resultType && m_r.m_resultType == RESULT_FEATURE)
{
if (m_r.IsEqualCommon(r))
return (PointDistance(m_r.GetCenter(), r.GetCenter()) < DIST_EQUAL_RESULTS);
return PointDistance(m_r.GetCenter(), r.GetCenter()) < m_epsMeters;
}
return false;

View file

@ -84,10 +84,14 @@ public:
/// Filter equal features for different mwm's.
class StrictEqualF
{
PreResult2 const & m_r;
public:
StrictEqualF(PreResult2 const & r) : m_r(r) {}
bool operator() (PreResult2 const & r) const;
StrictEqualF(PreResult2 const & r, double const epsMeters);
bool operator()(PreResult2 const & r) const;
private:
PreResult2 const & m_r;
double const m_epsMeters;
};
/// To filter equal linear objects.

View file

@ -209,10 +209,7 @@ void PreRanker::Filter(bool viewportSearch)
filtered.insert(m_results.begin(), m_results.begin() + n);
}
m_results.reserve(filtered.size());
m_results.clear();
copy(filtered.begin(), filtered.end(), back_inserter(m_results));
m_results.assign(filtered.begin(), filtered.end());
}
void PreRanker::UpdateResults(bool lastUpdate)

View file

@ -27,6 +27,9 @@ public:
struct Params
{
m2::RectD m_viewport;
// A minimum distance between search results in meters, needed for
// filtering of viewport search results.
double m_minDistanceOnMapBetweenResults = 0.0;
// This is different from geocoder's pivot because pivot is

View file

@ -699,10 +699,12 @@ void Processor::InitRanker(Geocoder::Params const & geocoderParams)
if (viewportSearch)
{
params.m_viewport = GetViewport();
params.m_minDistanceOnMapBetweenResults = m_minDistanceOnMapBetweenResults;
params.m_limit = kPreResultsCount;
}
else
{
params.m_minDistanceOnMapBetweenResults = 100.0;
params.m_limit = kResultsCount;
}
params.m_position = GetPosition();

View file

@ -301,7 +301,8 @@ void Ranker::Init(Params const & params, Geocoder::Params const & geocoderParams
bool Ranker::IsResultExists(PreResult2 const & p, vector<IndexedValue> const & values)
{
PreResult2::StrictEqualF equalCmp(p);
PreResult2::StrictEqualF equalCmp(p, m_params.m_minDistanceOnMapBetweenResults);
// Do not insert duplicating results.
return values.end() != find_if(values.begin(), values.end(), [&equalCmp](IndexedValue const & iv)
{
@ -509,8 +510,8 @@ void Ranker::UpdateResults(bool lastUpdate)
// Emit feature results.
size_t count = m_emitter.GetResults().GetCount();
size_t i;
for (i = 0; i < m_tentativeResults.size(); ++i)
size_t i = 0;
for (; i < m_tentativeResults.size(); ++i)
{
if (!lastUpdate && i >= kBatchSize && !m_params.m_viewportSearch)
break;

View file

@ -60,6 +60,10 @@ public:
m2::PointD m_accuratePivotCenter = m2::PointD(0, 0);
// A minimum distance between search results in meters, needed for
// filtering of indentical search results.
double m_minDistanceOnMapBetweenResults = 0.0;
TLocales m_categoryLocales;
size_t m_limit = 0;

View file

@ -49,7 +49,7 @@ public:
double m_lat, m_lon;
// A minimum distance between search results in mercator, needed for
// A minimum distance between search results in meters, needed for
// pre-ranking of viewport search results.
double m_minDistanceOnMapBetweenResults;