Loading...
Searching...
No Matches
osmium::Location Class Reference

`#include <location.hpp>`

## Public Types

enum | { undefined_coordinate = 2147483647 }

## 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)
constexpr | operator bool () const noexcept
constexpr bool | valid () const noexcept
constexpr bool | is_defined () const noexcept
constexpr bool | is_undefined () 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 noexcept
double | lat () const
double | lat_without_check () const noexcept
Location & | set_lon (double lon) noexcept
Location & | set_lat (double lat) noexcept
Location & | set_lon (const char *str)
Location & | set_lat (const char *str)
Location & | set_lon_partial (const char **str)
Location & | set_lat_partial (const char **str)
template<typename T>
T | as_string_without_check (T iterator, const char separator=',') const
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 Private Member Functions

static constexpr double | precision () noexcept
static constexpr int32_t | remove_extra_bit (int32_t v) noexcept

## 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.

If the macro OSMIUM_LOCATION_WITH_EXTRA_BIT is defined, Location values can store one extra bit of information, because one bit is not needed for the y coordinate. Use the functions set/clear/toggle/get_extra_bit() to access it. The extra bit will always be cleared for new locations or by setting the y coordinate of a location. You can not store an extra bit on an invalid location.

## Member Enumeration Documentation

## anonymous enum

anonymous enum

Enumerator
undefined_coordinate |

## Constructor & Destructor Documentation

## Location() [1/4]

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

inline explicit constexpr noexcept

Create undefined Location.

## Location() [2/4]

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

inline constexpr noexcept

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

## Location() [3/4]

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

inline constexpr noexcept

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

## Location() [4/4]

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

inline

Create Location with given longitude and latitude in WGS84 coordinates.

## Member Function Documentation

## as_string()

template<typename T>

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

inline

## as_string_without_check()

template<typename T>

T osmium::Location::as_string_without_check | ( | T | iterator,
|  | const char | separator = ',' ) const

inline

## double_to_fix()

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

inline static noexcept

## fix_to_double()

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

inline static constexpr noexcept

## is_defined()

bool osmium::Location::is_defined | ( |  | ) | const

inline constexpr noexcept

Returns true if at least one of the coordinates is defined.

See also is_undefined() and valid().

## is_undefined()

bool osmium::Location::is_undefined | ( |  | ) | const

inline constexpr noexcept

Returns true if both coordinates are undefined.

See also is_defined() and valid().

## lat()

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

inline

Get latitude.

Exceptions

  invalid_location | if the location is invalid

## lat_without_check()

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

inline noexcept

Get latitude without checking the validity.

## lon()

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

inline

Get longitude.

Exceptions

  invalid_location | if the location is invalid

## lon_without_check()

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

inline noexcept

Get longitude without checking the validity.

## operator bool()

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

inline explicit constexpr noexcept

Check whether the coordinates of this location are defined.

Deprecated
  Use is_defined() or is_undefined() or valid() which have all slightly different meanings.

## precision()

constexpr double osmium::Location::precision | ( |  | ) |

inline static constexpr private noexcept

## remove_extra_bit()

constexpr int32_t osmium::Location::remove_extra_bit | ( | int32_t | v | ) |

inline static constexpr private noexcept

## set_lat() [1/2]

Location & osmium::Location::set_lat | ( | const char * | str | ) |

inline

## set_lat() [2/2]

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

inline noexcept

## set_lat_partial()

Location & osmium::Location::set_lat_partial | ( | const char ** | str | ) |

inline

## set_lon() [1/2]

Location & osmium::Location::set_lon | ( | const char * | str | ) |

inline

## set_lon() [2/2]

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

inline noexcept

## set_lon_partial()

Location & osmium::Location::set_lon_partial | ( | const char ** | str | ) |

inline

## set_x()

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

inline noexcept

## set_y()

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

inline noexcept

Set the y coordinate of the location.

This will always clear the extra bit.

## valid()

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

inline constexpr noexcept

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

See also is_defined() and is_undefined().

## x()

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

inline constexpr noexcept

## y()

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

inline constexpr noexcept

## Member Data Documentation

## m_x

int32_t osmium::Location::m_x

private

## m_y

int32_t osmium::Location::m_y

private

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

- include/osmium/osm/location.hpp