osmium::Location Class Reference

`#include <location.hpp>`

## Public Member Functions

constexpr | Location () noexcept
constexpr | Location (const int32_t x, const int32_t y) noexcept
constexpr | Location (const int64_t x, const int64_t y) noexcept
| Location (const double lon, const double lat)
| Location (const Location &)=default
| Location (Location &&)=default
Location & | operator= (const Location &)=default
Location & | operator= (Location &&)=default
| ~Location ()=default
constexpr | operator bool () const noexcept
constexpr bool | valid () const noexcept
constexpr int32_t | x () const noexcept
constexpr int32_t | y () const noexcept
Location & | set_x (const int32_t x) noexcept
Location & | set_y (const int32_t y) noexcept
double | lon () const
double | lon_without_check () const
double | lat () const
double | lat_without_check () const
Location & | set_lon (double lon) noexcept
Location & | set_lat (double lat) noexcept
template<typename T >
T | as_string (T iterator, const char separator) const

## Static Public Member Functions

static int32_t | double_to_fix (const double c) noexcept
static constexpr double | fix_to_double (const int32_t c) noexcept

## Static Public Attributes

static constexpr int32_t | undefined_coordinate = 2147483647
static constexpr int | coordinate_precision = 10000000

## Private Attributes

int32_t | m_x
int32_t | m_y

## Detailed Description

Locations define a place on earth.

Locations are stored in 32 bit integers for the x and y coordinates, respectively. This gives you an accuracy of a few centimeters, good enough for OSM use. (The main OSM database uses the same scheme.)

An undefined Location can be created by calling the constructor without parameters.

Coordinates are never checked on whether they are inside bounds. Call valid() to check this.

## Constructor & Destructor Documentation

constexpr osmium::Location::Location | ( |  | ) |

inline explicit noexcept

Create undefined Location.

constexpr osmium::Location::Location | ( | const int32_t | x,
|  | const int32_t | y
| ) |  |

inline noexcept

Create Location with given x and y coordinates. Note that these coordinates are coordinate_precision times larger than the real coordinates.

constexpr osmium::Location::Location | ( | const int64_t | x,
|  | const int64_t | y
| ) |  |

inline noexcept

Create Location with given x and y coordinates. Note that these coordinates are coordinate_precision times larger than the real coordinates.

osmium::Location::Location | ( | const double | lon,
|  | const double | lat
| ) |  |

inline

Create Location with given longitude and latitude.

osmium::Location::Location | ( | const Location & |  | ) |

default

osmium::Location::Location | ( | Location && |  | ) |

default

osmium::Location::~Location | ( |  | ) |

default

## Member Function Documentation

template<typename T >

T osmium::Location::as_string | ( | T | iterator,
|  | const char | separator
| ) |  | const

inline

static int32_t osmium::Location::double_to_fix | ( | const double | c | ) |

inline static noexcept

static constexpr double osmium::Location::fix_to_double | ( | const int32_t | c | ) |

inline static noexcept

double osmium::Location::lat | ( |  | ) | const

inline

Get latitude.

Exceptions

  invalid_location | if the location is invalid

double osmium::Location::lat_without_check | ( |  | ) | const

inline

Get latitude without checking the validity.

double osmium::Location::lon | ( |  | ) | const

inline

Get longitude.

Exceptions

  invalid_location | if the location is invalid

double osmium::Location::lon_without_check | ( |  | ) | const

inline

Get longitude without checking the validity.

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

inline explicit noexcept

Check whether the coordinates of this location are defined.

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

default

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

default

Location& osmium::Location::set_lat | ( | double | lat | ) |

inline noexcept

Location& osmium::Location::set_lon | ( | double | lon | ) |

inline noexcept

Location& osmium::Location::set_x | ( | const int32_t | x | ) |

inline noexcept

Location& osmium::Location::set_y | ( | const int32_t | y | ) |

inline noexcept

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

inline noexcept

Check whether the coordinates are inside the usual bounds (-180<=lon<=180, -90<=lat<=90).

constexpr int32_t osmium::Location::x | ( |  | ) | const

inline noexcept

constexpr int32_t osmium::Location::y | ( |  | ) | const

inline noexcept

## Member Data Documentation

constexpr int osmium::Location::coordinate_precision = 10000000

static

int32_t osmium::Location::m_x

private

int32_t osmium::Location::m_y

private

constexpr int32_t osmium::Location::undefined_coordinate = 2147483647

static

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

- osmium/osm/location.hpp