forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaffiliation.hpp
77 lines (57 loc) · 2.38 KB
/
affiliation.hpp
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
#pragma once
#include "generator/borders.hpp"
#include "generator/cells_merger.hpp"
#include "generator/feature_builder.hpp"
#include <optional>
#include <string>
#include <vector>
#include <boost/geometry/index/rtree.hpp>
namespace feature
{
class AffiliationInterface
{
public:
virtual ~AffiliationInterface() = default;
// The method will return the names of the buckets to which the fb belongs.
virtual std::vector<std::string> GetAffiliations(FeatureBuilder const & fb) const = 0;
virtual std::vector<std::string> GetAffiliations(m2::PointD const & point) const = 0;
virtual bool HasCountryByName(std::string const & name) const = 0;
};
class CountriesFilesAffiliation : public AffiliationInterface
{
public:
CountriesFilesAffiliation(std::string const & borderPath, bool haveBordersForWholeWorld);
// AffiliationInterface overrides:
std::vector<std::string> GetAffiliations(FeatureBuilder const & fb) const override;
std::vector<std::string> GetAffiliations(m2::PointD const & point) const override;
bool HasCountryByName(std::string const & name) const override;
protected:
borders::CountryPolygonsCollection const & m_countryPolygonsTree;
bool m_haveBordersForWholeWorld;
};
class CountriesFilesIndexAffiliation : public CountriesFilesAffiliation
{
public:
using Box = boost::geometry::model::box<m2::PointD>;
using Value = std::pair<Box, std::vector<std::reference_wrapper<borders::CountryPolygons const>>>;
using Tree = boost::geometry::index::rtree<Value, boost::geometry::index::quadratic<16>>;
CountriesFilesIndexAffiliation(std::string const & borderPath, bool haveBordersForWholeWorld);
// AffiliationInterface overrides:
std::vector<std::string> GetAffiliations(FeatureBuilder const & fb) const override;
std::vector<std::string> GetAffiliations(m2::PointD const & point) const override;
private:
std::shared_ptr<Tree> BuildIndex(std::vector<m2::RectD> const & net);
std::shared_ptr<Tree> m_index;
};
class SingleAffiliation : public AffiliationInterface
{
public:
explicit SingleAffiliation(std::string const & filename);
// AffiliationInterface overrides:
std::vector<std::string> GetAffiliations(FeatureBuilder const &) const override;
std::vector<std::string> GetAffiliations(m2::PointD const & point) const override;
bool HasCountryByName(std::string const & name) const override;
private:
std::string m_filename;
};
} // namespace feature