]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/formulas/inverse_karney.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / formulas / inverse_karney.cpp
1 // Boost.Geometry
2 // Unit Test
3
4 // Copyright (c) 2016-2021 Oracle and/or its affiliates.
5
6 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8
9 // Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan.
10
11 // Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program
12
13 // Use, modification and distribution is subject to the Boost Software License,
14 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16
17
18 #include <sstream>
19
20 #include "test_formula.hpp"
21 #include "inverse_cases.hpp"
22 #include "inverse_cases_antipodal.hpp"
23 #include "inverse_cases_small_angles.hpp"
24
25 #include <boost/geometry/formulas/karney_inverse.hpp>
26
27 #include <boost/geometry/srs/spheroid.hpp>
28
29 #include <boost/geometry/util/math.hpp>
30
31 void test_all(expected_results const& results)
32 {
33 double lon1d = results.p1.lon * bg::math::d2r<double>();
34 double lat1d = results.p1.lat * bg::math::d2r<double>();
35 double lon2d = results.p2.lon * bg::math::d2r<double>();
36 double lat2d = results.p2.lat * bg::math::d2r<double>();
37
38 // WGS84
39 bg::srs::spheroid<double> spheroid(6378137.0, 6356752.3142451793);
40
41 bg::formula::result_inverse<double> result_k;
42
43 typedef bg::formula::karney_inverse<double, true, true, true, true, true> ka_t;
44 result_k = ka_t::apply(lon1d, lat1d, lon2d, lat2d, spheroid);
45 result_k.azimuth *= bg::math::r2d<double>();
46 result_k.reverse_azimuth *= bg::math::r2d<double>();
47 check_inverse("karney", results, result_k, results.vincenty, results.reference, 0.0000001);
48 }
49
50 template <typename ExpectedResults>
51 void test_karney(ExpectedResults const& results)
52 {
53 double lon1d = results.p1.lon * bg::math::d2r<double>();
54 double lat1d = results.p1.lat * bg::math::d2r<double>();
55 double lon2d = results.p2.lon * bg::math::d2r<double>();
56 double lat2d = results.p2.lat * bg::math::d2r<double>();
57
58
59 // WGS84
60 bg::srs::spheroid<double> spheroid(6378137.0, 6356752.3142451793);
61
62 bg::formula::result_inverse<double> result;
63
64 typedef bg::formula::karney_inverse<double, true, true, true, true, true> ka_t;
65 result = ka_t::apply(lon1d, lat1d, lon2d, lat2d, spheroid);
66 result.azimuth *= bg::math::r2d<double>();
67 result.reverse_azimuth *= bg::math::r2d<double>();
68 check_inverse("karney", results, result, results.karney, results.karney, 0.0000001);
69 }
70
71 int test_main(int, char*[])
72 {
73 for (size_t i = 0; i < expected_size; ++i)
74 {
75 test_all(expected[i]);
76 }
77
78 for (size_t i = 0; i < expected_size_antipodal; ++i)
79 {
80 test_karney(expected_antipodal[i]);
81 }
82
83 for (size_t i = 0; i < expected_size_small_angles; ++i)
84 {
85 test_karney(expected_small_angles[i]);
86 }
87
88 return 0;
89 }