blob: bef8c5b5beeaa7d11374ecf06ef74b534847b349 (
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
53
54
55
56
57
58
|
#pragma once
#include "indexer/mwm_set.hpp"
#include "indexer/rank_table.hpp"
#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"
#include "geometry/tree4d.hpp"
#include "std/set.hpp"
#include "std/unique_ptr.hpp"
class Index;
namespace search
{
struct LocalityItem
{
LocalityItem(string const & name, uint32_t population, uint32_t id);
string m_name;
uint32_t m_population;
uint32_t m_id;
};
class LocalityFinder
{
public:
struct Cache
{
void Clear();
void GetLocality(m2::PointD const & pt, string & name);
m4::Tree<LocalityItem> m_tree;
set<uint32_t> m_loadedIds;
size_t m_usage = 0;
m2::RectD m_rect;
};
LocalityFinder(Index const & index);
void SetLanguage(int8_t lang);
void GetLocality(m2::PointD const & pt, string & name);
void ClearCache();
private:
void UpdateCache(Cache & cache, m2::PointD const & pt);
Index const & m_index;
MwmSet::MwmId m_worldId;
unique_ptr<RankTable> m_ranks;
Cache m_caches[10];
int8_t m_lang;
};
string DebugPrint(LocalityItem const & item);
} // namespace search
|