Libosmium  2.20.0
Fast and flexible C++ library for working with OpenStreetMap data
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
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
 
Locationset_x (const int32_t x) noexcept
 
Locationset_y (const int32_t y) noexcept
 
double lon () const
 
double lon_without_check () const noexcept
 
double lat () const
 
double lat_without_check () const noexcept
 
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 Private Member Functions

static constexpr double precision () 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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
undefined_coordinate 

Constructor & Destructor Documentation

◆ Location() [1/4]

constexpr osmium::Location::Location ( )
inlineexplicitconstexprnoexcept

Create undefined Location.

◆ Location() [2/4]

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

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 
)
inlineconstexprnoexcept

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 ( 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)
inlinestaticconstexprnoexcept

◆ is_defined()

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

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
inlineconstexprnoexcept

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
inlinenoexcept

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
inlinenoexcept

Get longitude without checking the validity.

◆ operator bool()

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

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.

◆ precision()

static constexpr double osmium::Location::precision ( )
inlinestaticconstexprprivatenoexcept

◆ set_lat() [1/2]

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

◆ set_lat() [2/2]

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

◆ 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)
inlinenoexcept

◆ 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
inlineconstexprnoexcept

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
inlineconstexprnoexcept

◆ y()

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

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: