]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/distance/distance_geo_linear_box.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / distance / distance_geo_linear_box.cpp
CommitLineData
92f5a8d4
TL
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
1e59de90 4// Copyright (c) 2017-2021 Oracle and/or its affiliates.
92f5a8d4 5// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
1e59de90 6// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
92f5a8d4
TL
7
8// Licensed under the Boost Software License version 1.0.
9// http://www.boost.org/users/license.html
10
1e59de90 11#ifdef BOOST_GEOMETRY_TEST_DEBUG
92f5a8d4 12#include <iostream>
1e59de90
TL
13#endif
14
15#include <string>
92f5a8d4
TL
16
17#ifndef BOOST_TEST_MODULE
18#define BOOST_TEST_MODULE test_distance_geographic_linear_areal
19#endif
20
92f5a8d4 21#include <boost/test/included/unit_test.hpp>
92f5a8d4
TL
22
23#include "test_distance_geo_common.hpp"
24//#include "test_empty_geometry.hpp"
25
26
27template <typename Point, typename Strategy_pp, typename Strategy_ps>
28void test_distance_segment_polygon(Strategy_pp const& strategy_pp,
29 Strategy_ps const& strategy_ps)
30{
31
32#ifdef BOOST_GEOMETRY_TEST_DEBUG
33 std::cout << std::endl;
34 std::cout << "segment/polygon distance tests" << std::endl;
35#endif
36 typedef bg::model::segment<Point> segment_type;
37 typedef bg::model::polygon<Point> polygon_type;
38 typedef test_distance_of_geometries<segment_type, polygon_type> tester;
39
40 std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
41
42 tester::apply("s-r-1", "SEGMENT(0 0, 0 10)", polygon,
43 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
44 strategy_ps, true, false, false);
45}
46
47template <typename Point, typename Strategy_pp, typename Strategy_ps>
48void test_distance_linestring_polygon(Strategy_pp const& strategy_pp,
49 Strategy_ps const& strategy_ps)
50{
51
52#ifdef BOOST_GEOMETRY_TEST_DEBUG
53 std::cout << std::endl;
54 std::cout << "linestring/polygon distance tests" << std::endl;
55#endif
56 typedef bg::model::linestring<Point> linestring_type;
57 typedef bg::model::polygon<Point> polygon_type;
58 typedef test_distance_of_geometries<linestring_type, polygon_type> tester;
59
60 std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
61
62 tester::apply("l-r-1", "LINESTRING(0 0, 0 10)", polygon,
63 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
64 strategy_ps, true, false, false);
65}
66
67template <typename Point, typename Strategy_pp, typename Strategy_ps>
68void test_distance_multi_linestring_polygon(Strategy_pp const& strategy_pp,
69 Strategy_ps const& strategy_ps)
70{
71
72#ifdef BOOST_GEOMETRY_TEST_DEBUG
73 std::cout << std::endl;
74 std::cout << "multilinestring/polygon distance tests" << std::endl;
75#endif
76 typedef bg::model::linestring<Point> linestring_type;
77 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
78 typedef bg::model::polygon<Point> polygon_type;
79 typedef test_distance_of_geometries<multi_linestring_type, polygon_type> tester;
80
81 std::string const polygon = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
82
83 tester::apply("ml-r-1", "MULTILINESTRING((0 0, 0 10)(0 0, 10 0))", polygon,
84 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
85 strategy_ps, true, false, false);
86}
87
88//=====================================================================
89
90template <typename Point, typename Strategy_pp, typename Strategy_ps>
91void test_distance_segment_multi_polygon(Strategy_pp const& strategy_pp,
92 Strategy_ps const& strategy_ps)
93{
94
95#ifdef BOOST_GEOMETRY_TEST_DEBUG
96 std::cout << std::endl;
97 std::cout << "segment/multi_polygon distance tests" << std::endl;
98#endif
99 typedef bg::model::segment<Point> segment_type;
100 typedef bg::model::polygon<Point> polygon_type;
101 typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
102 typedef test_distance_of_geometries<segment_type, multi_polygon_type> tester;
103
104 std::string const mp = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
105 ((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
106
107 tester::apply("s-r-1", "SEGMENT(0 0, 0 10)", mp,
108 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
109 strategy_ps, true, false, false);
110}
111
112template <typename Point, typename Strategy_pp, typename Strategy_ps>
113void test_distance_linestring_multi_polygon(Strategy_pp const& strategy_pp,
114 Strategy_ps const& strategy_ps)
115{
116
117#ifdef BOOST_GEOMETRY_TEST_DEBUG
118 std::cout << std::endl;
119 std::cout << "linestring/multi_polygon distance tests" << std::endl;
120#endif
121 typedef bg::model::linestring<Point> linestring_type;
122 typedef bg::model::polygon<Point> polygon_type;
123 typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
124 typedef test_distance_of_geometries<linestring_type, multi_polygon_type> tester;
125
126 std::string const mp = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
127 ((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
128
129 tester::apply("l-r-1", "LINESTRING(0 0, 0 10)", mp,
130 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
131 strategy_ps, true, false, false);
132}
133
134template <typename Point, typename Strategy_pp, typename Strategy_ps>
135void test_distance_multi_linestring_multi_polygon(Strategy_pp const& strategy_pp,
136 Strategy_ps const& strategy_ps)
137{
138
139#ifdef BOOST_GEOMETRY_TEST_DEBUG
140 std::cout << std::endl;
141 std::cout << "multilinestring/multi_polygon distance tests" << std::endl;
142#endif
143 typedef bg::model::linestring<Point> linestring_type;
144 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
145 typedef bg::model::polygon<Point> polygon_type;
146 typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
147 typedef test_distance_of_geometries<multi_linestring_type, multi_polygon_type> tester;
148
149 std::string const polygon = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
150 ((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
151
152 tester::apply("ml-r-1", "MULTILINESTRING((0 0, 0 10)(0 0, 10 0))", polygon,
153 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
154 strategy_ps, true, false, false);
155}
156
157//=====================================================================
158
159template <typename Point, typename Strategy_pp, typename Strategy_ps>
160void test_distance_segment_ring(Strategy_pp const& strategy_pp,
161 Strategy_ps const& strategy_ps)
162{
163
164#ifdef BOOST_GEOMETRY_TEST_DEBUG
165 std::cout << std::endl;
166 std::cout << "segment/ring distance tests" << std::endl;
167#endif
168 typedef bg::model::segment<Point> segment_type;
169 typedef bg::model::ring<Point> ring_type;
170 typedef test_distance_of_geometries<segment_type, ring_type> tester;
171
172 std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
173
174 tester::apply("s-r-1", "SEGMENT(0 0, 0 10)", ring,
175 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
176 strategy_ps, true, false, false);
177}
178
179template <typename Point, typename Strategy_pp, typename Strategy_ps>
180void test_distance_linestring_ring(Strategy_pp const& strategy_pp,
181 Strategy_ps const& strategy_ps)
182{
183
184#ifdef BOOST_GEOMETRY_TEST_DEBUG
185 std::cout << std::endl;
186 std::cout << "linestring/ring distance tests" << std::endl;
187#endif
188 typedef bg::model::linestring<Point> linestring_type;
189 typedef bg::model::ring<Point> ring_type;
190 typedef test_distance_of_geometries<linestring_type, ring_type> tester;
191
192 std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
193
194 tester::apply("l-r-1", "LINESTRING(0 0, 0 10)", ring,
195 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
196 strategy_ps, true, false, false);
197}
198
199template <typename Point, typename Strategy_pp, typename Strategy_ps>
200void test_distance_multi_linestring_ring(Strategy_pp const& strategy_pp,
201 Strategy_ps const& strategy_ps)
202{
203
204#ifdef BOOST_GEOMETRY_TEST_DEBUG
205 std::cout << std::endl;
206 std::cout << "multilinestring/ring distance tests" << std::endl;
207#endif
208 typedef bg::model::linestring<Point> linestring_type;
209 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
210 typedef bg::model::ring<Point> ring_type;
211 typedef test_distance_of_geometries<multi_linestring_type, ring_type> tester;
212
213 std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
214
215 tester::apply("ml-r-1", "MULTILINESTRING((0 0, 0 10)(0 0, 10 0))", ring,
216 ps_distance<Point>("POINT(0 10)", "SEGMENT(0 20, 10 10)", strategy_ps),
217 strategy_ps, true, false, false);
218}
219
220//======================================================================
221
222template <typename Point, typename Strategy_pp, typename Strategy_ps, typename Strategy_sb>
223void test_distance_segment_box(Strategy_pp const& strategy_pp,
224 Strategy_ps const& strategy_ps,
225 Strategy_sb const& strategy_sb)
226{
227
228#ifdef BOOST_GEOMETRY_TEST_DEBUG
229 std::cout << std::endl;
230 std::cout << "segment/box distance tests" << std::endl;
231#endif
232 typedef bg::model::segment<Point> segment_type;
233 typedef bg::model::box<Point> box_type;
234 typedef test_distance_of_geometries<segment_type, box_type> tester;
235
236 std::string const box_north = "BOX(10 10,20 20)";
237
238 tester::apply("sb1-1a", "SEGMENT(0 0, 0 20)", box_north,
239 pp_distance<Point>("POINT(0 20)", "POINT(10 20)", strategy_pp),
240 strategy_sb);
241 //segment with slope
242 tester::apply("sb1-1b", "SEGMENT(10 5, 20 6)", box_north,
243 pp_distance<Point>("POINT(20 6)", "POINT(20 10)", strategy_pp),
244 strategy_sb);
245 tester::apply("sb1-2", "SEGMENT(0 0, 0 10)", box_north,
246 ps_distance<Point>("POINT(0 10)", "SEGMENT(10 10,10 20)", strategy_ps),
247 strategy_sb);
248 tester::apply("sb1-3", "SEGMENT(0 0, 0 15)", box_north,
249 ps_distance<Point>("POINT(0 15)", "SEGMENT(10 10,10 20)", strategy_ps),
250 strategy_sb);
251 tester::apply("sb1-4", "SEGMENT(0 0, 0 25)", box_north,
252 ps_distance<Point>("POINT(10 20)", "SEGMENT(0 0,0 25)", strategy_ps),
253 strategy_sb);
254 tester::apply("sb1-5", "SEGMENT(0 10, 0 25)", box_north,
255 ps_distance<Point>("POINT(10 20)", "SEGMENT(0 0,0 25)", strategy_ps),
256 strategy_sb);
257
258 tester::apply("sb2-2", "SEGMENT(0 5, 15 5)", box_north,
259 ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5,15 5)", strategy_ps),
260 strategy_sb);
261 tester::apply("sb2-3a", "SEGMENT(0 5, 20 5)", box_north,
262 ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5,20 5)", strategy_ps),
263 strategy_sb);
264
265 // Test segments below box
266 tester::apply("test_b1", "SEGMENT(0 5, 9 5)", box_north,
267 ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 9 5)", strategy_ps),
268 strategy_sb);
269 tester::apply("test_b2", "SEGMENT(0 5, 10 5)", box_north,
270 ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 10 5)", strategy_ps),
271 strategy_sb);
272 tester::apply("test_b3", "SEGMENT(0 5, 11 5)", box_north,
273 ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 11 5)", strategy_ps),
274 strategy_sb);
275 tester::apply("test_b4", "SEGMENT(0 5, 20 5)", box_north,
276 ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5,20 5)", strategy_ps),
277 strategy_sb);
278 tester::apply("test_b5", "SEGMENT(0 5, 22 5)", box_north,
279 ps_distance<Point>("POINT(11 10)", "SEGMENT(0 5,22 5)", strategy_ps),
280 strategy_sb);
281 tester::apply("test_b6", "SEGMENT(10 5, 20 5)", box_north,
282 ps_distance<Point>("POINT(15 10)", "SEGMENT(10 5,20 5)", strategy_ps),
283 strategy_sb);
284 tester::apply("test_b7", "SEGMENT(10 5, 22 5)", box_north,
285 ps_distance<Point>("POINT(16 10)", "SEGMENT(10 5,22 5)", strategy_ps),
286 strategy_sb);
287 tester::apply("test_b8", "SEGMENT(12 5, 22 5)", box_north,
288 ps_distance<Point>("POINT(17 10)", "SEGMENT(12 5,22 5)", strategy_ps),
289 strategy_sb);
290 tester::apply("test_b9", "SEGMENT(18 5, 22 5)", box_north,
291 ps_distance<Point>("POINT(20 10)", "SEGMENT(18 5,22 5)", strategy_ps),
292 strategy_sb);
293 tester::apply("test_b10", "SEGMENT(18 5, 24 5)", box_north,
294 ps_distance<Point>("POINT(20 10)", "SEGMENT(18 5,24 5)", strategy_ps),
295 strategy_sb);
296 tester::apply("test_b11", "SEGMENT(20 5, 24 5)", box_north,
297 ps_distance<Point>("POINT(20 10)", "SEGMENT(20 5,24 5)", strategy_ps),
298 strategy_sb);
299 tester::apply("test_b12", "SEGMENT(22 5, 24 5)", box_north,
300 ps_distance<Point>("POINT(20 10)", "SEGMENT(22 5,24 5)", strategy_ps),
301 strategy_sb);
302 tester::apply("test_b13", "SEGMENT(0 5, 125 5)", box_north,
303 ps_distance<Point>("POINT(20 10)", "SEGMENT(0 5, 125 5)", strategy_ps),
304 strategy_sb);
305
306 // Test segments above box
307 tester::apply("test_a1", "SEGMENT(0 25, 9 25)", box_north,
308 ps_distance<Point>("POINT(10 20)", "SEGMENT(0 25, 9 25)", strategy_ps),
309 strategy_sb);
310 tester::apply("test_a2", "SEGMENT(0 25, 10 25)", box_north,
311 ps_distance<Point>("POINT(10 20)", "SEGMENT(0 25, 10 25)", strategy_ps),
312 strategy_sb);
313 tester::apply("test_a3", "SEGMENT(0 25, 11 25)", box_north,
314 ps_distance<Point>("POINT(11 20)", "SEGMENT(0 25, 11 25)", strategy_ps),
315 strategy_sb);
316 tester::apply("test_a4", "SEGMENT(0 25, 20 25)", box_north,
317 ps_distance<Point>("POINT(20 20)", "SEGMENT(0 25, 20 25)", strategy_ps),
318 strategy_sb);
319 tester::apply("test_a5", "SEGMENT(0 25, 22 25)", box_north,
320 ps_distance<Point>("POINT(20 20)", "SEGMENT(0 25, 22 25)", strategy_ps),
321 strategy_sb);
322 tester::apply("test_a6", "SEGMENT(10 25, 20 25)", box_north,
323 ps_distance<Point>("POINT(20 20)", "SEGMENT(10 25, 20 25)", strategy_ps),
324 strategy_sb);
325 tester::apply("test_a7", "SEGMENT(10 25, 22 25)", box_north,
326 ps_distance<Point>("POINT(10 20)", "SEGMENT(10 25, 22 25)", strategy_ps),
327 strategy_sb);
328 tester::apply("test_a8", "SEGMENT(12 25, 22 25)", box_north,
329 ps_distance<Point>("POINT(12 20)", "SEGMENT(12 25, 22 25)", strategy_ps),
330 strategy_sb);
331 tester::apply("test_a9", "SEGMENT(18 25, 22 25)", box_north,
332 ps_distance<Point>("POINT(18 20)", "SEGMENT(18 25, 22 25)", strategy_ps),
333 strategy_sb);
334 tester::apply("test_a10", "SEGMENT(18 25, 24 25)", box_north,
335 ps_distance<Point>("POINT(18 20)", "SEGMENT(18 25, 24 25)", strategy_ps),
336 strategy_sb);
337 tester::apply("test_a11", "SEGMENT(20 25, 24 25)", box_north,
338 ps_distance<Point>("POINT(20 20)", "SEGMENT(20 25, 24 25)", strategy_ps),
339 strategy_sb);
340 tester::apply("test_a12", "SEGMENT(22 25, 24 25)", box_north,
341 ps_distance<Point>("POINT(20 20)", "SEGMENT(22 25, 24 25)", strategy_ps),
342 strategy_sb);
343
344 // Segments left-right of box
345 tester::apply("test_l1", "SEGMENT(0 5, 9 5)", box_north,
346 ps_distance<Point>("POINT(10 10)", "SEGMENT(0 5, 9 5)", strategy_ps),
347 strategy_sb);
348 tester::apply("test_l2", "SEGMENT(0 10, 9 10)", box_north,
349 ps_distance<Point>("POINT(9 10)", "SEGMENT(10 10, 10 20)", strategy_ps),
350 strategy_sb);
351 tester::apply("test_l3", "SEGMENT(0 10, 9 15)", box_north,
352 ps_distance<Point>("POINT(9 15)", "SEGMENT(10 10, 10 20)", strategy_ps),
353 strategy_sb);
354 tester::apply("test_l4", "SEGMENT(0 10, 0 15)", box_north,
355 ps_distance<Point>("POINT(0 15)", "SEGMENT(10 10, 10 20)", strategy_ps),
356 strategy_sb);
357 tester::apply("test_l5", "SEGMENT(1 10, 0 15)", box_north,
358 ps_distance<Point>("POINT(1 10)", "SEGMENT(10 10, 10 20)", strategy_ps),
359 strategy_sb);
360 tester::apply("test_l6", "SEGMENT(0 20, 9 21)", box_north,
361 ps_distance<Point>("POINT(9 21)", "SEGMENT(10 10, 10 20)", strategy_ps),
362 strategy_sb);
363 tester::apply("test_r1", "SEGMENT(21 5, 29 5)", box_north,
364 ps_distance<Point>("POINT(20 10)", "SEGMENT(21 5, 29 5)", strategy_ps),
365 strategy_sb);
366 tester::apply("test_r2", "SEGMENT(21 10, 29 10)", box_north,
367 ps_distance<Point>("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
368 strategy_sb);
369 tester::apply("test_r3", "SEGMENT(21 10, 29 15)", box_north,
370 ps_distance<Point>("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
371 strategy_sb);
372 tester::apply("test_r4", "SEGMENT(21 10, 21 15)", box_north,
373 ps_distance<Point>("POINT(21 15)", "SEGMENT(20 10, 20 20)", strategy_ps),
374 strategy_sb);
375 tester::apply("test_r5", "SEGMENT(21 10, 22 15)", box_north,
376 ps_distance<Point>("POINT(21 10)", "SEGMENT(20 10, 20 20)", strategy_ps),
377 strategy_sb);
378 tester::apply("test_r6", "SEGMENT(29 20, 21 21)", box_north,
379 ps_distance<Point>("POINT(21 21)", "SEGMENT(20 10, 20 20)", strategy_ps),
380 strategy_sb);
381
382 //Segments on corners of box
383 //left-top corner
384 //generic
385 tester::apply("test_c1", "SEGMENT(9 19.5, 11 21)", box_north,
386 ps_distance<Point>("POINT(10 20)", "SEGMENT(9 19.5, 11 21)", strategy_ps),
387 strategy_sb);
388 //degenerate
389 tester::apply("test_c2", "SEGMENT(9 19, 11 21)", box_north,
390 ps_distance<Point>("POINT(10 20)", "SEGMENT(9 19, 11 21)", strategy_ps),
391 strategy_sb);
392 //left-bottom corner
393 //generic
394 tester::apply("test_c3", "SEGMENT(8.5 11, 11 9)", box_north,
395 ps_distance<Point>("POINT(10 10)", "SEGMENT(8.5 11, 11 9)", strategy_ps),
396 strategy_sb);
397 //degenerate
398 tester::apply("test_c4", "SEGMENT(9 11, 11 9)", box_north,
399 0,
400 strategy_sb);
401 //right-top corner
402 //generic
403 tester::apply("test_c5", "SEGMENT(19 21, 21 19.5)", box_north,
404 ps_distance<Point>("POINT(20 20)", "SEGMENT(19 21, 21 19.5)", strategy_ps),
405 strategy_sb);
406 //degenerate
407 tester::apply("test_c6", "SEGMENT(19 21, 21 19)", box_north,
408 ps_distance<Point>("POINT(20 20)", "SEGMENT(19 21, 21 19)", strategy_ps),
409 strategy_sb);
410 //right-bottom corner
411 //generic
412 tester::apply("test_c7", "SEGMENT(19 9, 21 10.5)", box_north,
413 ps_distance<Point>("POINT(20 10)", "SEGMENT(19 9, 21 10.5)", strategy_ps),
414 strategy_sb);
415 tester::apply("test_c7", "SEGMENT(19 9, 21 11)", box_north,
416 0,
417 strategy_sb);
418
419 //Segment and box on different hemispheres
420 std::string const box_south = "BOX(10 -20,20 -10)";
421
422 tester::apply("test_ns1", "SEGMENT(10 20, 15 30)", box_south,
423 ps_distance<Point>("POINT(10 -10)", "SEGMENT(10 20, 15 30)", strategy_ps),
424 strategy_sb);
425 tester::apply("test_ns2", "SEGMENT(0 10, 12 10)", box_south,
426 pp_distance<Point>("POINT(12 10)", "POINT(12 -10)", strategy_pp),
427 strategy_sb);
428 tester::apply("test_ns3", "SEGMENT(10 10, 20 10)", box_south,
429 pp_distance<Point>("POINT(10 10)", "POINT(10 -10)", strategy_pp),
430 strategy_sb);
431 tester::apply("test_ns4", "SEGMENT(0 -10, 12 -10)", box_north,
432 pp_distance<Point>("POINT(12 10)", "POINT(12 -10)", strategy_pp),
433 strategy_sb);
434 tester::apply("test_ns5", "SEGMENT(10 -10, 20 -10)", box_north,
435 pp_distance<Point>("POINT(10 -10)", "POINT(10 10)", strategy_pp),
436 strategy_sb);
437
438 //Box crossing equator
439 std::string const box_crossing_eq = "BOX(10 -10,20 10)";
440
441 tester::apply("test_cr1", "SEGMENT(10 20, 15 30)", box_crossing_eq,
442 pp_distance<Point>("POINT(10 10)", "POINT(10 20)", strategy_pp),
443 strategy_sb);
444 tester::apply("test_cr2", "SEGMENT(10 -20, 15 -30)", box_crossing_eq,
445 pp_distance<Point>("POINT(10 10)", "POINT(10 20)", strategy_pp),
446 strategy_sb);
447
448 //Box crossing prime meridian
449
450 std::string const box_crossing_mer = "BOX(-10 10,15 20)";
451
452 tester::apply("test_cr3", "SEGMENT(-5 25, 10 30)", box_crossing_mer,
453 pp_distance<Point>("POINT(-5 25)", "POINT(-5 20)", strategy_pp),
454 strategy_sb);
455 tester::apply("test_cr4", "SEGMENT(-5 5, 10 7)", box_crossing_mer,
456 pp_distance<Point>("POINT(10 7)", "POINT(10 10)", strategy_pp),
457 strategy_sb);
458 tester::apply("test_cr5", "SEGMENT(-5 5, 10 5)", box_crossing_mer,
459 ps_distance<Point>("POINT(2.5 10)", "SEGMENT(-5 5, 10 5)", strategy_ps),
460 strategy_sb);
461
462
463 //Geometries in south hemisphere
464 tester::apply("test_south1", "SEGMENT(10 -30, 15 -30)", box_south,
465 ps_distance<Point>("POINT(10 -20)", "SEGMENT(10 -30, 15 -30)", strategy_ps),
466 strategy_sb);
467
468 //Segments in boxes corner
469 tester::apply("corner1", "SEGMENT(17 21, 25 20)", box_north,
470 ps_distance<Point>("POINT(20 20)", "SEGMENT(17 21, 25 20)", strategy_ps),
471 strategy_sb);
472 tester::apply("corner2", "SEGMENT(17 21, 0 20)", box_north,
473 ps_distance<Point>("POINT(10 20)", "SEGMENT(17 21, 0 20)", strategy_ps),
474 strategy_sb);
475 tester::apply("corner3", "SEGMENT(17 5, 0 10)", box_north,
476 ps_distance<Point>("POINT(10 10)", "SEGMENT(17 5, 0 10)", strategy_ps),
477 strategy_sb);
478 tester::apply("corner4", "SEGMENT(17 5, 25 9)", box_north,
479 ps_distance<Point>("POINT(20 10)", "SEGMENT(17 5, 25 9)", strategy_ps),
480 strategy_sb);
481}
482
483template <typename Point, typename Strategy_ps, typename Strategy_sb>
484void test_distance_linestring_box(Strategy_ps const& strategy_ps, Strategy_sb const& strategy_sb)
485{
486
487#ifdef BOOST_GEOMETRY_TEST_DEBUG
488 std::cout << std::endl;
489 std::cout << "linestring/box distance tests" << std::endl;
490#endif
491 typedef bg::model::linestring<Point> linestring_type;
492 typedef bg::model::box<Point> box_type;
493 typedef test_distance_of_geometries<linestring_type, box_type> tester;
494
495 std::string const box_north = "BOX(10 10,20 20)";
496
497 tester::apply("sl1", "LINESTRING(0 20, 15 21, 25 19.9, 21 5, 15 5, 0 10)", box_north,
498 ps_distance<Point>("POINT(20 20)", "SEGMENT(15 21, 25 19.9)", strategy_ps),
499 strategy_ps, true, false, false);
500
501 tester::apply("sl2", "LINESTRING(0 20, 15 21, 25 19.9, 21 5, 15 5, 15 15)", box_north,
502 0, strategy_ps, true, false, false);
503
504 tester::apply("sl3", "LINESTRING(0 20, 15 21, 25 19.9, 21 5, 15 5, 2 20)", box_north,
505 0, strategy_ps, true, false, false);
506}
507
508template <typename Point, typename Strategy_ps, typename Strategy_sb>
509void test_distance_multi_linestring_box(Strategy_ps const& strategy_ps, Strategy_sb const& strategy_sb)
510{
511
512#ifdef BOOST_GEOMETRY_TEST_DEBUG
513 std::cout << std::endl;
514 std::cout << "multi_linestring/box distance tests" << std::endl;
515#endif
516 typedef bg::model::linestring<Point> linestring_type;
517 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
518 typedef bg::model::box<Point> box_type;
519 typedef test_distance_of_geometries<multi_linestring_type, box_type> tester;
520
521 std::string const box_north = "BOX(10 10,20 20)";
522
523 tester::apply("sl1", "MULTILINESTRING((0 20, 15 21, 25 19.9, 21 5, 15 5, 0 10)(25 20, 22 4, 0 0))", box_north,
524 ps_distance<Point>("POINT(20 20)", "SEGMENT(15 21, 25 19.9)", strategy_ps),
525 strategy_sb, true, false, false);
526}
527
528//===========================================================================
529//===========================================================================
530//===========================================================================
531
532
533template <typename Point, typename Strategy_pp, typename Strategy_ps, typename Strategy_sb>
534void test_all_l_ar(Strategy_pp pp_strategy, Strategy_ps ps_strategy, Strategy_sb sb_strategy)
535{
536 test_distance_segment_polygon<Point>(pp_strategy, ps_strategy);
537 test_distance_linestring_polygon<Point>(pp_strategy, ps_strategy);
538 test_distance_multi_linestring_polygon<Point>(pp_strategy, ps_strategy);
539
540 test_distance_segment_multi_polygon<Point>(pp_strategy, ps_strategy);
541 test_distance_linestring_multi_polygon<Point>(pp_strategy, ps_strategy);
542 test_distance_multi_linestring_multi_polygon<Point>(pp_strategy, ps_strategy);
543
544 test_distance_segment_ring<Point>(pp_strategy, ps_strategy);
545 test_distance_linestring_ring<Point>(pp_strategy, ps_strategy);
546 test_distance_multi_linestring_ring<Point>(pp_strategy, ps_strategy);
547
548 test_distance_segment_box<Point>(pp_strategy, ps_strategy, sb_strategy);
549 //test_distance_linestring_box<Point>(ps_strategy, sb_strategy);
550 //test_distance_multi_linestring_box<Point>(ps_strategy, sb_strategy);
551
552 //test_more_empty_input_linear_areal<Point>(ps_strategy);
553}
554
555BOOST_AUTO_TEST_CASE( test_all_linear_areal )
556{
557 typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> >
558 sph_point;
559 test_all_l_ar<sph_point>(spherical_pp(), spherical_ps(), spherical_sb());
560
561 typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree> > geo_point;
562
563 test_all_l_ar<geo_point>(vincenty_pp(), vincenty_ps(), vincenty_sb());
564 test_all_l_ar<geo_point>(thomas_pp(), thomas_ps(), thomas_sb());
565 test_all_l_ar<geo_point>(andoyer_pp(), andoyer_ps(), andoyer_sb());
1e59de90 566 //test_all_l_ar<geo_point>(karney_pp(), karney_ps(), karney_sb());
92f5a8d4 567}