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

params.cpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 78a2683cc316644436a517b8743d821425237d04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "params.hpp"

#include "indexer/mercator.hpp"

#include "coding/multilang_utf8_string.hpp"


namespace search
{

SearchParams::SearchParams()
  : m_searchRadiusM(-1.0), m_searchMode(ALL),
    m_forceSearch(false), m_validPos(false)
{
}

void SearchParams::SetPosition(double lat, double lon)
{
  m_lat = lat;
  m_lon = lon;
  m_validPos = true;
}

bool SearchParams::GetSearchRect(m2::RectD & rect) const
{
  if (IsSearchAroundPosition())
  {
    rect = MercatorBounds::MetresToXY(m_lon, m_lat, m_searchRadiusM);
    return true;
  }
  return false;
}

bool SearchParams::IsEqualCommon(SearchParams const & rhs) const
{
  return (m_query == rhs.m_query &&
          m_inputLocale == rhs.m_inputLocale &&
          m_validPos == rhs.m_validPos &&
          m_searchMode == rhs.m_searchMode &&
          m_searchRadiusM == rhs.m_searchRadiusM);
}

string DebugPrint(SearchParams const & params)
{
  ostringstream ss;
  ss << "{ SearchParams: Query = " << params.m_query <<
                      ", Locale = " << params.m_inputLocale <<
                      ", Mode = " << params.m_searchMode << " }";
  return ss.str();
}

} // namespace search