]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/perimeter/perimeter_geo.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / perimeter / perimeter_geo.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
b32b8144 4// Copyright (c) 2016-2017 Oracle and/or its affiliates.
7c673cae
FG
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
17template <typename P>
18struct geo_strategies
19{
20 // Set radius type, but for integer coordinates we want to have floating
21 // point radius type
22 typedef typename bg::promote_floating_point
23 <
24 typename bg::coordinate_type<P>::type
25 >::type rtype;
26
27 typedef bg::srs::spheroid<rtype> stype;
28 typedef bg::strategy::distance::andoyer<stype> andoyer_type;
29 typedef bg::strategy::distance::thomas<stype> thomas_type;
30 typedef bg::strategy::distance::vincenty<stype> vincenty_type;
31};
32
33template <typename P>
34void test_default() //this should use andoyer strategy
35{
36 for (std::size_t i = 0; i <= 2; ++i)
37 {
38 test_geometry<bg::model::polygon<P> >(poly_data_geo[i],
39 1116814.237 + 1116152.605);
40 }
41
b32b8144
FG
42 //since the geodesic distance is the shortest path it should go over the pole
43 //in this case; thus the correct perimeter is the meridian length (below)
44 //and not 40075160 which is the legth of the equator
45 test_geometry<bg::model::polygon<P> >(poly_data_geo[3],
46 40007834.7139);
47
48 //force to use equator path
49 test_geometry<bg::model::polygon<P> >(poly_data_geo[4],
50 40075016.6856);
51
7c673cae
FG
52 // Multipolygon
53 test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
b32b8144 54 (multipoly_data[0], 60011752.0709);
7c673cae
FG
55
56 // Geometries with length zero
57 test_geometry<P>("POINT(0 0)", 0);
58 test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,0 1,1 1,1 0,0 0)",
59 0);
60}
61
62template <typename P, typename N, typename Strategy>
63void test_with_strategy(N exp_length, Strategy strategy)
64{
65 for (std::size_t i = 0; i <= 2; ++i)
66 {
67 test_geometry<bg::model::polygon<P> >(poly_data_geo[i],
68 exp_length,
69 strategy);
70 }
71 // Geometries with length zero
72 test_geometry<P>("POINT(0 0)", 0, strategy);
73 test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,0 1,1 1,1 0,0 0)",
74 0,
75 strategy);
76}
77
78template <typename P>
79void test_andoyer()
80{
81 typename geo_strategies<P>::andoyer_type andoyer;
82 test_with_strategy<P>(1116814.237 + 1116152.605, andoyer);
83}
84
85template <typename P>
86void test_thomas()
87{
88 typename geo_strategies<P>::thomas_type thomas;
89 test_with_strategy<P>(1116825.795 + 1116158.7417, thomas);
90}
91
92template <typename P>
93void test_vincenty()
94{
95 typename geo_strategies<P>::vincenty_type vincenty;
b32b8144 96 test_with_strategy<P>(1116825.857 + 1116159.144, vincenty);
7c673cae
FG
97}
98
99template <typename P>
100void test_all()
101{
102 test_default<P>();
103 test_andoyer<P>();
104 test_thomas<P>();
105 test_vincenty<P>();
106}
107
108int test_main(int, char* [])
109{
110 // Works only for double(?!)
111 //test_all<bg::model::d2::point_xy<int,
112 // bg::cs::geographic<bg::degree> > >();
113 //test_all<bg::model::d2::point_xy<float,
114 // bg::cs::geographic<bg::degree> > >();
115 test_all<bg::model::d2::point_xy<double,
116 bg::cs::geographic<bg::degree> > >();
117
118#if defined(HAVE_TTMATH)
119 test_all<bg::model::d2::point_xy<ttmath_big> >();
120#endif
121
122 return 0;
123}
124