Conversions for the Global Area Reference System (GARS)
The Global Area Reference System is described in
It provides a compact string representation of a geographic area (expressed as latitude and longitude). The classes Georef and Geohash implement similar compact representations.
Example of use:
#include <iostream>
#include <iomanip>
#include <exception>
#include <string>
try {
{
double lat = 57.64911,
lon = 10.40744;
string gars;
for (int prec = 0; prec <= 2; ++prec) {
cout << prec << " " << gars << "\n";
}
}
{
string gars = "381NH45";
cout << fixed;
int prec;
cout << prec << " " << lat << " " << lon << "\n";
}
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
Definition at line 38 of file GARS.hpp.
void GeographicLib::GARS::Reverse |
( |
const std::string & |
gars, |
|
|
real & |
lat, |
|
|
real & |
lon, |
|
|
int & |
prec, |
|
|
bool |
centerp = true |
|
) |
| |
|
static |
Convert from GARS to geographic coordinates.
- Parameters
-
[in] | gars | the GARS. |
[out] | lat | latitude of point (degrees). |
[out] | lon | longitude of point (degrees). |
[out] | prec | the precision of gars. |
[in] | centerp | if true (the default) return the center of the gars, otherwise return the south-west corner. |
- Exceptions
-
The case of the letters in gars is ignored. prec is in the range [0, 2] and gives the precision of gars as follows:
- prec = 0 (min), 30' precision, e.g., 006AG;
- prec = 1, 15' precision, e.g., 006AG3;
- prec = 2 (max), 5' precision, e.g., 006AG39.
If the first 3 characters of gars are "INV", then lat and lon are set to NaN and prec is unchanged.
Definition at line 57 of file src/GARS.cpp.