examples/example-OSGB.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::OSGB class
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <exception>
6 #include <string>
7 #include <GeographicLib/OSGB.hpp>
8 #include <GeographicLib/DMS.hpp>
9 
10 using namespace std;
11 using namespace GeographicLib;
12 
13 int main() {
14  try {
15  {
16  // Sample forward calculation from
17  // A guide to coordinate systems in Great Britain
18  double
19  lat = DMS::Decode(52,39,27.2531),
20  lon = DMS::Decode( 1,43, 4.5177);
21  double x, y;
22  OSGB::Forward(lat, lon, x, y);
23  string gridref;
24  OSGB::GridReference(x, y, 2, gridref);
25  cout << fixed << setprecision(3)
26  << x << " " << y << " " << gridref << "\n";
27  }
28  {
29  // Sample reverse calculation
30  string gridref = "TG5113";
31  double x, y;
32  int prec;
33  OSGB::GridReference(gridref, x, y, prec);
34  double lat, lon;
35  OSGB::Reverse(x, y, lat, lon);
36  cout << fixed << setprecision(8)
37  << prec << " " << lat << " " << lon << "\n";
38  }
39  }
40  catch (const exception& e) {
41  cerr << "Caught exception: " << e.what() << "\n";
42  return 1;
43  }
44 }
Eigen::Forward
@ Forward
Definition: NumericalDiff.h:19
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
x
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
Definition: gnuplot_common_settings.hh:12
OSGB.hpp
Header for GeographicLib::OSGB class.
y
Scalar * y
Definition: level1_cplx_impl.h:124
std
Definition: BFloat16.h:88
main
int main()
Definition: examples/example-OSGB.cpp:13
lon
static const double lon
Definition: testGeographicLib.cpp:34
DMS.hpp
Header for GeographicLib::DMS class.
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:31