A static class to handle geographic algorithms. This class offers methods to handle lat/lon coordinates, to transform lat/lon coordinates, to compute distances on a sphere or to convert between coordinate systems.
#include <CoordsAlgorithms.h>
Static Public Member Functions | |
static double | dms_to_decimal (const std::string &dms) |
Parse a latitude or longitude It can be formatted as any of the following examples: More... | |
static std::string | decimal_to_dms (const double &decimal) |
Converts a decimal latitude or longitude to degrees, minutes, seconds It formats its arguments as in the following example: 46°48'03". More... | |
static void | parseLatLon (const std::string &coordinates, double &lat, double &lon) |
Parse a latitude-longitude pair It can be formatted as any of the following examples: More... | |
static std::string | printLatLon (const double &latitude, const double &longitude) |
Print a nicely formatted lat/lon in degrees, minutes, seconds. More... | |
static double | lat_degree_lenght (const double &latitude) |
Lenght of one degree of latitude This returns the lenght in meters of one degree of latitude around the given latitude (ie: latitude-.5, latitude+.5). See https://en.wikipedia.org/wiki/Latitude#The_length_of_a_degree_of_latitude. More... | |
static double | lon_degree_lenght (const double &latitude) |
Lenght of one degree of longitude This returns the lenght in meters of one degree of longitude around the given latitude (ie: latitude-.5, latitude+.5). See https://en.wikipedia.org/wiki/Latitude#The_length_of_a_degree_of_latitude. More... | |
static short int | str_to_EPSG (const std::string &coordsystem, const std::string &coordparam) |
returns the epsg code matching a provided string representation For example, when given "CH1903" with empty coordparam, it will return "21781" More... | |
static void | EPSG_to_str (const int &epsg, std::string &coordsystem, std::string &coordparam) |
Build the string representation for a given EPSG code. More... | |
static void | rotatedToTrueLatLon (const double &lat_N, const double &lon_N, const double &lat_rot, const double &lon_rot, double &lat_true, double &lon_true) |
Convert rotated lat/lon into geographic lat/lon Rotated coordinates are created by moving the North pole by a given offset along latitude and longitude. The goal is to put the equator through the center of the domain of interest, so a lat/lon grid can easily be approximated by a tangential cartesian coordinate system. (see http://www.cosmo-model.org/content/model/documentation/core/default.htm, part I, chapter 3.3 for more) More... | |
static void | trueLatLonToRotated (const double &lat_N, const double &lon_N, const double &lat_true, const double &lon_true, double &lat_rot, double &lon_rot) |
Convert geographic lat/lon into rotated lat/lon Rotated coordinates are created by moving the North pole by a given offset along latitude and longitude. The goal is to put the equator through the center of the domain of interest, so a lat/lon grid can easily be approximated by a tangential cartesian coordinate system. (see http://www.cosmo-model.org/content/model/documentation/core/default.htm, part I, chapter 3.3 for more) More... | |
static double | cosineDistance (const double &lat1, const double &lon1, const double &lat2, const double &lon2, double &alpha) |
Spherical law of cosine Distance calculation between points in WGS84 (decimal Lat/Long) See http://www.movable-type.co.uk/scripts/latlong.html for more. More... | |
static void | cosineInverse (const double &lat_ref, const double &lon_ref, const double &distance, const double &bearing, double &lat, double &lon) |
Spherical law of cosine Distance calculation between points in WGS84 (decimal Lat/Long) See http://www.movable-type.co.uk/scripts/latlong.html for more. More... | |
static double | VincentyDistance (const double &lat1, const double &lon1, const double &lat2, const double &lon2, double &alpha) |
Vincenty Distance calculation between points in WGS84 (decimal Lat/Long) See T. Vincenty, "Closed formulas for the direct and reverse geodetic problems", Journal of Geodesy, 51, 3, 1977, DOI:10.1007/BF02521599, see http://www.springerlink.com/content/y7108u6862473583 for more. More... | |
static void | VincentyInverse (const double &lat_ref, const double &lon_ref, const double &distance, const double &bearing, double &lat, double &lon) |
Vincenty Inverse calculation giving WGS84 (decimal Lat/Long) position given a start location (lat,lon) a distance and a bearing See T. Vincenty, "Closed formulas for the direct and reverse geodetic problems", Journal of Geodesy, 51, 3, 1977, DOI:10.1007/BF02521599, see http://www.springerlink.com/content/y7108u6862473583 for more. More... | |
static void | WGS84_to_CH1903 (const double &lat_in, const double &long_in, double &east_out, double &north_out) |
Coordinate conversion: from WGS84 Lat/Long to Swiss grid See http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf for more. More... | |
static void | CH1903_to_WGS84 (const double &east_in, const double &north_in, double &lat_out, double &long_out) |
Coordinate conversion: from Swiss grid to WGS84 Lat/Long See http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf for more. More... | |
static void | WGS84_to_UTM (const double &lat_in, double long_in, const std::string &coordparam, double &east_out, double &north_out) |
Coordinate conversion: from WGS84 Lat/Long to UTM grid See http://www.oc.nps.edu/oc2902w/maps/utmups.pdf for more. More... | |
static void | UTM_to_WGS84 (double east_in, double north_in, const std::string &coordparam, double &lat_out, double &long_out) |
Coordinate conversion: from UTM grid to WGS84 Lat/Long See http://www.oc.nps.edu/oc2902w/maps/utmups.pdf for more. More... | |
static void | WGS84_to_UPS (const double &lat_in, const double &long_in, const std::string &coordparam, double &east_out, double &north_out) |
Coordinate conversion: from WGS84 Lat/Long to Universal Polar Stereographic grid see J. Hager, J. Behensky, B. Drew, THE UNIVERSAL GRIDS: Universal Transverse Mercator (UTM) and Universal Polar Stereographic (UPS), 1989, Defense Mapping Agency, DMATM 8358.2. This is valid above latitudes 84N or above 80S. More... | |
static void | UPS_to_WGS84 (const double &east_in, const double &north_in, const std::string &coordparam, double &lat_out, double &long_out) |
Coordinate conversion: from Universal Polar Stereographic grid to WGS84 Lat/Long see J. Hager, J. Behensky, B. Drew, THE UNIVERSAL GRIDS: Universal Transverse Mercator (UTM) and Universal Polar Stereographic (UPS), 1989, Defense Mapping Agency, DMATM 8358.2. This is valid above latitudes 84N or above 80S. More... | |
static void | WGS84_to_PROJ4 (const double &lat_in, const double &long_in, const std::string &coordparam, double &east_out, double &north_out) |
Coordinate conversion: from WGS84 Lat/Long to proj4 parameters. More... | |
static void | PROJ4_to_WGS84 (const double &east_in, const double &north_in, const std::string &coordparam, double &lat_out, double &long_out) |
Coordinate conversion: from proj4 parameters to WGS84 Lat/Long. More... | |
|
static |
Coordinate conversion: from Swiss grid to WGS84 Lat/Long See http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf for more.
[in] | east_in | easting coordinate (Swiss system) |
[in] | north_in | northing coordinate (Swiss system) |
[out] | lat_out | Decimal Latitude |
[out] | long_out | Decimal Longitude |
|
static |
Spherical law of cosine Distance calculation between points in WGS84 (decimal Lat/Long) See http://www.movable-type.co.uk/scripts/latlong.html for more.
[in] | lat1 | Decimal Latitude (const double&) |
[in] | lon1 | Decimal Longitude (const double&) |
[in] | lat2 | Decimal Latitude (const double&) |
[in] | lon2 | Decimal Longitude (const double&) |
[out] | alpha | average bearing |
|
static |
Spherical law of cosine Distance calculation between points in WGS84 (decimal Lat/Long) See http://www.movable-type.co.uk/scripts/latlong.html for more.
[in] | lat_ref | Decimal Latitude (const double&) |
[in] | lon_ref | Decimal Longitude (const double&) |
[in] | distance | Distance in meters (const double&) |
[in] | bearing | bearing in degrees, 0 being north (const double&) |
[out] | lat | Decimal latitude of target point (double&) |
[out] | lon | Decimal longitude of target point (double&) |
|
static |
Converts a decimal latitude or longitude to degrees, minutes, seconds It formats its arguments as in the following example: 46°48'03".
[in] | decimal | decimal coordinate to convert |
|
static |
Parse a latitude or longitude It can be formatted as any of the following examples:
[in] | dms | string containing the coordinate |
|
static |
Build the string representation for a given EPSG code.
[in] | epsg | epsg code |
[out] | coordsystem | string representation of the coordinate system |
[out] | coordparam | string representation of the optional coordinate system parameters (such as zone for utm, etc) |
|
static |
Lenght of one degree of latitude This returns the lenght in meters of one degree of latitude around the given latitude (ie: latitude-.5, latitude+.5). See https://en.wikipedia.org/wiki/Latitude#The_length_of_a_degree_of_latitude.
[in] | latitude | latitude where to perform the computation |
|
static |
Lenght of one degree of longitude This returns the lenght in meters of one degree of longitude around the given latitude (ie: latitude-.5, latitude+.5). See https://en.wikipedia.org/wiki/Latitude#The_length_of_a_degree_of_latitude.
[in] | latitude | latitude where to perform the computation |
|
static |
Parse a latitude-longitude pair It can be formatted as any of the following examples:
[in] | coordinates | string containing the coordinates |
[out] | lat | parsed latitude |
[out] | lon | parsed longitude |
|
static |
Print a nicely formatted lat/lon in degrees, minutes, seconds.
|
static |
Coordinate conversion: from proj4 parameters to WGS84 Lat/Long.
east_in | easting coordinate (Swiss system) | |
north_in | northing coordinate (Swiss system) | |
[in] | coordparam | Extra parameters necessary for the conversion (such as UTM zone, etc) |
lat_out | Decimal Latitude | |
long_out | Decimal Longitude |
|
static |
Convert rotated lat/lon into geographic lat/lon Rotated coordinates are created by moving the North pole by a given offset along latitude and longitude. The goal is to put the equator through the center of the domain of interest, so a lat/lon grid can easily be approximated by a tangential cartesian coordinate system. (see http://www.cosmo-model.org/content/model/documentation/core/default.htm, part I, chapter 3.3 for more)
[in] | lat_N | North pole latitude offset |
[in] | lon_N | North pole longitude offset |
[in] | lat_rot | rotated latitude |
[in] | lon_rot | rotated longitude |
[out] | lat_true | geographic latitude |
[out] | lon_true | geographic longitude |
|
static |
returns the epsg code matching a provided string representation For example, when given "CH1903" with empty coordparam, it will return "21781"
[in] | coordsystem | string representation of the coordinate system |
[in] | coordparam | string representation of the optional coordinate system parameters (such as zone for utm, etc) |
|
static |
Convert geographic lat/lon into rotated lat/lon Rotated coordinates are created by moving the North pole by a given offset along latitude and longitude. The goal is to put the equator through the center of the domain of interest, so a lat/lon grid can easily be approximated by a tangential cartesian coordinate system. (see http://www.cosmo-model.org/content/model/documentation/core/default.htm, part I, chapter 3.3 for more)
[in] | lat_N | North pole latitude offset |
[in] | lon_N | North pole longitude offset |
[in] | lat_true | geographic latitude |
[in] | lon_true | geographic longitude |
[out] | lat_rot | rotated latitude |
[out] | lon_rot | rotated longitude |
|
static |
Coordinate conversion: from Universal Polar Stereographic grid to WGS84 Lat/Long see J. Hager, J. Behensky, B. Drew, THE UNIVERSAL GRIDS: Universal Transverse Mercator (UTM) and Universal Polar Stereographic (UPS), 1989, Defense Mapping Agency, DMATM 8358.2. This is valid above latitudes 84N or above 80S.
[in] | east_in | easting coordinate (UTM) |
[in] | north_in | northing coordinate (UTM) |
[in] | coordparam | UPS zone, either "N" or "S" |
[out] | lat_out | Decimal Latitude |
[out] | long_out | Decimal Longitude |
|
static |
Coordinate conversion: from UTM grid to WGS84 Lat/Long See http://www.oc.nps.edu/oc2902w/maps/utmups.pdf for more.
[in] | east_in | easting coordinate (UTM) |
[in] | north_in | northing coordinate (UTM) |
[in] | coordparam | UTM zone of the easting/northing |
[out] | lat_out | Decimal Latitude |
[out] | long_out | Decimal Longitude |
|
static |
Vincenty Distance calculation between points in WGS84 (decimal Lat/Long) See T. Vincenty, "Closed formulas for the direct and reverse geodetic problems", Journal of Geodesy, 51, 3, 1977, DOI:10.1007/BF02521599, see http://www.springerlink.com/content/y7108u6862473583 for more.
[in] | lat1 | Decimal Latitude (const double&) |
[in] | lon1 | Decimal Longitude (const double&) |
[in] | lat2 | Decimal Latitude (const double&) |
[in] | lon2 | Decimal Longitude (const double&) |
[in] | alpha | average bearing (double&) |
|
static |
Vincenty Inverse calculation giving WGS84 (decimal Lat/Long) position given a start location (lat,lon) a distance and a bearing See T. Vincenty, "Closed formulas for the direct and reverse geodetic problems", Journal of Geodesy, 51, 3, 1977, DOI:10.1007/BF02521599, see http://www.springerlink.com/content/y7108u6862473583 for more.
[in] | lat_ref | Decimal Latitude (const double&) |
[in] | lon_ref | Decimal Longitude (const double&) |
[in] | distance | Distance in meters (const double&) |
[in] | bearing | bearing in degrees, 0 being north (const double&) |
[out] | lat | Decimal latitude of target point (double&) |
[out] | lon | Decimal longitude of target point (double&) |
|
static |
Coordinate conversion: from WGS84 Lat/Long to Swiss grid See http://geomatics.ladetto.ch/ch1903_wgs84_de.pdf for more.
[in] | lat_in | Decimal Latitude |
[in] | long_in | Decimal Longitude |
[out] | east_out | easting coordinate (Swiss system) |
[out] | north_out | northing coordinate (Swiss system) |
|
static |
Coordinate conversion: from WGS84 Lat/Long to proj4 parameters.
[in] | lat_in | Decimal Latitude |
[in] | long_in | Decimal Longitude |
[in] | coordparam | Extra parameters necessary for the conversion (such as UTM zone, etc) |
[out] | east_out | easting coordinate (target system) |
[out] | north_out | northing coordinate (target system) |
|
static |
Coordinate conversion: from WGS84 Lat/Long to Universal Polar Stereographic grid see J. Hager, J. Behensky, B. Drew, THE UNIVERSAL GRIDS: Universal Transverse Mercator (UTM) and Universal Polar Stereographic (UPS), 1989, Defense Mapping Agency, DMATM 8358.2. This is valid above latitudes 84N or above 80S.
[in] | lat_in | Decimal Latitude |
[in] | long_in | Decimal Longitude |
[in] | coordparam | UPS zone, either "N" or "S" |
[out] | east_out | easting coordinate (Swiss system) |
[out] | north_out | northing coordinate (Swiss system) |
|
static |
Coordinate conversion: from WGS84 Lat/Long to UTM grid See http://www.oc.nps.edu/oc2902w/maps/utmups.pdf for more.
[in] | lat_in | Decimal Latitude |
[in] | long_in | Decimal Longitude |
[in] | coordparam | UTM zone to convert to |
[out] | east_out | easting coordinate (Swiss system) |
[out] | north_out | northing coordinate (Swiss system) |