1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2014-2018, Oracle and/or its affiliates.
5
6 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
7 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
8
9 // Licensed under the Boost Software License version 1.0.
10 // http://www.boost.org/users/license.html
11
12 #include <iostream>
13
14 #ifndef BOOST_TEST_MODULE
15 #define BOOST_TEST_MODULE test_distance_cartesian_pointlike_areal
16 #endif
17
18 #include <boost/test/included/unit_test.hpp>
19
20 #include "test_distance_common.hpp"
21
22
23 typedef bg::model::point<double,2,bg::cs::cartesian> point_type;
24 typedef bg::model::multi_point<point_type> multi_point_type;
25 typedef bg::model::point<double,3,bg::cs::cartesian> point_type_3d;
26 typedef bg::model::multi_point<point_type_3d> multi_point_type_3d;
27 typedef bg::model::polygon<point_type, false> polygon_type;
28 typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
29 typedef bg::model::ring<point_type, false> ring_type;
30 typedef bg::model::box<point_type> box_type;
31 typedef bg::model::box<point_type_3d> box_type_3d;
32
33 namespace services = bg::strategy::distance::services;
34 typedef bg::default_distance_result<point_type>::type return_type;
35
36 typedef bg::strategy::distance::pythagoras<> point_point_strategy;
37 typedef bg::strategy::distance::projected_point<> point_segment_strategy;
38 typedef bg::strategy::distance::pythagoras_point_box<> point_box_strategy;
39
40 //===========================================================================
41
42 template <typename Strategy>
test_distance_point_polygon(Strategy const & strategy)43 void test_distance_point_polygon(Strategy const& strategy)
44 {
45 #ifdef BOOST_GEOMETRY_TEST_DEBUG
46 std::cout << std::endl;
47 std::cout << "point/polygon distance tests" << std::endl;
48 #endif
49 typedef test_distance_of_geometries<point_type, polygon_type> tester;
50
51 tester::apply("point(0 -20)",
52 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
53 10, 100, strategy);
54
55 tester::apply("point(12 0)",
56 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
57 2, 4, strategy);
58
59 tester::apply("point(0 0)",
60 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
61 0, 0, strategy);
62
63 tester::apply("point(0 0)",
64 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\
65 (-5 -5,-5 5,5 5,5 -5,-5 -5))",
66 5, 25, strategy);
67
68 // polygons with single-point rings
69 tester::apply("point(0 0)",
70 "polygon((-5 5))",
71 sqrt(50.0), 50, strategy);
72
73 tester::apply("point(0 0)",
74 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),(-5 5))",
75 0, 0, strategy);
76 }
77
78 //===========================================================================
79
80 template <typename Strategy>
test_distance_point_ring(Strategy const & strategy)81 void test_distance_point_ring(Strategy const& strategy)
82 {
83 #ifdef BOOST_GEOMETRY_TEST_DEBUG
84 std::cout << std::endl;
85 std::cout << "point/ring distance tests" << std::endl;
86 #endif
87 typedef test_distance_of_geometries<point_type, ring_type> tester;
88
89 tester::apply("point(0 -20)",
90 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
91 10, 100, strategy);
92
93 tester::apply("point(12 0)",
94 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
95 2, 4, strategy);
96
97 tester::apply("point(0 0)",
98 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
99 0, 0, strategy);
100
101 // single-point rings
102 tester::apply("point(0 0)",
103 "polygon((-10 -10))",
104 sqrt(200.0), 200, strategy);
105 }
106
107 //===========================================================================
108
109 template <typename Strategy>
test_distance_point_multipolygon(Strategy const & strategy)110 void test_distance_point_multipolygon(Strategy const& strategy)
111 {
112 #ifdef BOOST_GEOMETRY_TEST_DEBUG
113 std::cout << std::endl;
114 std::cout << "point/multipolygon distance tests" << std::endl;
115 #endif
116 typedef test_distance_of_geometries<point_type, multi_polygon_type> tester;
117
118 tester::apply("point(0 -20)",
119 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
120 ((0 22,-1 30,2 40,0 22)))",
121 10, 100, strategy);
122
123 tester::apply("point(12 0)",
124 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
125 ((20 -1,21 2,30 -10,20 -1)))",
126 2, 4, strategy);
127
128 tester::apply("point(0 0)",
129 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
130 ((20 -1,21 2,30 -10,20 -1)))",
131 0, 0, strategy);
132
133 tester::apply("point(0 0)",
134 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\
135 (-5 -5,-5 5,5 5,5 -5,-5 -5)),\
136 ((100 0,101 0,101 1,100 1,100 0)))",
137 5, 25, strategy);
138 }
139
140 //===========================================================================
141
142 template <typename Strategy>
test_distance_multipoint_polygon(Strategy const & strategy)143 void test_distance_multipoint_polygon(Strategy const& strategy)
144 {
145 #ifdef BOOST_GEOMETRY_TEST_DEBUG
146 std::cout << std::endl;
147 std::cout << "multipoint/polygon distance tests" << std::endl;
148 #endif
149 typedef test_distance_of_geometries<multi_point_type, polygon_type> tester;
150
151 tester::apply("multipoint(0 -20,0 -15)",
152 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
153 5, 25, strategy);
154
155 tester::apply("multipoint(16 0,12 0)",
156 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
157 2, 4, strategy);
158
159 tester::apply("multipoint(0 0,5 5,4 4)",
160 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
161 0, 0, strategy);
162
163 tester::apply("multipoint(0 0,2 0)",
164 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\
165 (-5 -5,-5 5,5 5,5 -5,-5 -5))",
166 3, 9, strategy);
167
168 tester::apply("multipoint(4 4,11 11)",
169 "polygon((0 0,0 10,10 10,10 0,0 0))",
170 0, 0, strategy);
171 }
172
173 //===========================================================================
174
175 template <typename Strategy>
test_distance_multipoint_ring(Strategy const & strategy)176 void test_distance_multipoint_ring(Strategy const& strategy)
177 {
178 #ifdef BOOST_GEOMETRY_TEST_DEBUG
179 std::cout << std::endl;
180 std::cout << "multipoint/ring distance tests" << std::endl;
181 #endif
182 typedef test_distance_of_geometries<multi_point_type, ring_type> tester;
183
184 tester::apply("multipoint(0 -20,0 -15)",
185 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
186 5, 25, strategy);
187
188 tester::apply("multipoint(16 0,12 0)",
189 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
190 2, 4, strategy);
191
192 tester::apply("multipoint(0 0,5 5,4 4)",
193 "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))",
194 0, 0, strategy);
195
196 // single-point ring
197 tester::apply("multipoint(0 0,5 5,4 4)",
198 "polygon((10 10))",
199 sqrt(50.0), 50, strategy);
200 }
201
202 //===========================================================================
203
204 template <typename Strategy>
test_distance_multipoint_multipolygon(Strategy const & strategy)205 void test_distance_multipoint_multipolygon(Strategy const& strategy)
206 {
207 #ifdef BOOST_GEOMETRY_TEST_DEBUG
208 std::cout << std::endl;
209 std::cout << "multipoint/multipolygon distance tests" << std::endl;
210 #endif
211 typedef test_distance_of_geometries
212 <
213 multi_point_type, multi_polygon_type
214 > tester;
215
216 tester::apply("multipoint(0 -20,0 -15)",
217 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
218 ((0 22,-1 30,2 40,0 22)))",
219 5, 25, strategy);
220
221 tester::apply("multipoint(16 0,12 0)",
222 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
223 ((20 -1,21 2,30 -10,20 -1)))",
224 2, 4, strategy);
225
226 tester::apply("multipoint(0 0,4 4,5 5)",
227 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\
228 ((20 -1,21 2,30 -10,20 -1)))",
229 0, 0, strategy);
230
231 tester::apply("multipoint(0 0,2 0)",
232 "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\
233 (-5 -5,-5 5,5 5,5 -5,-5 -5)),\
234 ((100 0,101 0,101 1,100 1,100 0)))",
235 3, 9, strategy);
236
237 tester::apply("MULTIPOINT(19 19,100 100)",
238 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),\
239 (4 4,4 6,6 6,6 4,4 4)), ((10 10,10 20,20 20,20 10,10 10),\
240 (14 14,14 16,16 16,16 14,14 14)))",
241 0, 0, strategy);
242 }
243
244 //===========================================================================
245
246 template <typename Strategy>
test_distance_point_box_2d(Strategy const & strategy)247 void test_distance_point_box_2d(Strategy const& strategy)
248 {
249 #ifdef BOOST_GEOMETRY_TEST_DEBUG
250 std::cout << std::endl;
251 std::cout << "2D point/box distance tests" << std::endl;
252 #endif
253 typedef test_distance_of_geometries<box_type, point_type> tester;
254
255 // point inside box
256 tester::apply("box(-1 -1,1 1)",
257 "point(0 0)", 0, 0, strategy);
258
259 // points on box corners
260 tester::apply("box(-1 -1,1 1)",
261 "point(-1 -1)", 0, 0, strategy);
262 tester::apply("box(-1 -1,1 1)",
263 "point(-1 1)", 0, 0, strategy);
264 tester::apply("box(-1 -1,1 1)",
265 "point(1 -1)", 0, 0, strategy);
266 tester::apply("box(-1 -1,1 1)",
267 "point(1 1)", 0, 0, strategy);
268
269 // points on box boundary edges
270 tester::apply("box(-1 -1,1 1)",
271 "point(0 -1)", 0, 0, strategy);
272 tester::apply("box(-1 -1,1 1)",
273 "point(-1 0)", 0, 0, strategy);
274 tester::apply("box(-1 -1,1 1)",
275 "point(1 0)", 0, 0, strategy);
276 tester::apply("box(-1 -1,1 1)",
277 "point(0 1)", 0, 0, strategy);
278
279 // points outside box
280 tester::apply("box(-1 -1,1 1)",
281 "point(0 4)", 3, 9, strategy);
282 tester::apply("box(-1 -1,1 1)",
283 "point(0.5 4)", 3, 9, strategy);
284 tester::apply("box(-1 -1,1 1)",
285 "point(-0.5 5)", 4, 16, strategy);
286 tester::apply("box(-1 -1,1 1)",
287 "point(3 0.25)", 2, 4, strategy);
288 tester::apply("box(-1 -1,1 1)",
289 "point(-3 -0.25)", 2, 4, strategy);
290 tester::apply("box(-1 -1,1 1)",
291 "point(3 5)", sqrt(20.0), 20, strategy);
292 tester::apply("box(-1 -1,1 1)",
293 "point(-5 -4)", 5, 25, strategy);
294 tester::apply("box(-1 -1,1 1)",
295 "point(2 -2)", sqrt(2.0), 2, strategy);
296 tester::apply("box(-1 -1,1 1)",
297 "point(-3 4)", sqrt(13.0), 13, strategy);
298 }
299
300 //===========================================================================
301
302 template <typename Strategy>
test_distance_point_box_different_point_types(Strategy const & strategy)303 void test_distance_point_box_different_point_types(Strategy const& strategy)
304 {
305 #ifdef BOOST_GEOMETRY_TEST_DEBUG
306 std::cout << std::endl;
307 std::cout << "2D point/box distance tests with different points"
308 << std::endl;
309 #endif
310 typedef point_type double_point;
311 typedef box_type double_box;
312 typedef bg::model::point<int,2,bg::cs::cartesian> int_point;
313 typedef bg::model::box<int_point> int_box;
314
315 test_distance_of_geometries
316 <
317 int_point, int_box
318 >::apply("point(0 0)",
319 "box(1 1, 2 2)",
320 sqrt(2.0), 2, strategy);
321
322 test_distance_of_geometries
323 <
324 double_point, int_box
325 >::apply("point(0.5 0)",
326 "box(1 -1,2 1)",
327 0.5, 0.25, strategy);
328
329 test_distance_of_geometries
330 <
331 double_point, double_box
332 >::apply("point(1.5 0)",
333 "box(1 -1,2 1)",
334 0, 0, strategy);
335
336 test_distance_of_geometries
337 <
338 double_point, int_box
339 >::apply("point(1.5 0)",
340 "box(1 -1,2 1)",
341 0, 0, strategy);
342
343 test_distance_of_geometries
344 <
345 int_point, double_box
346 >::apply("point(1 0)",
347 "box(0.5 -1,1.5 1)",
348 0, 0, strategy);
349
350 test_distance_of_geometries
351 <
352 int_point, double_box
353 >::apply("point(0 0)",
354 "box(0.5, -1,1.5, 1)",
355 0.5, 0.25, strategy);
356 }
357
358 //===========================================================================
359
360 template <typename Strategy>
test_distance_point_box_3d(Strategy const & strategy)361 void test_distance_point_box_3d(Strategy const& strategy)
362 {
363 #ifdef BOOST_GEOMETRY_TEST_DEBUG
364 std::cout << std::endl;
365 std::cout << "3D point/box distance tests" << std::endl;
366 #endif
367 typedef test_distance_of_geometries<box_type_3d, point_type_3d> tester;
368
369 // point inside box
370 tester::apply("box(-1 -1 -1,1 1 1)",
371 "point(0 0 0)", 0, 0, strategy);
372
373 // points on box corners
374 tester::apply("box(-1 -1 -1,1 1 1)",
375 "point(-1 -1 -1)", 0, 0, strategy);
376 tester::apply("box(-1 -1 -1,1 1 1)",
377 "point(-1 -1 1)", 0, 0, strategy);
378 tester::apply("box(-1 -1 -1,1 1 1)",
379 "point(-1 1 -1)", 0, 0, strategy);
380 tester::apply("box(-1 -1 -1,1 1 1)",
381 "point(-1 1 1)", 0, 0, strategy);
382 tester::apply("box(-1 -1 -1,1 1 1)",
383 "point(1 -1 -1)", 0, 0, strategy);
384 tester::apply("box(-1 -1 -1,1 1 1)",
385 "point(1 -1 1)", 0, 0, strategy);
386 tester::apply("box(-1 -1 -1,1 1 1)",
387 "point(1 1 -1)", 0, 0, strategy);
388 tester::apply("box(-1 -1 -1,1 1 1)",
389 "point(1 1 1)", 0, 0, strategy);
390
391 // points on box boundary edges
392 tester::apply("box(-1 -1 -1,1 1 1)",
393 "point(0 -1 -1)", 0, 0, strategy);
394 tester::apply("box(-1 -1 -1,1 1 1)",
395 "point(0 -1 1)", 0, 0, strategy);
396 tester::apply("box(-1 -1 -1,1 1 1)",
397 "point(0 1 -1)", 0, 0, strategy);
398 tester::apply("box(-1 -1 -1,1 1 1)",
399 "point(0 1 1)", 0, 0, strategy);
400
401 tester::apply("box(-1 -1 -1,1 1 1)",
402 "point(-1 0 -1)", 0, 0, strategy);
403 tester::apply("box(-1 -1 -1,1 1 1)",
404 "point(-1 0 1)", 0, 0, strategy);
405 tester::apply("box(-1 -1 -1,1 1 1)",
406 "point(1 0 -1)", 0, 0, strategy);
407 tester::apply("box(-1 -1 -1,1 1 1)",
408 "point(1 0 1)", 0, 0, strategy);
409
410 tester::apply("box(-1 -1 -1,1 1 1)",
411 "point(-1 -1 0)", 0, 0, strategy);
412 tester::apply("box(-1 -1 -1,1 1 1)",
413 "point(-1 1 0)", 0, 0, strategy);
414 tester::apply("box(-1 -1 -1,1 1 1)",
415 "point(1 -1 0)", 0, 0, strategy);
416 tester::apply("box(-1 -1 -1,1 1 1)",
417 "point(1 1 0)", 0, 0, strategy);
418
419 // point on box faces
420 tester::apply("box(-1 -1 -1,1 1 1)",
421 "point(0 0 -1)", 0, 0, strategy);
422 tester::apply("box(-1 -1 -1,1 1 1)",
423 "point(0 0 1)", 0, 0, strategy);
424 tester::apply("box(-1 -1 -1,1 1 1)",
425 "point(0 -1 0)", 0, 0, strategy);
426 tester::apply("box(-1 -1 -1,1 1 1)",
427 "point(0 1 0)", 0, 0, strategy);
428 tester::apply("box(-1 -1 -1,1 1 1)",
429 "point(-1 0 0)", 0, 0, strategy);
430 tester::apply("box(-1 -1 -1,1 1 1)",
431 "point(1 0 0)", 0, 0, strategy);
432
433 // points outside box -- closer to box corners
434 tester::apply("box(-1 -1 -1,1 1 1)",
435 "point(-2 -3 -4)", sqrt(14.0), 14, strategy);
436 tester::apply("box(-1 -1 -1,1 1 1)",
437 "point(-2 -3 3)", 3, 9, strategy);
438 tester::apply("box(-1 -1 -1,1 1 1)",
439 "point(-2 5 -2)", sqrt(18.0), 18, strategy);
440 tester::apply("box(-1 -1 -1,1 1 1)",
441 "point(-2 5 3)", sqrt(21.0), 21, strategy);
442 tester::apply("box(-1 -1 -1,1 1 1)",
443 "point(4 -6 -3)", sqrt(38.0), 38, strategy);
444 tester::apply("box(-1 -1 -1,1 1 1)",
445 "point(4 -6 4)", sqrt(43.0), 43, strategy);
446 tester::apply("box(-1 -1 -1,1 1 1)",
447 "point(4 7 -2)", sqrt(46.0), 46, strategy);
448 tester::apply("box(-1 -1 -1,1 1 1)",
449 "point(4 7 8)", sqrt(94.0), 94, strategy);
450
451
452 // points closer to box facets
453 tester::apply("box(-1 -1 -1,1 1 1)",
454 "point(0 0 10)", 9, 81, strategy);
455 tester::apply("box(-1 -1 -1,1 1 1)",
456 "point(0 0 -5)", 4, 16, strategy);
457 tester::apply("box(-1 -1 -1,1 1 1)",
458 "point(0 7 0)", 6, 36, strategy);
459 tester::apply("box(-1 -1 -1,1 1 1)",
460 "point(0 -6 0)", 5, 25, strategy);
461 tester::apply("box(-1 -1 -1,1 1 1)",
462 "point(4 0 0)", 3, 9, strategy);
463 tester::apply("box(-1 -1 -1,1 1 1)",
464 "point(-3 0 0)", 2, 4, strategy);
465
466 // points closer to box edges
467 tester::apply("box(-1 -1 -1,1 1 1)",
468 "point(0 -4 -5)", 5, 25, strategy);
469 tester::apply("box(-1 -1 -1,1 1 1)",
470 "point(0 -3 6)", sqrt(29.0), 29, strategy);
471 tester::apply("box(-1 -1 -1,1 1 1)",
472 "point(0 2 -7)", sqrt(37.0), 37, strategy);
473 tester::apply("box(-1 -1 -1,1 1 1)",
474 "point(0 8 7)", sqrt(85.0), 85, strategy);
475
476 tester::apply("box(-1 -1 -1,1 1 1)",
477 "point(-4 0 -4)", sqrt(18.0), 18, strategy);
478 tester::apply("box(-1 -1 -1,1 1 1)",
479 "point(-3 0 5)", sqrt(20.0), 20, strategy);
480 tester::apply("box(-1 -1 -1,1 1 1)",
481 "point(2 0 -6)", sqrt(26.0), 26, strategy);
482 tester::apply("box(-1 -1 -1,1 1 1)",
483 "point(8 0 6)", sqrt(74.0), 74, strategy);
484
485 tester::apply("box(-1 -1 -1,1 1 1)",
486 "point(-5 -5 0)", sqrt(32.0), 32, strategy);
487 tester::apply("box(-1 -1 -1,1 1 1)",
488 "point(-4 6 0)", sqrt(34.0), 34, strategy);
489 tester::apply("box(-1 -1 -1,1 1 1)",
490 "point(3 -7 0)", sqrt(40.0), 40, strategy);
491 tester::apply("box(-1 -1 -1,1 1 1)",
492 "point(9 7 0)", 10, 100, strategy);
493 }
494
495 //===========================================================================
496
497 template <typename Strategy>
test_distance_multipoint_box_2d(Strategy const & strategy)498 void test_distance_multipoint_box_2d(Strategy const& strategy)
499 {
500 #ifdef BOOST_GEOMETRY_TEST_DEBUG
501 std::cout << std::endl;
502 std::cout << "2D multipoint/box distance tests" << std::endl;
503 #endif
504 typedef test_distance_of_geometries<box_type, multi_point_type> tester;
505
506 // at least one point inside the box
507 tester::apply("box(0 0,10 10)",
508 "multipoint(0 0,-1 -1,20 20)",
509 0, 0, strategy);
510
511 tester::apply("box(0 0,10 10)",
512 "multipoint(1 1,-1 -1,20 20)",
513 0, 0, strategy);
514
515 tester::apply("box(0 0,10 10)",
516 "multipoint(1 1,2 2,3 3)",
517 0, 0, strategy);
518
519 // all points outside the box
520 tester::apply("box(0 0,10 10)",
521 "multipoint(-1 -1,20 20)",
522 sqrt(2.0), 2, strategy);
523
524 tester::apply("box(0 0,10 10)",
525 "multipoint(5 13, 50 50)",
526 3, 9, strategy);
527 }
528
529 //===========================================================================
530
531 template <typename Strategy>
test_distance_multipoint_box_3d(Strategy const & strategy)532 void test_distance_multipoint_box_3d(Strategy const& strategy)
533 {
534 #ifdef BOOST_GEOMETRY_TEST_DEBUG
535 std::cout << std::endl;
536 std::cout << "3D multipoint/box distance tests" << std::endl;
537 #endif
538 typedef test_distance_of_geometries
539 <
540 box_type_3d, multi_point_type_3d
541 > tester;
542
543 // at least one point inside the box
544 tester::apply("box(0 0 0,10 10 10)",
545 "multipoint(0 0 0,-1 -1 -1,20 20 20)",
546 0, 0, strategy);
547
548 tester::apply("box(0 0 0,10 10 10)",
549 "multipoint(1 1 1,-1 -1 -1,20 20 20)",
550 0, 0, strategy);
551
552 tester::apply("box(0 0 0,10 10 10)",
553 "multipoint(1 1 1,2 2 2,3 3 3)",
554 0, 0, strategy);
555
556 // all points outside the box
557 tester::apply("box(0 0 0,10 10 10)",
558 "multipoint(-1 -1 -1,20 20 20)",
559 sqrt(3.0), 3, strategy);
560
561 tester::apply("box(0 0 0,10 10 10)",
562 "multipoint(5 5 13,50 50 50)",
563 3, 9, strategy);
564 }
565
566 //===========================================================================
567
568 template <typename Point, typename Strategy>
test_more_empty_input_pointlike_areal(Strategy const & strategy)569 void test_more_empty_input_pointlike_areal(Strategy const& strategy)
570 {
571 #ifdef BOOST_GEOMETRY_TEST_DEBUG
572 std::cout << std::endl;
573 std::cout << "testing on empty inputs... " << std::flush;
574 #endif
575 bg::model::multi_point<Point> multipoint_empty;
576 bg::model::polygon<Point> polygon_empty;
577 bg::model::multi_polygon<bg::model::polygon<Point> > multipolygon_empty;
578 bg::model::ring<Point> ring_empty;
579
580 Point point = from_wkt<Point>("point(0 0)");
581 bg::model::polygon<Point> polygon =
582 from_wkt<bg::model::polygon<Point> >("polygon((0 0,1 0,0 1))");
583 bg::model::ring<Point> ring =
584 from_wkt<bg::model::ring<Point> >("polygon((0 0,1 0,0 1))");
585
586 // 1st geometry is empty
587 test_empty_input(multipoint_empty, polygon, strategy);
588 test_empty_input(multipoint_empty, ring, strategy);
589
590 // 2nd geometry is empty
591 test_empty_input(point, polygon_empty, strategy);
592 test_empty_input(point, multipolygon_empty, strategy);
593 test_empty_input(point, ring_empty, strategy);
594
595 // both geometries are empty
596 test_empty_input(multipoint_empty, polygon_empty, strategy);
597 test_empty_input(multipoint_empty, multipolygon_empty, strategy);
598 test_empty_input(multipoint_empty, ring_empty, strategy);
599
600 #ifdef BOOST_GEOMETRY_TEST_DEBUG
601 std::cout << "done!" << std::endl;
602 #endif
603 }
604
605 //===========================================================================
606
BOOST_AUTO_TEST_CASE(test_all_pointlike_polygon)607 BOOST_AUTO_TEST_CASE( test_all_pointlike_polygon )
608 {
609 test_distance_point_polygon(point_point_strategy()); // back-compatibility
610 test_distance_point_polygon(point_segment_strategy());
611 }
612
BOOST_AUTO_TEST_CASE(test_all_point_multipolygon)613 BOOST_AUTO_TEST_CASE( test_all_point_multipolygon )
614 {
615 test_distance_point_multipolygon(point_point_strategy()); // back-compatibility
616 test_distance_point_multipolygon(point_segment_strategy());
617 }
618
BOOST_AUTO_TEST_CASE(test_all_point_ring)619 BOOST_AUTO_TEST_CASE( test_all_point_ring )
620 {
621 test_distance_point_ring(point_point_strategy()); // back-compatibility
622 test_distance_point_ring(point_segment_strategy());
623 }
624
BOOST_AUTO_TEST_CASE(test_all_multipoint_polygon)625 BOOST_AUTO_TEST_CASE( test_all_multipoint_polygon )
626 {
627 test_distance_multipoint_polygon(point_point_strategy()); // back-compatibility
628 test_distance_multipoint_polygon(point_segment_strategy());
629 }
630
BOOST_AUTO_TEST_CASE(test_all_multipoint_multipolygon)631 BOOST_AUTO_TEST_CASE( test_all_multipoint_multipolygon )
632 {
633 test_distance_multipoint_multipolygon(point_point_strategy()); // back-compatibility
634 test_distance_multipoint_multipolygon(point_segment_strategy());
635 }
636
BOOST_AUTO_TEST_CASE(test_all_multipoint_ring)637 BOOST_AUTO_TEST_CASE( test_all_multipoint_ring )
638 {
639 test_distance_multipoint_ring(point_segment_strategy());
640 }
641
BOOST_AUTO_TEST_CASE(test_all_point_box_2d)642 BOOST_AUTO_TEST_CASE( test_all_point_box_2d )
643 {
644 point_box_strategy pb_strategy;
645
646 test_distance_point_box_2d(pb_strategy);
647 test_distance_point_box_different_point_types(pb_strategy);
648 }
649
BOOST_AUTO_TEST_CASE(test_all_point_box_3d)650 BOOST_AUTO_TEST_CASE( test_all_point_box_3d )
651 {
652 test_distance_point_box_3d(point_box_strategy());
653 }
654
BOOST_AUTO_TEST_CASE(test_all_multipoint_box_2d)655 BOOST_AUTO_TEST_CASE( test_all_multipoint_box_2d )
656 {
657 test_distance_multipoint_box_2d(point_box_strategy());
658 }
659
BOOST_AUTO_TEST_CASE(test_all_multipoint_box_3d)660 BOOST_AUTO_TEST_CASE( test_all_multipoint_box_3d )
661 {
662 test_distance_multipoint_box_3d(point_box_strategy());
663 }
664
BOOST_AUTO_TEST_CASE(test_all_empty_input_pointlike_areal)665 BOOST_AUTO_TEST_CASE( test_all_empty_input_pointlike_areal )
666 {
667 test_more_empty_input_pointlike_areal
668 <
669 point_type
670 >(point_segment_strategy());
671 }
672