]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/perimeter/perimeter_sph.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / perimeter / perimeter_sph.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2016 Oracle and/or its affiliates.
5 // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #include <algorithms/test_perimeter.hpp>
12 #include <algorithms/perimeter/perimeter_polygon_cases.hpp>
13
14 #include <boost/geometry/geometries/geometries.hpp>
15 #include <boost/geometry/geometries/point_xy.hpp>
16
17 template <typename P>
18 void test_all_default() //test the default strategy
19 {
20 double const pi = boost::math::constants::pi<double>();
21
22 for (std::size_t i = 0; i <= 2; ++i)
23 {
24 test_geometry<bg::model::polygon<P> >(poly_data_sph[i], 2 * pi);
25 }
26
27 // Multipolygon
28 test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
29 (multipoly_data[0], 3 * pi);
30
31 // Geometries with length zero
32 test_geometry<P>("POINT(0 0)", 0);
33 test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,3 4,4 3)", 0);
34 }
35
36
37 template <typename P>
38 void test_all_haversine(double const mean_radius)
39 {
40 double const pi = boost::math::constants::pi<double>();
41 bg::strategy::distance::haversine<double> haversine_strategy(mean_radius);
42
43 for (std::size_t i = 0; i <= 2; ++i)
44 {
45 test_geometry<bg::model::polygon<P> >(poly_data_sph[i],
46 2 * pi * mean_radius,
47 haversine_strategy);
48 }
49
50 // Multipolygon
51 test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
52 (multipoly_data[0],
53 3 * pi * mean_radius,
54 haversine_strategy);
55
56 // Geometries with length zero
57 test_geometry<P>("POINT(0 0)", 0, haversine_strategy);
58 test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,3 4,4 3)",
59 0,
60 haversine_strategy);
61 }
62
63 int test_main(int, char* [])
64 {
65 //Earth radius estimation in Km
66 //(see https://en.wikipedia.org/wiki/Earth_radius)
67 double const mean_radius = 6371.0;
68
69 test_all_default<bg::model::d2::point_xy<int,
70 bg::cs::spherical_equatorial<bg::degree> > >();
71 test_all_default<bg::model::d2::point_xy<float,
72 bg::cs::spherical_equatorial<bg::degree> > >();
73 test_all_default<bg::model::d2::point_xy<double,
74 bg::cs::spherical_equatorial<bg::degree> > >();
75
76 test_all_haversine<bg::model::d2::point_xy<int,
77 bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
78 test_all_haversine<bg::model::d2::point_xy<float,
79 bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
80 test_all_haversine<bg::model::d2::point_xy<double,
81 bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
82
83 #if defined(HAVE_TTMATH)
84 test_all<bg::model::d2::point_xy<ttmath_big> >();
85 #endif
86
87 return 0;
88 }