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 }
Scalar * y
static const double lat
Definition: BFloat16.h:88
Header for GeographicLib::OSGB class.
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const double lon
int main()
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
Header for GeographicLib::DMS class.


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