]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/strategies/segment_intersection_geo.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / strategies / segment_intersection_geo.hpp
1 // Boost.Geometry
2 // Unit Test
3
4 // Copyright (c) 2016, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, 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 #ifndef BOOST_GEOMETRY_TEST_STRATEGIES_SEGMENT_INTERSECTION_GEO_HPP
12 #define BOOST_GEOMETRY_TEST_STRATEGIES_SEGMENT_INTERSECTION_GEO_HPP
13
14
15 #include "segment_intersection_sph.hpp"
16
17 #include <boost/geometry/strategies/geographic/intersection.hpp>
18 #include <boost/geometry/strategies/geographic/intersection_elliptic.hpp>
19
20
21 template <typename S, typename P>
22 void test_default_strategy(std::string const& s1_wkt, std::string const& s2_wkt,
23 char m, std::size_t expected_count,
24 std::string const& ip0_wkt = "", std::string const& ip1_wkt = "",
25 int opposite_id = -1)
26 {
27 typename bg::strategy::intersection::services::default_strategy
28 <
29 bg::geographic_tag
30 >::type strategy;
31
32 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
33 }
34
35 template <typename S, typename P>
36 void test_great_elliptic(std::string const& s1_wkt, std::string const& s2_wkt,
37 char m, std::size_t expected_count,
38 std::string const& ip0_wkt = "", std::string const& ip1_wkt = "",
39 int opposite_id = -1)
40 {
41 bg::strategy::intersection::great_elliptic_segments<> strategy;
42
43 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
44 }
45 /*
46 template <typename S, typename P>
47 void test_experimental_elliptic(std::string const& s1_wkt, std::string const& s2_wkt,
48 char m, std::size_t expected_count,
49 std::string const& ip0_wkt = "", std::string const& ip1_wkt = "",
50 int opposite_id = -1)
51 {
52 bg::strategy::intersection::experimental_elliptic_segments<> strategy;
53
54 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
55 }
56 */
57 template <typename S, typename P>
58 void test_geodesic_vincenty(std::string const& s1_wkt, std::string const& s2_wkt,
59 char m, std::size_t expected_count,
60 std::string const& ip0_wkt = "", std::string const& ip1_wkt = "",
61 int opposite_id = -1)
62 {
63 bg::strategy::intersection::geographic_segments<bg::strategy::vincenty, 4> strategy;
64
65 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
66 }
67
68 template <typename S, typename P>
69 void test_geodesic_thomas(std::string const& s1_wkt, std::string const& s2_wkt,
70 char m, std::size_t expected_count,
71 std::string const& ip0_wkt = "", std::string const& ip1_wkt = "",
72 int opposite_id = -1)
73 {
74 bg::strategy::intersection::geographic_segments<bg::strategy::thomas, 2> strategy;
75
76 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
77 }
78
79 template <typename S, typename P>
80 void test_geodesic_andoyer(std::string const& s1_wkt, std::string const& s2_wkt,
81 char m, std::size_t expected_count,
82 std::string const& ip0_wkt = "", std::string const& ip1_wkt = "",
83 int opposite_id = -1)
84 {
85 bg::strategy::intersection::geographic_segments<bg::strategy::andoyer, 1> strategy;
86
87 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
88 }
89
90
91 struct strategy_base
92 {
93 strategy_base(char m_)
94 : m(m_), expected_count(0), opposite(-1)
95 {}
96 strategy_base(char m_, std::string const& wkt1_)
97 : m(m_), expected_count(1), wkt1(wkt1_), opposite(-1)
98 {}
99 strategy_base(char m_, std::string const& wkt1_, std::string const& wkt2_, bool opposite_)
100 : m(m_), expected_count(1), wkt1(wkt1_), opposite(opposite_ ? 1 : 0)
101 {}
102
103 char m;
104 std::size_t expected_count;
105 std::string wkt1, wkt2;
106 int opposite;
107 };
108 struct strategy_default : strategy_base
109 {
110 strategy_default(char m)
111 : strategy_base(m)
112 {}
113 strategy_default(char m, std::string const& wkt1)
114 : strategy_base(m, wkt1)
115 {}
116 strategy_default(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
117 : strategy_base(m, wkt1, wkt2, opposite)
118 {}
119 };
120 struct geodesic_vincenty : strategy_base
121 {
122 geodesic_vincenty(char m)
123 : strategy_base(m)
124 {}
125 geodesic_vincenty(char m, std::string const& wkt1)
126 : strategy_base(m, wkt1)
127 {}
128 geodesic_vincenty(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
129 : strategy_base(m, wkt1, wkt2, opposite)
130 {}
131 };
132 struct geodesic_thomas : strategy_base
133 {
134 geodesic_thomas(char m)
135 : strategy_base(m)
136 {}
137 geodesic_thomas(char m, std::string const& wkt1)
138 : strategy_base(m, wkt1)
139 {}
140 geodesic_thomas(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
141 : strategy_base(m, wkt1, wkt2, opposite)
142 {}
143 };
144 struct geodesic_andoyer : strategy_base
145 {
146 geodesic_andoyer(char m)
147 : strategy_base(m)
148 {}
149 geodesic_andoyer(char m, std::string const& wkt1)
150 : strategy_base(m, wkt1)
151 {}
152 geodesic_andoyer(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
153 : strategy_base(m, wkt1, wkt2, opposite)
154 {}
155 };
156 struct great_elliptic : strategy_base
157 {
158 great_elliptic(char m)
159 : strategy_base(m)
160 {}
161 great_elliptic(char m, std::string const& wkt1)
162 : strategy_base(m, wkt1)
163 {}
164 great_elliptic(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
165 : strategy_base(m, wkt1, wkt2, opposite)
166 {}
167 };
168
169
170 template <typename S, typename P>
171 void test_strategy(std::string const& s1_wkt, std::string const& s2_wkt,
172 strategy_default const& s)
173 {
174 test_default_strategy<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
175 }
176
177 template <typename S, typename P>
178 void test_strategy(std::string const& s1_wkt, std::string const& s2_wkt,
179 great_elliptic const& s)
180 {
181 test_great_elliptic<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
182 }
183
184 template <typename S, typename P>
185 void test_strategy(std::string const& s1_wkt, std::string const& s2_wkt,
186 geodesic_vincenty const& s)
187 {
188 test_geodesic_vincenty<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
189 }
190
191 template <typename S, typename P>
192 void test_strategy(std::string const& s1_wkt, std::string const& s2_wkt,
193 geodesic_thomas const& s)
194 {
195 test_geodesic_thomas<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
196 }
197
198 template <typename S, typename P>
199 void test_strategy(std::string const& s1_wkt, std::string const& s2_wkt,
200 geodesic_andoyer const& s)
201 {
202 test_geodesic_andoyer<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
203 }
204
205
206 template <typename S, typename P, typename SR1>
207 void test_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
208 SR1 const& sr1)
209 {
210 test_strategy<S, P>(s1_wkt, s2_wkt, sr1);
211 }
212 template <typename S, typename P, typename SR1, typename SR2>
213 void test_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
214 SR1 const& sr1, SR2 const& sr2)
215 {
216 test_strategy<S, P>(s1_wkt, s2_wkt, sr1);
217 test_strategy<S, P>(s1_wkt, s2_wkt, sr2);
218 }
219 template <typename S, typename P, typename SR1, typename SR2, typename SR3>
220 void test_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
221 SR1 const& sr1, SR2 const& sr2, SR3 const& sr3)
222 {
223 test_strategy<S, P>(s1_wkt, s2_wkt, sr1);
224 test_strategy<S, P>(s1_wkt, s2_wkt, sr2);
225 test_strategy<S, P>(s1_wkt, s2_wkt, sr3);
226 }
227 template <typename S, typename P, typename SR1, typename SR2, typename SR3, typename SR4>
228 void test_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
229 SR1 const& sr1, SR2 const& sr2, SR3 const& sr3, SR4 const& sr4)
230 {
231 test_strategy<S, P>(s1_wkt, s2_wkt, sr1);
232 test_strategy<S, P>(s1_wkt, s2_wkt, sr2);
233 test_strategy<S, P>(s1_wkt, s2_wkt, sr3);
234 test_strategy<S, P>(s1_wkt, s2_wkt, sr4);
235 }
236
237
238 template <typename S, typename P>
239 void test_all_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
240 char m, std::string const& ip0_wkt = "")
241 {
242 std::size_t expected_count = ip0_wkt.empty() ? 0 : 1;
243
244 test_default_strategy<S, P>(s1_wkt, s2_wkt, m, expected_count, ip0_wkt);
245 test_great_elliptic<S, P>(s1_wkt, s2_wkt, m, expected_count, ip0_wkt);
246 //test_experimental_elliptic<S, P>(s1_wkt, s2_wkt, m, expected_count, ip0_wkt);
247 test_geodesic_vincenty<S, P>(s1_wkt, s2_wkt, m, expected_count, ip0_wkt);
248 test_geodesic_thomas<S, P>(s1_wkt, s2_wkt, m, expected_count, ip0_wkt);
249 test_geodesic_andoyer<S, P>(s1_wkt, s2_wkt, m, expected_count, ip0_wkt);
250 }
251
252 template <typename S, typename P>
253 void test_all_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
254 char m,
255 std::string const& ip0_wkt, std::string const& ip1_wkt,
256 bool opposite)
257 {
258 int opposite_id = opposite ? 1 : 0;
259
260 test_default_strategy<S, P>(s1_wkt, s2_wkt, m, 2, ip0_wkt, ip1_wkt, opposite_id);
261 test_great_elliptic<S, P>(s1_wkt, s2_wkt, m, 2, ip0_wkt, ip1_wkt, opposite_id);
262 //test_experimental_elliptic<S, P>(s1_wkt, s2_wkt, m, 2, ip0_wkt, ip1_wkt, opposite_id);
263 test_geodesic_vincenty<S, P>(s1_wkt, s2_wkt, m, 2, ip0_wkt, ip1_wkt, opposite_id);
264 test_geodesic_thomas<S, P>(s1_wkt, s2_wkt, m, 2, ip0_wkt, ip1_wkt, opposite_id);
265 test_geodesic_andoyer<S, P>(s1_wkt, s2_wkt, m, 2, ip0_wkt, ip1_wkt, opposite_id);
266 }
267
268 #endif // BOOST_GEOMETRY_TEST_STRATEGIES_SEGMENT_INTERSECTION_GEO_HPP