MCPcopy Create free account
hub / github.com/comaps/comaps / CountryPolygons

Class CountryPolygons

generator/borders.hpp:43–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41using PolygonsTree = m4::Tree<Polygon>;
42
43class CountryPolygons
44{
45public:
46 CountryPolygons() = default;
47 explicit CountryPolygons(std::string && name, PolygonsTree && regions)
48 : m_name(std::move(name))
49 , m_polygons(std::move(regions))
50 {}
51
52 std::string const & GetName() const { return m_name; }
53 bool IsEmpty() const { return m_polygons.IsEmpty(); }
54 void Clear()
55 {
56 m_polygons.Clear();
57 m_name.clear();
58 }
59
60 class ContainsCompareFn
61 {
62 double m_eps, m_squareEps;
63
64 public:
65 explicit ContainsCompareFn(double eps) : m_eps(eps), m_squareEps(eps * eps) {}
66 bool EqualPoints(m2::PointD const & p1, m2::PointD const & p2) const
67 {
68 return AlmostEqualAbs(p1.x, p2.x, m_eps) && AlmostEqualAbs(p1.y, p2.y, m_eps);
69 }
70 bool EqualZeroSquarePrecision(double val) const { return AlmostEqualAbs(val, 0.0, m_squareEps); }
71 };
72
73 static double GetContainsEpsilon() { return 1.0E-4; }
74
75 bool Contains(m2::PointD const & point) const;
76
77 template <typename Do>
78 void ForEachPolygon(Do && fn) const
79 {
80 m_polygons.ForEach(std::forward<Do>(fn));
81 }
82
83 template <typename Do>
84 bool ForAnyPolygon(Do && fn) const
85 {
86 return m_polygons.ForAny(std::forward<Do>(fn));
87 }
88
89private:
90 std::string m_name;
91
92 /// @todo Is it an overkill to store Tree4D for each country's polygon?
93 PolygonsTree m_polygons;
94};
95
96class CountryPolygonsCollection
97{

Callers 1

LoadCountriesListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected