examples/example-GARS.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>
7 #include <GeographicLib/GARS.hpp>
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 gars;
18  for (int prec = 0; prec <= 2; ++prec) {
19  GARS::Forward(lat, lon, prec, gars);
20  cout << prec << " " << gars << "\n";
21  }
22  }
23  {
24  // Sample reverse calculation
25  string gars = "381NH45";
26  double lat, lon;
27  cout << fixed;
28  for (int len = 5; len <= int(gars.size()); ++len) {
29  int prec;
30  GARS::Reverse(gars.substr(0, len), lat, lon, prec);
31  cout << prec << " " << lat << " " << lon << "\n";
32  }
33  }
34  }
35  catch (const exception& e) {
36  cerr << "Caught exception: " << e.what() << "\n";
37  return 1;
38  }
39 }
return int(ret)+1
static const double lat
int main()
Definition: Half.h:150
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const double lon
Header for GeographicLib::GARS class.
size_t len(handle h)
Definition: pytypes.h:1514


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