GeographicalLocation Class Reference

CPP API: mio::geo::GeographicalLocation Class Reference

Class representing a geographical location on the Earth's surface. More...

#include <geolocation.h>

Collaboration diagram for mio::geo::GeographicalLocation:

Public Member Functions

auto default_serialize ()
 Default serialize the GeographicalLocation object. More...
 
Distance distance (const GeographicalLocation &other) const
 
 GeographicalLocation ()=default
 Construct a new Geographical Location object using the default constructor to keep compatibility with ABM code. More...
 
 GeographicalLocation (ScalarType lat, ScalarType lon)
 Construct a new Geographical Location object. More...
 
 GeographicalLocation (std::pair< ScalarType, ScalarType > coordinates)
 Construct a new Geographical Location object. More...
 
ScalarType get_latitude () const
 Get the latitude object. More...
 
ScalarType get_longitude () const
 Get the longitude object. More...
 
bool is_close (const GeographicalLocation &other, Distance tol=Distance(10 *Limits< ScalarType >::zero_tolerance())) const
 Check that this location is within a (small) distance of another. More...
 
bool operator!= (const GeographicalLocation &other) const
 Compare two GeographicalLocations for inequality. More...
 
bool operator== (const GeographicalLocation &other) const
 Compare two GeographicalLocations for equality. More...
 
void set_latitude (ScalarType lat)
 Set the latitude object. More...
 
void set_longitude (ScalarType lon)
 Set the longitude object. More...
 

Private Member Functions

void check_input () const
 Assert that the latitude and longitude are within valid ranges. More...
 

Private Attributes

ScalarType m_latitude
 
ScalarType m_longitude
 

Static Private Attributes

constexpr static mio::geo::Distance earth_radius = mio::geo::kilometers(6371.)
 
constexpr static ScalarType radians = std::numbers::pi / 180.0
 

Detailed Description

Class representing a geographical location on the Earth's surface.

Provides latitude and longitude in degrees and a method to calculate the distance to another location.

Constructor & Destructor Documentation

◆ GeographicalLocation() [1/3]

mio::geo::GeographicalLocation::GeographicalLocation ( ScalarType  lat,
ScalarType  lon 
)
inline

Construct a new Geographical Location object.

Parameters
latLatitude in degrees.
lonLongitude in degrees.

◆ GeographicalLocation() [2/3]

mio::geo::GeographicalLocation::GeographicalLocation ( std::pair< ScalarType, ScalarType coordinates)
inline

Construct a new Geographical Location object.

Parameters
coordinatesPair of latitude and longitude in degrees as ScalarTypes.

◆ GeographicalLocation() [3/3]

mio::geo::GeographicalLocation::GeographicalLocation ( )
default

Construct a new Geographical Location object using the default constructor to keep compatibility with ABM code.

Member Function Documentation

◆ check_input()

void mio::geo::GeographicalLocation::check_input ( ) const
inlineprivate

Assert that the latitude and longitude are within valid ranges.

◆ default_serialize()

auto mio::geo::GeographicalLocation::default_serialize ( )
inline

Default serialize the GeographicalLocation object.

This method is used by the default serialization feature.

◆ distance()

Distance mio::geo::GeographicalLocation::distance ( const GeographicalLocation other) const
inline

◆ get_latitude()

ScalarType mio::geo::GeographicalLocation::get_latitude ( ) const
inline

Get the latitude object.

Returns
ScalarType latitude in degrees

◆ get_longitude()

ScalarType mio::geo::GeographicalLocation::get_longitude ( ) const
inline

Get the longitude object.

Returns
ScalarType longitude in degrees

◆ is_close()

bool mio::geo::GeographicalLocation::is_close ( const GeographicalLocation other,
Distance  tol = Distance(10 * Limits<ScalarType>::zero_tolerance()) 
) const
inline

Check that this location is within a (small) distance of another.

Parameters
[in]otherAny location.
[in]tolThe Absolute tolerance for considering two locations close.

◆ operator!=()

bool mio::geo::GeographicalLocation::operator!= ( const GeographicalLocation other) const
inline

Compare two GeographicalLocations for inequality.

◆ operator==()

bool mio::geo::GeographicalLocation::operator== ( const GeographicalLocation other) const
inline

Compare two GeographicalLocations for equality.

◆ set_latitude()

void mio::geo::GeographicalLocation::set_latitude ( ScalarType  lat)
inline

Set the latitude object.

Parameters
latLatitude in degrees.

◆ set_longitude()

void mio::geo::GeographicalLocation::set_longitude ( ScalarType  lon)
inline

Set the longitude object.

Parameters
lonLongitude in degrees.

Member Data Documentation

◆ earth_radius

constexpr static mio::geo::Distance mio::geo::GeographicalLocation::earth_radius = mio::geo::kilometers(6371.)
staticconstexprprivate

◆ m_latitude

ScalarType mio::geo::GeographicalLocation::m_latitude
private

◆ m_longitude

ScalarType mio::geo::GeographicalLocation::m_longitude
private

◆ radians

constexpr static ScalarType mio::geo::GeographicalLocation::radians = std::numbers::pi / 180.0
staticconstexprprivate