Static Public Member Functions | Private Types | Private Member Functions | Static Private Attributes | List of all members
GeographicLib::Georef Class Reference

Conversions for the World Geographic Reference System (georef) More...

#include <Georef.hpp>

Static Public Member Functions

static void Forward (real lat, real lon, int prec, std::string &georef)
 
static int Precision (real res)
 
static Math::real Resolution (int prec)
 
static void Reverse (const std::string &georef, real &lat, real &lon, int &prec, bool centerp=true)
 

Private Types

enum  {
  tile_ = 15, lonorig_ = -180, latorig_ = -90, base_ = 10,
  baselen_ = 4, maxprec_ = 11, maxlen_ = baselen_ + 2 * maxprec_
}
 
typedef Math::real real
 

Private Member Functions

 Georef ()
 

Static Private Attributes

static const char *const degrees_ = "ABCDEFGHJKLMNPQ"
 
static const char *const digits_ = "0123456789"
 
static const char *const lattile_ = "ABCDEFGHJKLM"
 
static const char *const lontile_ = "ABCDEFGHJKLMNPQRSTUVWXYZ"
 

Detailed Description

Conversions for the World Geographic Reference System (georef)

The World Geographic Reference System is described in

It provides a compact string representation of a geographic area (expressed as latitude and longitude). The classes GARS and Geohash implement similar compact representations.

Example of use:

// Example of using the GeographicLib::GARS class
#include <iostream>
#include <iomanip>
#include <exception>
#include <string>
using namespace std;
using namespace GeographicLib;
int main() {
try {
{
// Sample forward calculation
double lat = 57.64911, lon = 10.40744; // Jutland
string georef;
for (int prec = -1; prec <= 11; ++prec) {
Georef::Forward(lat, lon, prec, georef);
cout << prec << " " << georef << "\n";
}
}
{
// Sample reverse calculation
string georef = "NKLN2444638946";
double lat, lon;
int prec;
cout << fixed;
Georef::Reverse(georef.substr(0, 2), lat, lon, prec);
cout << prec << " " << lat << " " << lon << "\n";
Georef::Reverse(georef.substr(0, 4), lat, lon, prec);
cout << prec << " " << lat << " " << lon << "\n";
Georef::Reverse(georef, lat, lon, prec);
cout << prec << " " << lat << " " << lon << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

Definition at line 38 of file Georef.hpp.

Member Typedef Documentation

◆ real

Definition at line 40 of file Georef.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
tile_ 
lonorig_ 
latorig_ 
base_ 
baselen_ 
maxprec_ 
maxlen_ 

Definition at line 45 of file Georef.hpp.

Constructor & Destructor Documentation

◆ Georef()

GeographicLib::Georef::Georef ( )
private

Member Function Documentation

◆ Forward()

void GeographicLib::Georef::Forward ( real  lat,
real  lon,
int  prec,
std::string &  georef 
)
static

Convert from geographic coordinates to georef.

Parameters
[in]latlatitude of point (degrees).
[in]lonlongitude of point (degrees).
[in]precthe precision of the resulting georef.
[out]georefthe georef string.
Exceptions
GeographicErrif lat is not in [−90°, 90°].
std::bad_allocif memory for georef can't be allocated.

prec specifies the precision of georef as follows:

  • prec = −1 (min), 15°
  • prec = 0, 1°
  • prec = 1, converted to prec = 2
  • prec = 2, 1'
  • prec = 3, 0.1'
  • prec = 4, 0.01'
  • prec = 5, 0.001'
  • prec = 11 (max), 10−9'

If lat or lon is NaN, then georef is set to "INVALID".

Definition at line 22 of file src/Georef.cpp.

◆ Precision()

static int GeographicLib::Georef::Precision ( real  res)
inlinestatic

The Georef precision required to meet a given geographic resolution.

Parameters
[in]resthe minimum of resolution in latitude and longitude (degrees).
Returns
Georef precision.

The returned length is in the range [0, 11].

Definition at line 142 of file Georef.hpp.

◆ Resolution()

static Math::real GeographicLib::Georef::Resolution ( int  prec)
inlinestatic

The angular resolution of a Georef.

Parameters
[in]precthe precision of the Georef.
Returns
the latitude-longitude resolution (degrees).

Internally, prec is first put in the range [−1, 11].

Definition at line 121 of file Georef.hpp.

◆ Reverse()

void GeographicLib::Georef::Reverse ( const std::string &  georef,
real lat,
real lon,
int prec,
bool  centerp = true 
)
static

Convert from Georef to geographic coordinates.

Parameters
[in]georefthe Georef.
[out]latlatitude of point (degrees).
[out]lonlongitude of point (degrees).
[out]precthe precision of georef.
[in]centerpif true (the default) return the center georef, otherwise return the south-west corner.
Exceptions
GeographicErrif georef is illegal.

The case of the letters in georef is ignored. prec is in the range [−1, 11] and gives the precision of georef as follows:

  • prec = −1 (min), 15°
  • prec = 0, 1°
  • prec = 1, not returned
  • prec = 2, 1'
  • prec = 3, 0.1'
  • prec = 4, 0.01'
  • prec = 5, 0.001'
  • prec = 11 (max), 10−9'

If the first 3 characters of georef are "INV", then lat and lon are set to NaN and prec is unchanged.

Definition at line 63 of file src/Georef.cpp.

Member Data Documentation

◆ degrees_

const char *const GeographicLib::Georef::degrees_ = "ABCDEFGHJKLMNPQ"
staticprivate

Definition at line 44 of file Georef.hpp.

◆ digits_

const char *const GeographicLib::Georef::digits_ = "0123456789"
staticprivate

Definition at line 41 of file Georef.hpp.

◆ lattile_

const char *const GeographicLib::Georef::lattile_ = "ABCDEFGHJKLM"
staticprivate

Definition at line 43 of file Georef.hpp.

◆ lontile_

const char *const GeographicLib::Georef::lontile_ = "ABCDEFGHJKLMNPQRSTUVWXYZ"
staticprivate

Definition at line 42 of file Georef.hpp.


The documentation for this class was generated from the following files:
Georef.hpp
Header for GeographicLib::Georef class.
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
GeographicLib::Georef::Forward
static void Forward(real lat, real lon, int prec, std::string &georef)
Definition: src/Georef.cpp:22
GeographicLib::Georef::Reverse
static void Reverse(const std::string &georef, real &lat, real &lon, int &prec, bool centerp=true)
Definition: src/Georef.cpp:63
std
Definition: BFloat16.h:88
lon
static const double lon
Definition: testGeographicLib.cpp:34
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:23:28