libdballe 9.6
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
dballe::Coords Struct Reference

Coordinates. More...

#include <types.h>

Public Member Functions

 Coords ()=default
 Construct a missing Coords.
 
 Coords (int lat, int lon)
 Construct a coords from integers in 1/100000 of a degree.
 
 Coords (double lat, double lon)
 Construct a coords from values in degrees.
 
bool is_missing () const
 Check if these coordinates are undefined.
 
void set_lat (double lat)
 Set the latitude only.
 
void set_lon (double lon)
 Set the longitude only.
 
void set_lat (int lat)
 Set the latitude only, in 1/100000 of a degree.
 
void set_lon (int lon)
 Set the longitude only, in 1/100000 of a degree.
 
void set (int lat, int lon)
 Set from integers in 1/100000 of a degree.
 
void set (double lat, double lon)
 Set from values in degrees.
 
double dlat () const
 Get the latitude in degrees.
 
double dlon () const
 Get the longitude in degrees.
 
int compare (const Coords &o) const
 Compare two Coords strutures, for use in sorting.
 
bool operator== (const Coords &o) const
 
bool operator!= (const Coords &o) const
 
bool operator< (const Coords &o) const
 
bool operator> (const Coords &o) const
 
bool operator<= (const Coords &o) const
 
bool operator>= (const Coords &o) const
 
int print (FILE *out, const char *end="\n") const
 Print to an output stream.
 
std::string to_string (const char *undef="-") const
 Format to a string.
 

Static Public Member Functions

static int lat_to_int (double lat)
 Convert a latitude to the internal integer representation.
 
static int lon_to_int (double lat)
 Convert a longitude to the internal integer representation.
 
static double lat_from_int (int lat)
 Convert a latitude from the internal integer representation.
 
static double lon_from_int (int lon)
 Convert a longitude from the internal integer representation.
 

Public Attributes

int lat = MISSING_INT
 Latitude in 1/100000 of a degree (5 significant digits preserved)
 
int lon = MISSING_INT
 Longitude in 1/100000 of a degree (5 significant digits preserved) and normalised between -180.0 and 180.0.
 

Detailed Description

Coordinates.

When given as an integer, a latitude/longitude value is intended in 1/100000 of a degree, which is the maximum resolution supported by DB-All.e.

When given as a double a latitude/longitude value is intended to be in degrees.

Longitude values are normalized between -180.0 and 180.0.

Member Function Documentation

◆ compare()

int dballe::Coords::compare ( const Coords o) const

Compare two Coords strutures, for use in sorting.

Sorting happens by latitude first, then by longitude. It is implemented mainly for the purpose of being able to use Coords as a key in a sorted container.

Returns
-1 if *this < o, 0 if *this == o, 1 if *this > o

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