examples/example-MGRS.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::MGRS class
2 
3 #include <iostream>
4 #include <exception>
5 #include <string>
7 #include <GeographicLib/MGRS.hpp>
8 
9 using namespace std;
10 using namespace GeographicLib;
11 
12 int main() {
13  try {
14  // See also example-GeoCoords.cpp
15  {
16  // Sample forward calculation
17  double lat = 33.3, lon = 44.4; // Baghdad
18  int zone;
19  bool northp;
20  double x, y;
21  UTMUPS::Forward(lat, lon, zone, northp, x, y);
22  string mgrs;
23  MGRS::Forward(zone, northp, x, y, lat, 5, mgrs);
24  cout << mgrs << "\n";
25  }
26  {
27  // Sample reverse calculation
28  string mgrs = "38SMB4488";
29  int zone, prec;
30  bool northp;
31  double x, y;
32  MGRS::Reverse(mgrs, zone, northp, x, y, prec);
33  double lat, lon;
34  UTMUPS::Reverse(zone, northp, x, y, lat, lon);
35  cout << prec << " " << lat << " " << lon << "\n";
36  }
37  }
38  catch (const exception& e) {
39  cerr << "Caught exception: " << e.what() << "\n";
40  return 1;
41  }
42 }
Scalar * y
static const double lat
Header for GeographicLib::UTMUPS class.
Definition: BFloat16.h:88
Header for GeographicLib::MGRS class.
int main()
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const double lon
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:13