]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/length/length_sph.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2016 Oracle and/or its affiliates.
5 // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
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)
11 #include <algorithms/test_length.hpp>
12 #include <algorithms/length/linestring_cases.hpp>
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>
18 #include <test_geometries/all_custom_linestring.hpp>
19 #include <test_geometries/wrapped_boost_array.hpp>
22 void test_all_default() //test the default strategy
24 double const pi
= boost::math::constants::pi
<double>();
26 for(std::size_t i
= 0; i
< 2; ++i
)
28 test_geometry
<bg::model::linestring
<P
> >(Ls_data_sph
[i
], 2 * pi
);
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);
36 void test_all_haversine(double const mean_radius
)
38 double const pi
= boost::math::constants::pi
<double>();
39 bg::strategy::distance::haversine
<float> haversine_strategy(mean_radius
);
41 for(std::size_t i
= 0; i
< 2; ++i
)
43 test_geometry
<bg::model::linestring
<P
> >(Ls_data_sph
[i
],
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
);
54 void test_empty_input()
56 test_empty_input(bg::model::linestring
<P
>());
57 test_empty_input(bg::model::multi_linestring
<P
>());
60 int test_main(int, char* [])
62 //Earth radius estimation in Km
63 //(see https://en.wikipedia.org/wiki/Earth_radius)
64 double const mean_radius
= 6371.0;
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
> > >();
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
);
80 //test_empty_input<bg::model::d2::point_xy<int> >();