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

nested_rects_cache.hpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 829132b7303117aa4d1967e27ea1ec25c676d287 (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
#pragma once

#include "indexer/feature_decl.hpp"

#include "geometry/point2d.hpp"

#include "std/map.hpp"
#include "std/vector.hpp"

class DataSource;

namespace search
{
class NestedRectsCache
{
public:
  explicit NestedRectsCache(DataSource const & dataSource);

  void SetPosition(m2::PointD const & position, int scale);

  double GetDistanceToFeatureMeters(FeatureID const & id) const;

  void Clear();

private:
  enum RectScale
  {
    RECT_SCALE_TINY,
    RECT_SCALE_SMALL,
    RECT_SCALE_MEDIUM,
    RECT_SCALE_LARGE,

    RECT_SCALE_COUNT
  };

  static double GetRadiusMeters(RectScale scale);

  void Update();

  DataSource const & m_dataSource;
  int m_scale;
  m2::PointD m_position;
  bool m_valid;

  using TFeatures = vector<uint32_t>;
  using TBucket = map<MwmSet::MwmId, TFeatures>;

  // Sorted lists of features.
  TBucket m_buckets[RECT_SCALE_COUNT];
};
}  // namespace search