Libosmium  2.5.4
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)
 
 Location (const Location &)=default
 
 Location (Location &&)=default
 
Locationoperator= (const Location &)=default
 
Locationoperator= (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
 
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
 
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
 
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 ( )
inlineexplicitnoexcept

Create undefined Location.

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.

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.

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 ( iterator,
const char  separator 
) const
inline
static int32_t osmium::Location::double_to_fix ( const double  c)
inlinestaticnoexcept
static constexpr double osmium::Location::fix_to_double ( const int32_t  c)
inlinestaticnoexcept
double osmium::Location::lat ( ) const
inline

Get latitude.

Exceptions
invalid_locationif 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_locationif the location is invalid
double osmium::Location::lon_without_check ( ) const
inline

Get longitude without checking the validity.

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

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)
inlinenoexcept
Location& osmium::Location::set_lon ( double  lon)
inlinenoexcept
Location& osmium::Location::set_x ( const int32_t  x)
inlinenoexcept
Location& osmium::Location::set_y ( const int32_t  y)
inlinenoexcept
constexpr bool osmium::Location::valid ( ) const
inlinenoexcept

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

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

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: