1 #ifndef OSMIUM_OSM_BOX_HPP
2 #define OSMIUM_OSM_BOX_HPP
60 constexpr
Box() noexcept :
70 Box(
double minx,
double miny,
double maxx,
double maxy) :
71 m_bottom_left(minx, miny),
72 m_top_right(maxx, maxy) {
73 assert(minx <= maxx && miny <= maxy);
86 m_bottom_left(bottom_left),
87 m_top_right(top_right) {
89 (!!bottom_left && !!top_right) ||
90 (bottom_left.
x() <= top_right.
x() && bottom_left.
y() <= top_right.
y())
110 if (location.valid()) {
112 if (location.x() < m_bottom_left.
x()) {
113 m_bottom_left.
set_x(location.x());
115 if (location.x() > m_top_right.
x()) {
116 m_top_right.
set_x(location.x());
118 if (location.y() < m_bottom_left.
y()) {
119 m_bottom_left.
set_y(location.y());
121 if (location.y() > m_top_right.
y()) {
122 m_top_right.
set_y(location.y());
125 m_bottom_left = location;
126 m_top_right = location;
140 extend(box.bottom_left());
148 explicit constexpr
operator bool() const noexcept {
149 return bool(m_bottom_left) && bool(m_top_right);
156 constexpr
bool valid() const noexcept {
211 return (m_top_right.
lon() - m_bottom_left.
lon()) *
212 (m_top_right.
lat() - m_bottom_left.
lat());
222 return lhs.bottom_left() == rhs.bottom_left() &&
223 lhs.top_right() == rhs.top_right();
232 template <
typename TChar,
typename TTraits>
233 inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out,
const osmium::Box& box) {
238 << box.bottom_left().lat()
240 << box.top_right().lon()
242 << box.top_right().lat()
245 out <<
"(undefined)";
252 #endif // OSMIUM_OSM_BOX_HPP
osmium::Location m_bottom_left
Definition: box.hpp:51
Location & top_right() noexcept
Definition: box.hpp:184
bool contains(const osmium::Location &location) const noexcept
Definition: box.hpp:194
constexpr bool operator==(const Box &lhs, const Box &rhs) noexcept
Definition: box.hpp:221
constexpr Location top_right() const noexcept
Definition: box.hpp:177
Box & extend(const Location &location) noexcept
Definition: box.hpp:109
constexpr bool valid() const noexcept
Definition: location.hpp:341
Box & operator=(const Box &)=default
double lat() const
Definition: location.hpp:390
Namespace for everything in the Osmium library.
Definition: assembler.hpp:73
Box & extend(const Box &box) noexcept
Definition: box.hpp:139
osmium::Location m_top_right
Definition: box.hpp:52
constexpr bool valid() const noexcept
Definition: box.hpp:156
constexpr int32_t y() const noexcept
Definition: location.hpp:352
Location & bottom_left() noexcept
Definition: box.hpp:170
Location & set_y(const int32_t y) noexcept
Definition: location.hpp:361
Box(const osmium::Location &bottom_left, const osmium::Location &top_right)
Definition: box.hpp:85
Definition: location.hpp:266
Location & set_x(const int32_t x) noexcept
Definition: location.hpp:356
double lon() const
Definition: location.hpp:371
constexpr Location bottom_left() const noexcept
Definition: box.hpp:163
Box(double minx, double miny, double maxx, double maxy)
Definition: box.hpp:70
constexpr int32_t x() const noexcept
Definition: location.hpp:348
double size() const
Definition: box.hpp:210
constexpr Box() noexcept
Definition: box.hpp:60