File: example-AuxLatitude.cpp

package info (click to toggle)
geographiclib 2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,572 kB
  • sloc: cpp: 27,765; sh: 5,463; makefile: 695; python: 12; ansic: 10
file content (43 lines) | stat: -rw-r--r-- 1,482 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Example of using the GeographicLib::AuxLatitude class.  See the paper
//
// - C. F. F. Karney,
//   On auxiliary latitudes,
//   Survey Review 56(395), 165--180 (2024).
//   https://doi.org/10.1080/00396265.2023.2217604
//   preprint: https://arxiv.org/abs/2212.05818

#include <iostream>
#include <iomanip>
#include <exception>
#include <GeographicLib/Utility.hpp>
#include <GeographicLib/AuxLatitude.hpp>

int main(int argc, const char* const argv[]) {
  try {
    using latitude = GeographicLib::AuxLatitude;
    using angle = GeographicLib::AuxAngle;
    if (argc != 3) {
      std::cerr << "Usage: example-AuxLatitude <n> <base-lat>\n";
      return 1;
    }
    double n = GeographicLib::Utility::fract<double>(std::string(argv[1]));
    int auxin = GeographicLib::Utility::val<int>(std::string(argv[2]));
    double a = 1+n, b = 1-n;    // Equatorial radius and polar semiaxis
    latitude aux(latitude::axes(a, b));
    bool exact = true;          // Do the exact calculation
    std::cout << std::setprecision(9) << std::fixed;
    int m = 1;
    for (int l = 0; l < 90*m; ++l) {
      angle phi(angle::degrees((l+0.5)/m));
      for (int auxout = 0; auxout < latitude::AUXNUMBER; ++auxout) {
        angle eta = aux.Convert(auxin, auxout, phi, exact);
        std::cout << (auxout ? " " : "") << eta.degrees();
      }
      std::cout << "\n";
    }
  }
  catch (const std::exception& e) {
    std::cerr << "Caught exception: " << e.what() << "\n";
    return 1;
  }
}