Libosmium  2.14.0
Fast and flexible C++ library for working with OpenStreetMap data
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
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)
 
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
 
Locationset_x (const int32_t x) noexcept
 
Locationset_y (const int32_t y) noexcept
 
double lon () const
 
double lon_without_check () const
 
double lat () const
 
double lat_without_check () const
 
Locationset_lon (double lon) noexcept
 
Locationset_lat (double lat) noexcept
 
Locationset_lon (const char *str)
 
Locationset_lat (const char *str)
 
Locationset_lon_partial (const char **str)
 
Locationset_lat_partial (const char **str)
 
template<typename T >
as_string_without_check (T iterator, const char separator=',') const
 
template<typename 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
 

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

◆ Location() [1/4]

constexpr osmium::Location::Location ( )
inlineexplicitnoexcept

Create undefined Location.

◆ Location() [2/4]

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

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

◆ Location() [3/4]

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

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.

Member Function Documentation

◆ as_string()

template<typename T >
T osmium::Location::as_string ( iterator,
const char  separator = ',' 
) const
inline

◆ as_string_without_check()

template<typename T >
T osmium::Location::as_string_without_check ( iterator,
const char  separator = ',' 
) const
inline

◆ double_to_fix()

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

◆ fix_to_double()

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

◆ is_defined()

constexpr bool osmium::Location::is_defined ( ) const
inlinenoexcept

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

See also is_undefined() and is_valid().

◆ is_undefined()

constexpr bool osmium::Location::is_undefined ( ) const
inlinenoexcept

Returns true if both coordinates are undefined.

See also is_defined() and is_valid().

◆ lat()

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

Get latitude.

Exceptions
invalid_locationif the location is invalid

◆ lat_without_check()

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

Get latitude without checking the validity.

◆ lon()

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

Get longitude.

Exceptions
invalid_locationif the location is invalid

◆ lon_without_check()

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

Get longitude without checking the validity.

◆ operator bool()

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

Check whether the coordinates of this location are defined.

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

◆ set_lat() [1/2]

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

◆ set_lat() [2/2]

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

◆ set_lat_partial()

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

◆ set_lon() [1/2]

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

◆ set_lon() [2/2]

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

◆ set_lon_partial()

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

◆ set_x()

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

◆ set_y()

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

◆ valid()

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

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

See also is_defined() and is_undefined().

◆ x()

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

◆ y()

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

Member Data Documentation

◆ m_x

int32_t osmium::Location::m_x
private

◆ m_y

int32_t osmium::Location::m_y
private

◆ undefined_coordinate

constexpr int32_t osmium::Location::undefined_coordinate = 2147483647
static

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