1 // Example of using the GeographicLib::Ellipsoid class
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <exception>
6 #include <GeographicLib/Ellipsoid.hpp>
7 
8 using namespace std;
9 using namespace GeographicLib;
10 
main()11 int main() {
12   try {
13     Ellipsoid wgs84(Constants::WGS84_a(), Constants::WGS84_f());
14     // Alternatively: const Ellipsoid& wgs84 = Ellipsoid::WGS84();
15     cout << "The latitude half way between the equator and the pole is "
16          << wgs84.InverseRectifyingLatitude(45) << "\n";
17     cout << "Half the area of the ellipsoid lies between latitudes +/- "
18          << wgs84.InverseAuthalicLatitude(30) << "\n";
19     cout << "The northernmost edge of a square Mercator map is at latitude "
20          << wgs84.InverseIsometricLatitude(180) << "\n";
21     cout << "Table phi(deg)  beta-phi xi-phi mu-phi chi-phi theta-phi (mins)\n"
22          << fixed << setprecision(2);
23     for (int i = 0; i <= 90; i += 15) {
24       double phi = i,
25         bet = wgs84.ParametricLatitude(phi),
26         xi = wgs84.AuthalicLatitude(phi),
27         mu = wgs84.RectifyingLatitude(phi),
28         chi = wgs84.ConformalLatitude(phi),
29         theta = wgs84.GeocentricLatitude(phi);
30       cout << i << " "
31            << (bet-phi)*60 << " "
32            << (xi-phi)*60 << " "
33            << (mu-phi)*60 << " "
34            << (chi-phi)*60 << " "
35            << (theta-phi)*60 << "\n";
36     }
37   }
38   catch (const exception& e) {
39     cerr << "Caught exception: " << e.what() << "\n";
40     return 1;
41   }
42 }
43