]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/distance/distance_se_geo_l_l.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / distance / distance_se_geo_l_l.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2018 Oracle and/or its affiliates.
5
6 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
7
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10
11 #include <iostream>
12
13 #ifndef BOOST_TEST_MODULE
14 #define BOOST_TEST_MODULE test_distance_geographic_linear_linear
15 #endif
16
17 #include <boost/range.hpp>
18 #include <boost/type_traits/is_same.hpp>
19
20 #include <boost/test/included/unit_test.hpp>
21 #include <boost/geometry/util/condition.hpp>
22 #include <boost/geometry/strategies/strategies.hpp>
23
24 #include "test_distance_geo_common.hpp"
25 #include "test_empty_geometry.hpp"
26
27 //===========================================================================
28
29 template <typename Point, typename Strategy>
30 void test_distance_segment_segment(Strategy const& strategy_ps)
31 {
32
33 #ifdef BOOST_GEOMETRY_TEST_DEBUG
34 std::cout << std::endl;
35 std::cout << "segment/segment distance tests" << std::endl;
36 #endif
37
38 typedef bg::model::segment<Point> segment_type;
39
40 typedef test_distance_of_geometries<segment_type, segment_type> tester;
41
42 tester::apply("s-s-01",
43 "SEGMENT(0 0,1 1)",
44 "SEGMENT(2 0,3 0)",
45 ps_distance<Point>("POINT(2 0)",
46 "SEGMENT(0 0,1 1)", strategy_ps),
47 strategy_ps, true, true, false);
48 tester::apply("s-s-02",
49 "SEGMENT(2 1,3 1)",
50 "SEGMENT(2 0,3 0)",
51 ps_distance<Point>("POINT(2 0)",
52 "SEGMENT(2 1,3 1)", strategy_ps),
53 strategy_ps, true, true, false);
54 tester::apply("s-s-03",
55 "SEGMENT(2.5 1,3.5 1)",
56 "SEGMENT(2 0,3 0)",
57 ps_distance<Point>("POINT(2.5 0)",
58 "SEGMENT(2.5 1,3.5 1)", strategy_ps),
59 strategy_ps, true, true, false);
60 tester::apply("s-s-04",
61 "SEGMENT(2.5 1,3.5 1)",
62 "SEGMENT(2 2,3 2)",
63 ps_distance<Point>("POINT(3 2)",
64 "SEGMENT(2.5 1,3.5 1)", strategy_ps),
65 strategy_ps, true, true, false);
66 tester::apply("s-s-05",
67 "SEGMENT(2.5 2.1,3.5 1)",
68 "SEGMENT(2 2,3 2)",
69 0, strategy_ps, true, true, false);
70 tester::apply("s-s-06",
71 "SEGMENT(2.5 2.1,3.5 1)",
72 "SEGMENT(2 2,3.5 1)",
73 0, strategy_ps, true, true, false);
74 }
75
76 //===========================================================================
77
78 template <typename Point, typename Strategy>
79 void test_distance_segment_linestring(Strategy const& strategy_ps)
80 {
81 #ifdef BOOST_GEOMETRY_TEST_DEBUG
82 std::cout << std::endl;
83 std::cout << "segment/linestring distance tests" << std::endl;
84 #endif
85
86 typedef bg::model::segment<Point> segment_type;
87 typedef bg::model::linestring<Point> linestring_type;
88
89 typedef test_distance_of_geometries<segment_type, linestring_type> tester;
90
91 tester::apply("s-l-01",
92 "SEGMENT(0 0,1 1)",
93 "LINESTRING(2 0,3 0)",
94 ps_distance<Point>("POINT(2 0)",
95 "SEGMENT(0 0,1 1)", strategy_ps),
96 strategy_ps, true, true, false);
97 tester::apply("s-l-02",
98 "SEGMENT(0 0,1 1)",
99 "LINESTRING(2 0,3 0,2 2,0.5 0.7)",
100 ps_distance<Point>("POINT(1 1)",
101 "SEGMENT(0.5 0.7,2 2)", strategy_ps),
102 strategy_ps, true, true, false);
103 tester::apply("s-l-03",
104 "SEGMENT(0 0,2 2)",
105 "LINESTRING(2 0,3 0,2 2,0.5 0.7)",
106 0, strategy_ps, true, true, false);
107 }
108
109 //===========================================================================
110
111 template <typename Point, typename Strategy>
112 void test_distance_linestring_linestring(Strategy const& strategy_ps)
113 {
114 #ifdef BOOST_GEOMETRY_TEST_DEBUG
115 std::cout << std::endl;
116 std::cout << "linestring/linestring distance tests" << std::endl;
117 #endif
118
119 typedef bg::model::linestring<Point> linestring_type;
120
121 typedef test_distance_of_geometries
122 <
123 linestring_type, linestring_type
124 > tester;
125
126 tester::apply("l-l-01",
127 "LINESTRING(0 0,1 1)",
128 "LINESTRING(2 0,3 0)",
129 ps_distance<Point>("POINT(2 0)",
130 "SEGMENT(0 0,1 1)", strategy_ps),
131 strategy_ps, true, true, false);
132 tester::apply("l-l-02",
133 "LINESTRING(0 0,1 1,2 2)",
134 "LINESTRING(2 0,3 0,4 1)",
135 ps_distance<Point>("POINT(2 0)",
136 "SEGMENT(1 1,2 2)", strategy_ps),
137 strategy_ps, true, true, false);
138 tester::apply("l-l-03",
139 "LINESTRING(0 0,1 1,2 2)",
140 "LINESTRING(2 0)",
141 ps_distance<Point>("POINT(2 0)",
142 "SEGMENT(1 1,2 2)", strategy_ps),
143 strategy_ps, true, true, false);
144 tester::apply("l-l-04",
145 "LINESTRING(0 0,1 1,2 2)",
146 "LINESTRING(3 3,1 1)",
147 0, strategy_ps, true, true, false);
148 }
149
150 //===========================================================================
151
152 template <typename Point, typename Strategy>
153 void test_distance_segment_multilinestring(Strategy const& strategy_ps)
154 {
155 #ifdef BOOST_GEOMETRY_TEST_DEBUG
156 std::cout << std::endl;
157 std::cout << "segment/multilinestring distance tests" << std::endl;
158 #endif
159
160 typedef bg::model::segment<Point> segment_type;
161 typedef bg::model::linestring<Point> linestring_type;
162 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
163
164 typedef test_distance_of_geometries
165 <
166 segment_type, multi_linestring_type
167 > tester;
168
169 tester::apply("s-ml-01",
170 "SEGMENT(0 0,1 1)",
171 "MULTILINESTRING((2 0,3 0)(2 5, 5 5, 2 -1))",
172 ps_distance<Point>("POINT(2 0)",
173 "SEGMENT(0 0,1 1)", strategy_ps),
174 strategy_ps, true, true, false);
175 tester::apply("s-ml-02",
176 "SEGMENT(0 0,1 1)",
177 "MULTILINESTRING((2 0,3 0))",
178 ps_distance<Point>("POINT(2 0)",
179 "SEGMENT(0 0,1 1)", strategy_ps),
180 strategy_ps, true, true, false);
181 tester::apply("s-ml-03",
182 "SEGMENT(0 0,2 0)",
183 "MULTILINESTRING((2 0,3 0)(2 5, 5 5, 2 -1))",
184 0, strategy_ps, true, true, false);
185 }
186
187 //===========================================================================
188
189 template <typename Point, typename Strategy>
190 void test_distance_linestring_multilinestring(Strategy const& strategy_ps)
191 {
192 #ifdef BOOST_GEOMETRY_TEST_DEBUG
193 std::cout << std::endl;
194 std::cout << "linestring/multilinestring distance tests" << std::endl;
195 #endif
196
197 typedef bg::model::linestring<Point> linestring_type;
198 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
199
200 typedef test_distance_of_geometries
201 <
202 linestring_type, multi_linestring_type
203 > tester;
204
205 tester::apply("l-ml-01",
206 "LINESTRING(0 0,1 1,2 2,3 3,4 4,6 6)",
207 "MULTILINESTRING((2 0,3 0)(2 1, 5 5))",
208 ps_distance<Point>("POINT(5 5)",
209 "SEGMENT(4 4,6 6)", strategy_ps),
210 strategy_ps, true, true, false);
211 tester::apply("l-ml-02",
212 "LINESTRING(0 0,1 1,2 2,3 3,4 4,6 6)",
213 "MULTILINESTRING((2 0,3 0)(2 5, 5 5))",
214 0,
215 strategy_ps, true, true, false);
216
217 }
218
219 //===========================================================================
220
221 template <typename Point, typename Strategy>
222 void test_distance_multilinestring_multilinestring(Strategy const& strategy_ps)
223 {
224 #ifdef BOOST_GEOMETRY_TEST_DEBUG
225 std::cout << std::endl;
226 std::cout << "multilinestring/multilinestring distance tests" << std::endl;
227 #endif
228
229 typedef bg::model::linestring<Point> linestring_type;
230 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
231
232 typedef test_distance_of_geometries
233 <
234 multi_linestring_type, multi_linestring_type
235 > tester;
236
237 tester::apply("s-ml-01",
238 "MULTILINESTRING((0 0,1 1)(-1 0, -1 -1))",
239 "MULTILINESTRING((2 0,3 0)(2 5, 5 5))",
240 ps_distance<Point>("POINT(2 0)",
241 "SEGMENT(0 0,1 1)", strategy_ps),
242 strategy_ps, true, true, false);
243 tester::apply("s-ml-02",
244 "MULTILINESTRING((0 0,1 1)(-1 0, -1 -1)(5 0, 5 6))",
245 "MULTILINESTRING((2 0,3 0)(2 5, 5 5))",
246 0,
247 strategy_ps, true, true, false);
248 }
249
250 //===========================================================================
251 //===========================================================================
252 //===========================================================================
253
254 template <typename Point, typename Strategy>
255 void test_all_l_l(Strategy ps_strategy)
256 {
257 test_distance_segment_segment<Point>(ps_strategy);
258 test_distance_segment_linestring<Point>(ps_strategy);
259 test_distance_linestring_linestring<Point>(ps_strategy);
260 test_distance_segment_multilinestring<Point>(ps_strategy);
261 test_distance_linestring_multilinestring<Point>(ps_strategy);
262 test_distance_multilinestring_multilinestring<Point>(ps_strategy);
263
264 test_more_empty_input_linear_linear<Point>(ps_strategy);
265 }
266
267 BOOST_AUTO_TEST_CASE( test_all_linear_linear )
268 {
269 typedef bg::model::point
270 <
271 double, 2,
272 bg::cs::spherical_equatorial<bg::degree>
273 > sph_point;
274
275 test_all_l_l<sph_point>(spherical_ps());
276
277 typedef bg::model::point
278 <
279 double, 2,
280 bg::cs::geographic<bg::degree>
281 > geo_point;
282
283 test_all_l_l<geo_point>(vincenty_ps());
284 test_all_l_l<geo_point>(thomas_ps());
285 test_all_l_l<geo_point>(andoyer_ps());
286 }