4 // Copyright (c) 2016, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, 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 #ifndef BOOST_GEOMETRY_TEST_STRATEGIES_SEGMENT_INTERSECTION_GEO_HPP
12 #define BOOST_GEOMETRY_TEST_STRATEGIES_SEGMENT_INTERSECTION_GEO_HPP
15 #include "segment_intersection_sph.hpp"
17 #include <boost/geometry/strategies/geographic/intersection.hpp>
18 #include <boost/geometry/strategies/geographic/intersection_elliptic.hpp>
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 = "",
27 typename bg::strategy::intersection::services::default_strategy
32 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
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 = "",
41 bg::strategy::intersection::great_elliptic_segments<> strategy;
43 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
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 = "",
52 bg::strategy::intersection::experimental_elliptic_segments<> strategy;
54 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
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 = "",
63 bg::strategy::intersection::geographic_segments<bg::strategy::vincenty, 4> strategy;
65 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
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 = "",
74 bg::strategy::intersection::geographic_segments<bg::strategy::thomas, 2> strategy;
76 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
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 = "",
85 bg::strategy::intersection::geographic_segments<bg::strategy::andoyer, 1> strategy;
87 test_strategy<S, S, P>(s1_wkt, s2_wkt, strategy, m, expected_count, ip0_wkt, ip1_wkt, opposite_id);
93 strategy_base(char m_)
94 : m(m_), expected_count(0), opposite(-1)
96 strategy_base(char m_, std::string const& wkt1_)
97 : m(m_), expected_count(1), wkt1(wkt1_), opposite(-1)
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)
104 std::size_t expected_count;
105 std::string wkt1, wkt2;
108 struct strategy_default : strategy_base
110 strategy_default(char m)
113 strategy_default(char m, std::string const& wkt1)
114 : strategy_base(m, wkt1)
116 strategy_default(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
117 : strategy_base(m, wkt1, wkt2, opposite)
120 struct geodesic_vincenty : strategy_base
122 geodesic_vincenty(char m)
125 geodesic_vincenty(char m, std::string const& wkt1)
126 : strategy_base(m, wkt1)
128 geodesic_vincenty(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
129 : strategy_base(m, wkt1, wkt2, opposite)
132 struct geodesic_thomas : strategy_base
134 geodesic_thomas(char m)
137 geodesic_thomas(char m, std::string const& wkt1)
138 : strategy_base(m, wkt1)
140 geodesic_thomas(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
141 : strategy_base(m, wkt1, wkt2, opposite)
144 struct geodesic_andoyer : strategy_base
146 geodesic_andoyer(char m)
149 geodesic_andoyer(char m, std::string const& wkt1)
150 : strategy_base(m, wkt1)
152 geodesic_andoyer(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
153 : strategy_base(m, wkt1, wkt2, opposite)
156 struct great_elliptic : strategy_base
158 great_elliptic(char m)
161 great_elliptic(char m, std::string const& wkt1)
162 : strategy_base(m, wkt1)
164 great_elliptic(char m, std::string const& wkt1, std::string const& wkt2, bool opposite)
165 : strategy_base(m, wkt1, wkt2, opposite)
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)
174 test_default_strategy<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
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)
181 test_great_elliptic<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
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)
188 test_geodesic_vincenty<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
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)
195 test_geodesic_thomas<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
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)
202 test_geodesic_andoyer<S, P>(s1_wkt, s2_wkt, s.m, s.expected_count, s.wkt1, s.wkt2);
206 template <typename S, typename P, typename SR1>
207 void test_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
210 test_strategy<S, P>(s1_wkt, s2_wkt, sr1);
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)
216 test_strategy<S, P>(s1_wkt, s2_wkt, sr1);
217 test_strategy<S, P>(s1_wkt, s2_wkt, sr2);
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)
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);
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)
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);
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 = "")
242 std::size_t expected_count = ip0_wkt.empty() ? 0 : 1;
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);
252 template <typename S, typename P>
253 void test_all_strategies(std::string const& s1_wkt, std::string const& s2_wkt,
255 std::string const& ip0_wkt, std::string const& ip1_wkt,
258 int opposite_id = opposite ? 1 : 0;
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);
268 #endif // BOOST_GEOMETRY_TEST_STRATEGIES_SEGMENT_INTERSECTION_GEO_HPP