olp-cpp-sdk  1.22.0
Public Member Functions | Static Public Member Functions | List of all members
olp::geo::GeoCoordinates Class Reference

A geographic location that uses the WGS84 Coordinate System. More...

#include <GeoCoordinates.h>

Public Member Functions

 GeoCoordinates ()
 Creates a GeoCoordinates instance with invalid coordinates.
 
 GeoCoordinates (double latitude_radians, double longitude_radians)
 Creates a GeoCoordinates instance from latitude and longitude. More...
 
 GeoCoordinates (double latitude_degrees, double longitude_degrees, DegreeType degrees)
 Creates a GeoCoordinates instance from latitude and longitude. More...
 
GeoPoint ToGeoPoint () const
 Converts the current coordinates to a geo point. More...
 
double GetLatitude () const
 Gets the WGS84 latitude in radians. More...
 
void SetLatitude (double latitude_radians)
 Sets the latitude in radians. More...
 
double GetLongitude () const
 Gets the WGS84 longitude in radians. More...
 
void SetLongitude (double longitude_radians)
 Sets the longitude in radians. More...
 
double GetLatitudeDegrees () const
 Gets the WGS84 latitude in degrees. More...
 
void SetLatitudeDegrees (double latitude_degrees)
 Sets the latitude in degrees. More...
 
double GetLongitudeDegrees () const
 Gets the WGS84 longitude in degrees. More...
 
void SetLongitudeDegrees (double longitude_degrees)
 Sets the longitude in degrees. More...
 
GeoCoordinates Normalized () const
 Normalizes the latitude and longitude to the [-pi/2, pi/2] and [-pi, pi] ranges correspondingly.
 
 operator bool () const
 Overloads the bool operator. More...
 
bool IsValid () const
 Checks whether the radian values of latitude and longitude are valid double numbers. More...
 

Static Public Member Functions

static GeoCoordinates FromDegrees (double latitude_degrees, double longitude_degrees)
 Creates a GeoCoordinates instance from latitude and longitude. More...
 
static GeoCoordinates FromGeoPoint (const GeoPoint &geo_point)
 Creates a GeoCoordinates instance from a geo point. More...
 

Detailed Description

A geographic location that uses the WGS84 Coordinate System.

Latitude values range from 0 at the equator to 90 degrees north and -90 degrees south. Longitude values range from 0 at the prime meridian to 180 degrees east and -180 degrees west.

Internal representation of angles is radians.

Constructor & Destructor Documentation

◆ GeoCoordinates() [1/2]

olp::geo::GeoCoordinates::GeoCoordinates ( double  latitude_radians,
double  longitude_radians 
)

Creates a GeoCoordinates instance from latitude and longitude.

Note
Use Normalized() to put a coordinate in a valid range.
Parameters
latitude_radiansThe WGS84 latitude in radians. Valid values are in the [-pi/2, pi/2] range.
longitude_radiansThe WGS84 longitude in radians. Valid values are in the [-pi, pi] range.

◆ GeoCoordinates() [2/2]

olp::geo::GeoCoordinates::GeoCoordinates ( double  latitude_degrees,
double  longitude_degrees,
DegreeType  degrees 
)

Creates a GeoCoordinates instance from latitude and longitude.

Note
Use Normalized() to put a coordinate in a valid range.
Parameters
latitude_degreesThe WGS84 latitude in degrees. Valid values are in the [-90, 90] range.
longitude_degreesThe WGS84 longitude in degrees. Valid values are in the [-180, 180] range.
degreesThe dispatch tag for coordinates in degrees.

Member Function Documentation

◆ FromDegrees()

static GeoCoordinates olp::geo::GeoCoordinates::FromDegrees ( double  latitude_degrees,
double  longitude_degrees 
)
static

Creates a GeoCoordinates instance from latitude and longitude.

Note
Use Normalized() to put a value in a valid range.
Parameters
latitude_degreesThe WGS84 latitude in degrees. Valid values are in the [-90, 90] range.
longitude_degreesThe WGS84 longitude in degrees. Valid values are in the [-180, 180] range.
Returns
The GeoCoordinates instance based on the specified latitude and longitude.

◆ FromGeoPoint()

static GeoCoordinates olp::geo::GeoCoordinates::FromGeoPoint ( const GeoPoint geo_point)
static

Creates a GeoCoordinates instance from a geo point.

Parameters
geo_pointThe geo point.
Returns
The GeoCoordinates instance based on the specified geo point.

◆ GetLatitude()

double olp::geo::GeoCoordinates::GetLatitude ( ) const

Gets the WGS84 latitude in radians.

Returns
The WGS84 latitude in radians.

◆ GetLatitudeDegrees()

double olp::geo::GeoCoordinates::GetLatitudeDegrees ( ) const

Gets the WGS84 latitude in degrees.

Returns
The WGS84 latitude in degrees.

◆ GetLongitude()

double olp::geo::GeoCoordinates::GetLongitude ( ) const

Gets the WGS84 longitude in radians.

Returns
The WGS84 longitude in radians.

◆ GetLongitudeDegrees()

double olp::geo::GeoCoordinates::GetLongitudeDegrees ( ) const

Gets the WGS84 longitude in degrees.

Returns
The WGS84 longitude in degrees.

◆ IsValid()

bool olp::geo::GeoCoordinates::IsValid ( ) const

Checks whether the radian values of latitude and longitude are valid double numbers.

The check happens with the help of math::isnan.

Returns
True if the result of the check is positive; false otherwise.

◆ operator bool()

olp::geo::GeoCoordinates::operator bool ( ) const
explicit

Overloads the bool operator.

See also
IsValid
Returns
True if the coordinates are valid; false otherwise.

◆ SetLatitude()

void olp::geo::GeoCoordinates::SetLatitude ( double  latitude_radians)

Sets the latitude in radians.

Parameters
latitude_radiansThe WGS84 latitude in radians. Valid values are in the [-pi/2, pi/2] range.

◆ SetLatitudeDegrees()

void olp::geo::GeoCoordinates::SetLatitudeDegrees ( double  latitude_degrees)

Sets the latitude in degrees.

Parameters
latitude_degreesThe WGS84 latitude in degrees. Valid values are in the [-90, 90] range.

◆ SetLongitude()

void olp::geo::GeoCoordinates::SetLongitude ( double  longitude_radians)

Sets the longitude in radians.

Parameters
longitude_radiansThe WGS84 longitude in radians. Valid values are in the [-pi, pi] range.

◆ SetLongitudeDegrees()

void olp::geo::GeoCoordinates::SetLongitudeDegrees ( double  longitude_degrees)

Sets the longitude in degrees.

Parameters
longitude_degreesThe WGS84 longitude in degrees. Valid values are in the [-180, 180] range.

◆ ToGeoPoint()

GeoPoint olp::geo::GeoCoordinates::ToGeoPoint ( ) const

Converts the current coordinates to a geo point.

Returns
The current coordinates as a geo point.

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