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
|
#pragma once
#include "geometry/bounding_box.hpp"
#include "geometry/calipers_box.hpp"
#include "geometry/diamond_box.hpp"
#include "geometry/point2d.hpp"
#include "base/visitor.hpp"
#include <vector>
namespace indexer
{
// Approximates city boundary.
// City points are inside the intersection of boxes.
struct CityBoundary
{
CityBoundary() = default;
explicit CityBoundary(std::vector<m2::PointD> const & ps) : m_bbox(ps), m_cbox(ps), m_dbox(ps) {}
bool HasPoint(m2::PointD const & p) const
{
return m_bbox.HasPoint(p) && m_dbox.HasPoint(p) && m_cbox.HasPoint(p);
}
bool HasPoint(double x, double y) const { return HasPoint(m2::PointD(x, y)); }
bool HasPoint(m2::PointD const & p, double eps) const
{
return m_bbox.HasPoint(p, eps) && m_dbox.HasPoint(p, eps) && m_cbox.HasPoint(p, eps);
}
bool HasPoint(double x, double y, double eps) const { return HasPoint(m2::PointD(x, y), eps); }
bool operator==(CityBoundary const & rhs) const
{
return m_bbox == rhs.m_bbox && m_cbox == rhs.m_cbox && m_dbox == rhs.m_dbox;
}
DECLARE_VISITOR(visitor(m_bbox), visitor(m_cbox), visitor(m_dbox))
DECLARE_DEBUG_PRINT(CityBoundary)
m2::BoundingBox m_bbox;
m2::CalipersBox m_cbox;
m2::DiamondBox m_dbox;
};
} // namespace indexer
|