4 // Copyright (c) 2016-2021 Oracle and/or its affiliates.
6 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9 // Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan.
11 // Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program
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)
20 #include "test_formula.hpp"
21 #include "inverse_cases.hpp"
22 #include "inverse_cases_antipodal.hpp"
23 #include "inverse_cases_small_angles.hpp"
25 #include <boost/geometry/formulas/karney_inverse.hpp>
27 #include <boost/geometry/srs/spheroid.hpp>
29 #include <boost/geometry/util/math.hpp>
31 void test_all(expected_results
const& results
)
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>();
39 bg::srs::spheroid
<double> spheroid(6378137.0, 6356752.3142451793);
41 bg::formula::result_inverse
<double> result_k
;
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);
50 template <typename ExpectedResults
>
51 void test_karney(ExpectedResults
const& results
)
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>();
60 bg::srs::spheroid
<double> spheroid(6378137.0, 6356752.3142451793);
62 bg::formula::result_inverse
<double> result
;
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);
71 int test_main(int, char*[])
73 for (size_t i
= 0; i
< expected_size
; ++i
)
75 test_all(expected
[i
]);
78 for (size_t i
= 0; i
< expected_size_antipodal
; ++i
)
80 test_karney(expected_antipodal
[i
]);
83 for (size_t i
= 0; i
< expected_size_small_angles
; ++i
)
85 test_karney(expected_small_angles
[i
]);