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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#pragma once
#include "params.hpp"
#include "../geometry/rect2d.hpp"
#include "../coding/reader.hpp"
#include "../base/mutex.hpp"
#include "../std/scoped_ptr.hpp"
#include "../std/string.hpp"
#include "../std/function.hpp"
class Index;
namespace search
{
class Query;
class Results;
class EngineData;
class Engine
{
typedef function<void (Results const &)> SearchCallbackT;
public:
typedef Index IndexType;
// Doesn't take ownership of @pIndex. Takes ownership of pCategories
Engine(IndexType const * pIndex, Reader * pCategoriesR,
ModelReaderPtr polyR, ModelReaderPtr countryR,
string const & lang);
~Engine();
void PrepareSearch(m2::RectD const & viewport,
bool hasPt, double lat, double lon);
bool Search(SearchParams const & params, m2::RectD const & viewport);
string GetCountryFile(m2::PointD const & pt);
string GetCountryCode(m2::PointD const & pt);
int8_t GetCurrentLanguage() const;
private:
template <class T> string GetCountryNameT(T const & t);
public:
string GetCountryName(m2::PointD const & pt);
string GetCountryName(string const & id);
bool GetNameByType(uint32_t type, int8_t lang, string & name) const;
m2::RectD GetCountryBounds(string const & file) const;
void ClearCaches();
private:
static const int RESULTS_COUNT = 15;
void SetViewportAsync(m2::RectD const & viewport, m2::RectD const & nearby);
void SearchAsync();
threads::Mutex m_searchMutex, m_updateMutex, m_readyMutex;
volatile bool m_readyThread;
SearchParams m_params;
m2::RectD m_viewport;
Index const * m_pIndex;
scoped_ptr<search::Query> m_pQuery;
scoped_ptr<EngineData> m_pData;
};
} // namespace search
|