]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/formulas/inverse.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / geometry / test / formulas / inverse.cpp
1 // Boost.Geometry
2 // Unit Test
3
4 // Copyright (c) 2016-2017 Oracle and/or its affiliates.
5
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11
12
13 #include <sstream>
14
15 #include "test_formula.hpp"
16 #include "inverse_cases.hpp"
17
18 #include <boost/geometry/formulas/vincenty_inverse.hpp>
19 #include <boost/geometry/formulas/thomas_inverse.hpp>
20 #include <boost/geometry/formulas/andoyer_inverse.hpp>
21
22 #include <boost/geometry/srs/spheroid.hpp>
23
24 void check_inverse(std::string const& name,
25 expected_results const& results,
26 bg::formula::result_inverse<double> const& result,
27 expected_result const& expected,
28 expected_result const& reference,
29 double reference_error)
30 {
31 std::stringstream ss;
32 ss << "(" << results.p1.lon << " " << results.p1.lat << ")->(" << results.p2.lon << " " << results.p2.lat << ")";
33
34 check_one(name + "_d " + ss.str(),
35 result.distance, expected.distance, reference.distance, reference_error);
36 check_one(name + "_a " + ss.str(),
37 result.azimuth, expected.azimuth, reference.azimuth, reference_error, true);
38 check_one(name + "_ra " + ss.str(),
39 result.reverse_azimuth, expected.reverse_azimuth, reference.reverse_azimuth, reference_error, true);
40 check_one(name + "_rl " + ss.str(),
41 result.reduced_length, expected.reduced_length, reference.reduced_length, reference_error);
42 check_one(name + "_gs " + ss.str(),
43 result.geodesic_scale, expected.geodesic_scale, reference.geodesic_scale, reference_error);
44 }
45
46 void test_all(expected_results const& results)
47 {
48 double const d2r = bg::math::d2r<double>();
49 double const r2d = bg::math::r2d<double>();
50
51 double lon1r = results.p1.lon * d2r;
52 double lat1r = results.p1.lat * d2r;
53 double lon2r = results.p2.lon * d2r;
54 double lat2r = results.p2.lat * d2r;
55
56 // WGS84
57 bg::srs::spheroid<double> spheroid(6378137.0, 6356752.3142451793);
58
59 bg::formula::result_inverse<double> result_v, result_t, result_a;
60
61 typedef bg::formula::vincenty_inverse<double, true, true, true, true, true> vi_t;
62 result_v = vi_t::apply(lon1r, lat1r, lon2r, lat2r, spheroid);
63 result_v.azimuth *= r2d;
64 result_v.reverse_azimuth *= r2d;
65 check_inverse("vincenty", results, result_v, results.vincenty, results.reference, 0.0000001);
66
67 typedef bg::formula::thomas_inverse<double, true, true, true, true, true> th_t;
68 result_t = th_t::apply(lon1r, lat1r, lon2r, lat2r, spheroid);
69 result_t.azimuth *= r2d;
70 result_t.reverse_azimuth *= r2d;
71 check_inverse("thomas", results, result_t, results.thomas, results.reference, 0.00001);
72
73 typedef bg::formula::andoyer_inverse<double, true, true, true, true, true> an_t;
74 result_a = an_t::apply(lon1r, lat1r, lon2r, lat2r, spheroid);
75 result_a.azimuth *= r2d;
76 result_a.reverse_azimuth *= r2d;
77 check_inverse("andoyer", results, result_a, results.andoyer, results.reference, 0.001);
78 }
79
80 int test_main(int, char*[])
81 {
82 for (size_t i = 0; i < expected_size; ++i)
83 {
84 test_all(expected[i]);
85 }
86
87 return 0;
88 }