]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/azimuth.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / azimuth.cpp
1 // Boost.Geometry
2 // Unit Test
3
4 // Copyright (c) 2021, Oracle and/or its affiliates.
5
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10
11
12 #include <geometry_test_common.hpp>
13
14 #include <boost/geometry/geometries/geometries.hpp>
15
16 #include <boost/geometry/algorithms/azimuth.hpp>
17
18
19 template <typename P, typename S>
20 auto call_azimuth(P const& p1, P const& p2, S const& s)
21 {
22 return bg::azimuth(p1, p2, s);
23 }
24
25 template <typename P>
26 auto call_azimuth(P const& p1, P const& p2, bg::default_strategy const&)
27 {
28 return bg::azimuth(p1, p2);
29 }
30
31 template <typename P, typename S = bg::default_strategy>
32 void test_one(P const& p1, P const& p2, double expected, S const& s = S())
33 {
34 double const result = call_azimuth(p1, p2, s) * bg::math::r2d<double>();
35 BOOST_CHECK_CLOSE(result, expected, 0.0001);
36 }
37
38 template <typename P>
39 void test_car()
40 {
41 test_one(P(0, 0), P(0, 0), 0);
42 test_one(P(0, 0), P(1, 1), 45);
43 test_one(P(0, 0), P(100, 1), 89.427061302316517);
44 test_one(P(0, 0), P(-1, 1), -45);
45 test_one(P(0, 0), P(-100, 1), -89.427061302316517);
46 }
47
48 template <typename P>
49 void test_sph()
50 {
51 test_one(P(0, 0), P(0, 0), 0);
52 test_one(P(0, 0), P(1, 1), 44.995636455344851);
53 test_one(P(0, 0), P(100, 1), 88.984576593576293);
54 test_one(P(0, 0), P(-1, 1), -44.995636455344851);
55 test_one(P(0, 0), P(-100, 1), -88.984576593576293);
56 }
57
58 template <typename P>
59 void test_geo()
60 {
61 test_one(P(0, 0), P(0, 0), 0);
62 test_one(P(0, 0), P(1, 1), 45.187718848049521);
63 test_one(P(0, 0), P(100, 1), 88.986933066023497);
64 test_one(P(0, 0), P(-1, 1), -45.187718848049521);
65 test_one(P(0, 0), P(-100, 1), -88.986933066023497);
66 }
67
68 template <typename P>
69 void test_geo_v()
70 {
71 bg::strategies::azimuth::geographic<bg::strategy::vincenty> s;
72
73 test_one(P(0, 0), P(0, 0), 0, s);
74 test_one(P(0, 0), P(1, 1), 45.188040229339755, s);
75 test_one(P(0, 0), P(100, 1), 88.986914518230208, s);
76 test_one(P(0, 0), P(-1, 1), -45.188040229339755, s);
77 test_one(P(0, 0), P(-100, 1), -88.986914518230208, s);
78 }
79
80 int test_main(int, char* [])
81 {
82 test_car< bg::model::point<double, 2, bg::cs::cartesian> >();
83 test_sph< bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
84 test_geo< bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
85 test_geo_v< bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
86
87 return 0;
88 }