osmium::Box Class Reference

`#include <box.hpp>`

Collaboration diagram for osmium::Box:
[legend]

## Public Member Functions

constexpr | Box () noexcept
| Box (double minx, double miny, double maxx, double maxy)
| Box (const osmium::Location &bottom_left, const osmium::Location &top_right)
| Box (const Box &)=default
| Box (Box &&)=default
Box & | operator= (const Box &)=default
Box & | operator= (Box &&)=default
| ~Box ()=default
Box & | extend (const Location &location) noexcept
Box & | extend (const Box &box) noexcept
constexpr | operator bool () const noexcept
constexpr bool | valid () const noexcept
constexpr Location | bottom_left () const noexcept
Location & | bottom_left () noexcept
constexpr Location | top_right () const noexcept
Location & | top_right () noexcept
bool | contains (const osmium::Location &location) const noexcept
double | size () const

## Private Attributes

osmium::Location | m_bottom_left
osmium::Location | m_top_right

## Detailed Description

Bounding box. A box is defined by two locations (bottom left location and top right location) or, alternatively by four coordinates (minx, miny, maxx, and maxy). If both locations are undefined, the box is undefined, too.

## Constructor & Destructor Documentation

constexpr osmium::Box::Box | ( |  | ) |

inline noexcept

Create undefined Box. Use the extend() function to add actual bounds.

osmium::Box::Box | ( | double | minx,
|  | double | miny,
|  | double | maxx,
|  | double | maxy
| ) |  |

inline

Create box from minimum and maximum coordinates.

Precondition
  minx <= maxx && miny <= maxy

osmium::Box::Box | ( | const osmium::Location & | bottom_left,
|  | const osmium::Location & | top_right
| ) |  |

inline

Create box from bottom left and top right locations.

Precondition
  Either both locations must be defined or neither.
  If both locations are defined, the bottom left location must actually be to the left and below the top right location. Same coordinates for bottom/top or left/right are also okay.

osmium::Box::Box | ( | const Box & |  | ) |

default

osmium::Box::Box | ( | Box && |  | ) |

default

osmium::Box::~Box | ( |  | ) |

default

## Member Function Documentation

constexpr Location osmium::Box::bottom_left | ( |  | ) | const

inline noexcept

Access bottom-left location.

Location& osmium::Box::bottom_left | ( |  | ) |

inline noexcept

Access bottom-left location.

bool osmium::Box::contains | ( | const osmium::Location & | location | ) | const

inline noexcept

Check whether the location is inside the box.

Precondition
  Location must be defined.
  Box must be defined.

Box& osmium::Box::extend | ( | const Location & | location | ) |

inline noexcept

Extend this bounding box by the specified location. If the location is invalid, the bounding box is unchanged. If the box is undefined it will only contain the new location after this call.

Parameters

  location | The location we want to extend the box by.

Returns
  A reference to this box.

Box& osmium::Box::extend | ( | const Box & | box | ) |

inline noexcept

Extend this bounding box by the specified box. If the specified box is undefined, the bounding box is unchanged.

Parameters

  box | The box to extend by.

Returns
  A reference to this box.

constexpr osmium::Box::operator bool | ( |  | ) | const

inline explicit noexcept

Box is defined, ie. contains defined locations.

Box& osmium::Box::operator= | ( | const Box & |  | ) |

default

Box& osmium::Box::operator= | ( | Box && |  | ) |

default

double osmium::Box::size | ( |  | ) | const

inline

Calculate size of the box in square degrees.

Note that this measure isn't very useful if you want to know the real-world size of the bounding box!

Exceptions

  osmium::invalid_location | unless all coordinates are valid.

constexpr Location osmium::Box::top_right | ( |  | ) | const

inline noexcept

Access top-right location.

Location& osmium::Box::top_right | ( |  | ) |

inline noexcept

Access top-right location.

constexpr bool osmium::Box::valid | ( |  | ) | const

inline noexcept

Box is valid, ie. defined and inside usual bounds (-180<=lon<=180, -90<=lat<=90).

## Member Data Documentation

osmium::Location osmium::Box::m_bottom_left

private

osmium::Location osmium::Box::m_top_right

private

The documentation for this class was generated from the following file:

- osmium/osm/box.hpp