]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/length/length_sph.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / length / length_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_length.hpp>
12 #include <algorithms/length/linestring_cases.hpp>
13
14 #include <boost/geometry/geometries/geometries.hpp>
15 #include <boost/geometry/geometries/point_xy.hpp>
16 #include <boost/geometry/geometries/adapted/std_pair_as_segment.hpp>
17
18 #include <test_geometries/all_custom_linestring.hpp>
19 #include <test_geometries/wrapped_boost_array.hpp>
20
21 template <typename P>
22 void test_all_default() //test the default strategy
23 {
24 double const pi = boost::math::constants::pi<double>();
25
26 for(std::size_t i = 0; i < 2; ++i)
27 {
28 test_geometry<bg::model::linestring<P> >(Ls_data_sph[i], 2 * pi);
29 }
30 // Geometries with length zero
31 test_geometry<P>("POINT(0 0)", 0);
32 test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0);
33 }
34
35 template <typename P>
36 void test_all_haversine(double const mean_radius)
37 {
38 double const pi = boost::math::constants::pi<double>();
39 bg::strategy::distance::haversine<float> haversine_strategy(mean_radius);
40
41 for(std::size_t i = 0; i < 2; ++i)
42 {
43 test_geometry<bg::model::linestring<P> >(Ls_data_sph[i],
44 2 * pi * mean_radius,
45 haversine_strategy);
46 }
47 // Geometries with length zero
48 test_geometry<P>("POINT(0 0)", 0, haversine_strategy);
49 test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))",
50 0, haversine_strategy);
51 }
52
53 template <typename P>
54 void test_empty_input()
55 {
56 test_empty_input(bg::model::linestring<P>());
57 test_empty_input(bg::model::multi_linestring<P>());
58 }
59
60 int test_main(int, char* [])
61 {
62 //Earth radius estimation in Km
63 //(see https://en.wikipedia.org/wiki/Earth_radius)
64 double const mean_radius = 6371.0;
65
66 test_all_default<bg::model::d2::point_xy<int,
67 bg::cs::spherical_equatorial<bg::degree> > >();
68 test_all_default<bg::model::d2::point_xy<float,
69 bg::cs::spherical_equatorial<bg::degree> > >();
70 test_all_default<bg::model::d2::point_xy<double,
71 bg::cs::spherical_equatorial<bg::degree> > >();
72
73 test_all_haversine<bg::model::d2::point_xy<int,
74 bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
75 test_all_haversine<bg::model::d2::point_xy<float,
76 bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
77 test_all_haversine<bg::model::d2::point_xy<double,
78 bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
79
80 #if defined(HAVE_TTMATH)
81 test_all<bg::model::d2::point_xy<ttmath_big> >();
82 #endif
83
84 //test_empty_input<bg::model::d2::point_xy<int> >();
85
86 return 0;
87 }