examples/example-Georef.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::GARS class
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <exception>
6 #include <string>
8 
9 using namespace std;
10 using namespace GeographicLib;
11 
12 int main() {
13  try {
14  {
15  // Sample forward calculation
16  double lat = 57.64911, lon = 10.40744; // Jutland
17  string georef;
18  for (int prec = -1; prec <= 11; ++prec) {
19  Georef::Forward(lat, lon, prec, georef);
20  cout << prec << " " << georef << "\n";
21  }
22  }
23  {
24  // Sample reverse calculation
25  string georef = "NKLN2444638946";
26  double lat, lon;
27  int prec;
28  cout << fixed;
29  Georef::Reverse(georef.substr(0, 2), lat, lon, prec);
30  cout << prec << " " << lat << " " << lon << "\n";
31  Georef::Reverse(georef.substr(0, 4), lat, lon, prec);
32  cout << prec << " " << lat << " " << lon << "\n";
33  Georef::Reverse(georef, lat, lon, prec);
34  cout << prec << " " << lat << " " << lon << "\n";
35  }
36  }
37  catch (const exception& e) {
38  cerr << "Caught exception: " << e.what() << "\n";
39  return 1;
40  }
41 }
Header for GeographicLib::Georef class.
static const double lat
Definition: Half.h:150
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const double lon


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:02