1 #ifndef OSMIUM_OSM_BOX_HPP
2 #define OSMIUM_OSM_BOX_HPP
61 constexpr
Box() noexcept :
71 Box(
double minx,
double miny,
double maxx,
double maxy) :
72 m_bottom_left(minx, miny),
73 m_top_right(maxx, maxy) {
74 assert(minx <= maxx && miny <= maxy);
87 m_bottom_left(bottom_left),
88 m_top_right(top_right) {
90 (!!bottom_left && !!top_right) ||
91 (bottom_left.
x() <= top_right.
x() && bottom_left.
y() <= top_right.
y())
111 if (location.valid()) {
113 if (location.x() < m_bottom_left.
x()) {
114 m_bottom_left.
set_x(location.x());
116 if (location.x() > m_top_right.
x()) {
117 m_top_right.
set_x(location.x());
119 if (location.y() < m_bottom_left.
y()) {
120 m_bottom_left.
set_y(location.y());
122 if (location.y() > m_top_right.
y()) {
123 m_top_right.
set_y(location.y());
126 m_bottom_left = location;
127 m_top_right = location;
141 extend(box.bottom_left());
149 explicit constexpr
operator bool() const noexcept {
150 return bool(m_bottom_left) && bool(m_top_right);
157 constexpr
bool valid() const noexcept {
212 return (m_top_right.
lon() - m_bottom_left.
lon()) *
213 (m_top_right.
lat() - m_bottom_left.
lat());
223 return lhs.bottom_left() == rhs.bottom_left() &&
224 lhs.top_right() == rhs.top_right();
233 template <
typename TChar,
typename TTraits>
234 inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out,
const osmium::Box& box) {
239 << box.bottom_left().lat()
241 << box.top_right().lon()
243 << box.top_right().lat()
246 out <<
"(undefined)";
253 #endif // OSMIUM_OSM_BOX_HPP
osmium::Location m_bottom_left
Definition: box.hpp:52
Location & top_right() noexcept
Definition: box.hpp:185
bool contains(const osmium::Location &location) const noexcept
Definition: box.hpp:195
constexpr bool operator==(const Box &lhs, const Box &rhs) noexcept
Definition: box.hpp:222
constexpr Location top_right() const noexcept
Definition: box.hpp:178
Box & extend(const Location &location) noexcept
Definition: box.hpp:110
constexpr bool valid() const noexcept
Definition: location.hpp:156
Box & operator=(const Box &)=default
double lat() const
Definition: location.hpp:205
Namespace for everything in the Osmium library.
Definition: assembler.hpp:59
Box & extend(const Box &box) noexcept
Definition: box.hpp:140
osmium::Location m_top_right
Definition: box.hpp:53
constexpr bool valid() const noexcept
Definition: box.hpp:157
constexpr int32_t y() const noexcept
Definition: location.hpp:167
Location & bottom_left() noexcept
Definition: box.hpp:171
Location & set_y(const int32_t y) noexcept
Definition: location.hpp:176
Box(const osmium::Location &bottom_left, const osmium::Location &top_right)
Definition: box.hpp:86
Definition: location.hpp:79
Location & set_x(const int32_t x) noexcept
Definition: location.hpp:171
double lon() const
Definition: location.hpp:186
constexpr Location bottom_left() const noexcept
Definition: box.hpp:164
Box(double minx, double miny, double maxx, double maxy)
Definition: box.hpp:71
constexpr int32_t x() const noexcept
Definition: location.hpp:163
double size() const
Definition: box.hpp:211
constexpr Box() noexcept
Definition: box.hpp:61