1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2017-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_pointlike_areal
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 template
28 <
29 typename Point,
30 typename Strategy_pp,
31 typename Strategy_ps
32 >
test_distance_point_ring(Strategy_pp const & strategy_pp,Strategy_ps const & strategy_ps)33 void test_distance_point_ring(Strategy_pp const& strategy_pp,
34 Strategy_ps const& strategy_ps)
35 {
36
37 #ifdef BOOST_GEOMETRY_TEST_DEBUG
38 std::cout << std::endl;
39 std::cout << "point/ring distance tests" << std::endl;
40 #endif
41 typedef bg::model::ring<Point> ring_type;
42 typedef test_distance_of_geometries<Point, ring_type> tester;
43
44 std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
45
46 tester::apply("pr1", "POINT(0 10)", ring,
47 ps_distance<Point>("POINT(0 10)",
48 "SEGMENT(0 20, 10 10)", strategy_ps),
49 strategy_ps, true, true, false);
50 tester::apply("pr2", "POINT(10 0)", ring,
51 pp_distance<Point>("POINT(10 10)", "POINT(10 0)", strategy_pp),
52 strategy_ps, true, true, false);
53 tester::apply("pr3", "POINT(0 20)", ring,
54 0, strategy_ps, true, true, false);
55 tester::apply("pr4", "POINT(10 10)", ring,
56 0, strategy_ps, true, true, false);
57 tester::apply("pr4", "POINT(10 11)", ring,
58 0, strategy_ps, true, true, false);
59 }
60
61 //===========================================================================
62
63 template
64 <
65 typename Point,
66 typename Strategy_ps
67 >
test_distance_multipoint_ring(Strategy_ps const & strategy_ps)68 void test_distance_multipoint_ring(Strategy_ps const& strategy_ps)
69 {
70
71 #ifdef BOOST_GEOMETRY_TEST_DEBUG
72 std::cout << std::endl;
73 std::cout << "multipoint/ring distance tests" << std::endl;
74 #endif
75 typedef bg::model::ring<Point> ring_type;
76 typedef bg::model::multi_point<Point> multi_point_type;
77 typedef test_distance_of_geometries<multi_point_type, ring_type> tester;
78
79 std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
80
81 tester::apply("pr1", "MULTIPOINT(0 10,10 0,0 0)", ring,
82 ps_distance<Point>("POINT(0 10)",
83 "SEGMENT(0 20, 10 10)", strategy_ps),
84 strategy_ps, true, true, false);
85 }
86
87
88 //===========================================================================
89
90 template
91 <
92 typename Point,
93 typename Strategy_pp,
94 typename Strategy_ps
95 >
test_distance_point_polygon(Strategy_pp const & strategy_pp,Strategy_ps const & strategy_ps)96 void test_distance_point_polygon(Strategy_pp const& strategy_pp,
97 Strategy_ps const& strategy_ps)
98 {
99
100 #ifdef BOOST_GEOMETRY_TEST_DEBUG
101 std::cout << std::endl;
102 std::cout << "point/polygon distance tests" << std::endl;
103 #endif
104 typedef bg::model::polygon<Point> polygon_type;
105 typedef test_distance_of_geometries<Point, polygon_type> tester;
106
107 std::string const polygon =
108 "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
109
110 tester::apply("pr1", "POINT(0 10)", polygon,
111 ps_distance<Point>("POINT(0 10)",
112 "SEGMENT(0 20, 10 10)", strategy_ps),
113 strategy_ps, true, true, false);
114 tester::apply("pr2", "POINT(10 0)", polygon,
115 pp_distance<Point>("POINT(10 10)", "POINT(10 0)", strategy_pp),
116 strategy_ps, true, true, false);
117 tester::apply("pr3", "POINT(0 20)", polygon,
118 0, strategy_ps, true, true, false);
119 tester::apply("pr4", "POINT(10 10)", polygon,
120 0, strategy_ps, true, true, false);
121 tester::apply("pr5", "POINT(10 10.1)", polygon,
122 0, strategy_ps, false, false, false);
123 }
124
125 //===========================================================================
126
127 template
128 <
129 typename Point,
130 typename Strategy_pp,
131 typename Strategy_ps
132 >
test_distance_multipoint_polygon(Strategy_pp const & strategy_pp,Strategy_ps const & strategy_ps)133 void test_distance_multipoint_polygon(Strategy_pp const& strategy_pp,
134 Strategy_ps const& strategy_ps)
135 {
136
137 #ifdef BOOST_GEOMETRY_TEST_DEBUG
138 std::cout << std::endl;
139 std::cout << "multipoint/polygon distance tests" << std::endl;
140 #endif
141 typedef bg::model::polygon<Point> polygon_type;
142 typedef bg::model::multi_point<Point> multi_point_type;
143 typedef test_distance_of_geometries<multi_point_type, polygon_type> tester;
144
145 std::string const polygon = "POLYGON((10 10,0 20,15 30,20 15,15 10,10 10))";
146
147 tester::apply("mpp1", "MULTIPOINT(0 10,10 0,0 0)", polygon,
148 ps_distance<Point>("POINT(0 10)",
149 "SEGMENT(0 20, 10 10)", strategy_ps),
150 strategy_ps, true, true, false);
151
152 tester::apply("mpp2", "MULTIPOINT(0 10,10 0,0 0,20.1 15)", polygon,
153 pp_distance<Point>("POINT(20 15)",
154 "POINT(20.1 15)", strategy_pp),
155 strategy_ps, true, true, false);
156
157 tester::apply("mpp3", "MULTIPOINT(0 10,10 0,0 0,20.1 15,10 10)", polygon,
158 0, strategy_ps, true, true, false);
159
160 tester::apply("mpp4", "MULTIPOINT(0 10,10 0,0 0,20.1 15,10 11)", polygon,
161 0, strategy_ps, true, true, false);
162 }
163
164
165 //===========================================================================
166
167 template
168 <
169 typename Point,
170 typename Strategy_pp,
171 typename Strategy_ps
172 >
test_distance_point_multipolygon(Strategy_pp const & strategy_pp,Strategy_ps const & strategy_ps)173 void test_distance_point_multipolygon(Strategy_pp const& strategy_pp,
174 Strategy_ps const& strategy_ps)
175 {
176
177 #ifdef BOOST_GEOMETRY_TEST_DEBUG
178 std::cout << std::endl;
179 std::cout << "point/multipolygon distance tests" << std::endl;
180 #endif
181 typedef bg::model::polygon<Point> polygon_type;
182 typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
183 typedef test_distance_of_geometries<Point, multipolygon_type> tester;
184
185 std::string const mpoly = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
186 ((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
187
188 tester::apply("pmp1", "POINT(0 10)", mpoly,
189 ps_distance<Point>("POINT(0 10)",
190 "SEGMENT(0 20, 10 10)", strategy_ps),
191 strategy_ps, true, true, false);
192
193
194 tester::apply("pmp2", "POINT(10 9.9)", mpoly,
195 pp_distance<Point>("POINT(10 9.9)",
196 "POINT(10 10)", strategy_pp),
197 strategy_ps, true, true, false);
198
199 tester::apply("pmp3", "POINT(10 11)", mpoly,
200 0, strategy_ps, true, true, false);
201 }
202
203 //===========================================================================
204
205 template
206 <
207 typename Point,
208 typename Strategy_pp,
209 typename Strategy_ps
210 >
test_distance_multipoint_multipolygon(Strategy_pp const & strategy_pp,Strategy_ps const & strategy_ps)211 void test_distance_multipoint_multipolygon(Strategy_pp const& strategy_pp,
212 Strategy_ps const& strategy_ps)
213 {
214
215 #ifdef BOOST_GEOMETRY_TEST_DEBUG
216 std::cout << std::endl;
217 std::cout << "multipoint/multipolygon distance tests" << std::endl;
218 #endif
219 typedef bg::model::polygon<Point> polygon_type;
220 typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
221 typedef bg::model::multi_point<Point> multi_point_type;
222 typedef test_distance_of_geometries<multi_point_type, multipolygon_type> tester;
223
224 std::string const mpoly = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
225 ((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
226
227 tester::apply("pr1", "MULTIPOINT(0 10,10 0,0 0)", mpoly,
228 ps_distance<Point>("POINT(0 10)",
229 "SEGMENT(0 20, 10 10)", strategy_ps),
230 strategy_ps, true, true, false);
231
232 tester::apply("pmp2", "MULTIPOINT(0 10,10 0,0 0,10 9.9)", mpoly,
233 pp_distance<Point>("POINT(10 9.9)",
234 "POINT(10 10)", strategy_pp),
235 strategy_ps, true, true, false);
236
237 tester::apply("pmp3", "MULTIPOINT(0 10,10 0,0 0,10 9.9,10 11)", mpoly,
238 0, strategy_ps, true, true, false);
239 }
240
241
242 //===========================================================================
243 // Cases for relative location of a point wrt to a box
244 //
245 // | |
246 // | 3 |
247 // | |
248 // +---------+
249 // | |
250 // 1 | 5 | 2
251 // | |
252 // +---------+
253 // | |
254 // | 4 |
255 // | |
256 //
257 // and also the following cases
258 //
259 // | |
260 // A B
261 // | |
262 // +----C----+
263 // | |
264 // D E
265 // | |
266 // +----F----+
267 // | |
268 // G H
269 // | |
270 //
271 // and finally we have the corners
272 //
273 // | |
274 // | |
275 // | |
276 // a---------b
277 // | |
278 // | |
279 // | |
280 // c---------d
281 // | |
282 // | |
283 // | |
284 //
285 // for each relative position we also have to test the shifted point
286 // (this is due to the fact that boxes have longitudes in the
287 // range [-180, 540)
288 //===========================================================================
289
290 template
291 <
292 typename Point,
293 typename Strategy_pp,
294 typename Strategy_ps,
295 typename Strategy_pb
296 >
test_distance_point_box(Strategy_pp const & strategy_pp,Strategy_ps const & strategy_ps,Strategy_pb const & strategy_pb)297 void test_distance_point_box(Strategy_pp const& strategy_pp,
298 Strategy_ps const& strategy_ps,
299 Strategy_pb const& strategy_pb)
300 {
301
302 #ifdef BOOST_GEOMETRY_TEST_DEBUG
303 std::cout << std::endl;
304 std::cout << "point/box distance tests" << std::endl;
305 #endif
306 typedef bg::model::box<Point> box_type;
307 typedef test_distance_of_geometries<Point, box_type> tester;
308
309 std::string const box1 = "BOX(10 10,20 20)";
310
311 // case 1
312 tester::apply("pb1-1a", "POINT(5 25)", box1,
313 pp_distance<Point>("POINT(5 25)", "POINT(10 20)", strategy_pp),
314 strategy_pb);
315
316 // case 1
317 tester::apply("pb1-1b", "POINT(3 12)", box1,
318 ps_distance<Point>("POINT(3 12)",
319 "SEGMENT(10 10,10 20)", strategy_ps),
320 strategy_pb);
321
322 // case 1
323 tester::apply("pb1-1c", "POINT(3 17)", box1,
324 ps_distance<Point>("POINT(3 17)",
325 "SEGMENT(10 10,10 20)", strategy_ps),
326 strategy_pb);
327
328 // case 1
329 tester::apply("pb1-1d", "POINT(5 4)", box1,
330 pp_distance<Point>("POINT(5 4)", "POINT(10 10)", strategy_pp),
331 strategy_pb);
332
333 // case 1
334 tester::apply("pb1-1e", "POINT(-100 20)", box1,
335 pp_distance<Point>("POINT(-100 20)",
336 "POINT(10 20)", strategy_pp),
337 strategy_pb);
338
339 // case 1
340 tester::apply("pb1-1g", "POINT(-100 10)", box1,
341 ps_distance<Point>("POINT(-100 10)",
342 "SEGMENT(10 10,10 20)", strategy_ps),
343 strategy_pb);
344
345 // case 2
346 tester::apply("pb1-2a", "POINT(31 25)", box1,
347 pp_distance<Point>("POINT(31 25)",
348 "POINT(20 20)", strategy_pp),
349 strategy_pb);
350
351 // case 2
352 tester::apply("pb1-2b", "POINT(23 17)", box1,
353 ps_distance<Point>("POINT(23 17)",
354 "SEGMENT(20 10,20 20)", strategy_ps),
355 strategy_pb);
356
357 // case 2
358 tester::apply("pb1-2c", "POINT(29 3)", box1,
359 pp_distance<Point>("POINT(29 3)",
360 "POINT(20 10)", strategy_pp),
361 strategy_pb);
362
363 // case 2
364 tester::apply("pb1-2d", "POINT(131 65)", box1,
365 pp_distance<Point>("POINT(131 65)",
366 "POINT(20 20)", strategy_pp),
367 strategy_pb);
368
369 // case 2
370 tester::apply("pb1-2e", "POINT(110 10)", box1,
371 ps_distance<Point>("POINT(110 10)",
372 "SEGMENT(20 10,20 20)", strategy_ps),
373 strategy_pb);
374
375 // case 2
376 tester::apply("pb1-2f", "POINT(150 20)", box1,
377 pp_distance<Point>("POINT(150 20)",
378 "POINT(20 20)", strategy_pp),
379 strategy_pb);
380
381 // case 3
382 tester::apply("pb1-3a", "POINT(11 25)", box1,
383 pp_distance<Point>("POINT(11 25)",
384 "POINT(11 20)", strategy_pp),
385 strategy_pb);
386
387 // case 3
388 tester::apply("pb1-3b", "POINT(15 25)", box1,
389 pp_distance<Point>("POINT(15 25)",
390 "POINT(15 20)", strategy_pp),
391 strategy_pb);
392
393 // case 3
394 tester::apply("pb1-3c", "POINT(18 25)", box1,
395 pp_distance<Point>("POINT(18 25)",
396 "POINT(18 20)", strategy_pp),
397 strategy_pb);
398
399 // case 4
400 tester::apply("pb1-4a", "POINT(13 4)", box1,
401 pp_distance<Point>("POINT(13 4)",
402 "POINT(13 10)", strategy_pp),
403 strategy_pb);
404
405 // case 4
406 tester::apply("pb1-4b", "POINT(19 4)", box1,
407 pp_distance<Point>("POINT(19 4)",
408 "POINT(19 10)", strategy_pp),
409 strategy_pb);
410
411 // case 5
412 tester::apply("pb1-5", "POINT(15 14)", box1, 0, strategy_pb);
413
414 // case A
415 tester::apply("pb1-A", "POINT(10 28)", box1,
416 pp_distance<Point>("POINT(10 28)",
417 "POINT(10 20)", strategy_pp),
418 strategy_pb);
419
420 // case B
421 tester::apply("pb1-B", "POINT(20 28)", box1,
422 pp_distance<Point>("POINT(20 28)",
423 "POINT(20 20)", strategy_pp),
424 strategy_pb);
425
426
427 // case C
428 tester::apply("pb1-C", "POINT(14 20)", box1, 0, strategy_pb);
429
430 // case D
431 tester::apply("pb1-D", "POINT(10 17)", box1, 0, strategy_pb);
432
433 // case E
434 tester::apply("pb1-E", "POINT(20 11)", box1, 0, strategy_pb);
435
436 // case F
437 tester::apply("pb1-F", "POINT(19 10)", box1, 0, strategy_pb);
438
439 // case G
440 tester::apply("pb1-G", "POINT(10 -40)", box1,
441 pp_distance<Point>("POINT(10 -40)",
442 "POINT(10 10)", strategy_pp),
443 strategy_pb);
444
445 // case H
446 tester::apply("pb1-H", "POINT(20 -50)", box1,
447 pp_distance<Point>("POINT(20 -50)",
448 "POINT(20 10)", strategy_pp),
449 strategy_pb);
450
451 // case a
452 tester::apply("pb1-a", "POINT(10 20)", box1, 0, strategy_pb);
453 // case b
454 tester::apply("pb1-b", "POINT(20 20)", box1, 0, strategy_pb);
455 // case c
456 tester::apply("pb1-c", "POINT(10 10)", box1, 0, strategy_pb);
457 // case d
458 tester::apply("pb1-d", "POINT(20 10)", box1, 0, strategy_pb);
459
460
461 std::string const box2 = "BOX(170 -60,400 80)";
462
463 // case 1 - point is closer to western meridian
464 tester::apply("pb2-1a", "POINT(160 0)", box2,
465 ps_distance<Point>("POINT(160 0)",
466 "SEGMENT(170 -60,170 80)", strategy_ps),
467 strategy_pb);
468
469 // case 1 - point is closer to eastern meridian
470 tester::apply("pb2-1b", "POINT(50 0)", box2,
471 ps_distance<Point>("POINT(50 0)",
472 "SEGMENT(40 -60,40 80)", strategy_ps),
473 strategy_pb);
474
475 // case 3 - equivalent point POINT(390 85) is above the box
476 tester::apply("pb2-3", "POINT(30 85)", box2,
477 pp_distance<Point>("POINT(30 85)",
478 "POINT(30 80)", strategy_pp),
479 strategy_pb);
480
481 // case 4 - equivalent point POINT(390 -75) is below the box
482 tester::apply("pb2-4", "POINT(30 -75)", box2,
483 pp_distance<Point>("POINT(30 -75)",
484 "POINT(30 -60)", strategy_pp),
485 strategy_pb);
486
487 // case 5 - equivalent point POINT(390 0) is inside box
488 tester::apply("pb2-5", "POINT(30 0)", box2, 0, strategy_pb);
489
490
491 std::string const box3 = "BOX(-150 -50,-40 70)";
492
493 // case 1 - point is closer to western meridian
494 tester::apply("pb3-1a", "POINT(-170 10)", box3,
495 ps_distance<Point>("POINT(-170 10)",
496 "SEGMENT(-150 -50,-150 70)", strategy_ps),
497 strategy_pb);
498
499 // case 2 - point is closer to eastern meridian
500 tester::apply("pb3-2a", "POINT(5 10)", box3,
501 ps_distance<Point>("POINT(5 10)",
502 "SEGMENT(-40 -50,-40 70)", strategy_ps),
503 strategy_pb);
504
505 // case 2 - point is closer to western meridian
506 tester::apply("pb3-2a", "POINT(160 10)", box3,
507 ps_distance<Point>("POINT(160 10)",
508 "SEGMENT(-150 -50,-150 70)", strategy_ps),
509 strategy_pb);
510
511 // case 2 - point is at equal distance from eastern and western meridian
512 tester::apply("pb3-2c1", "POINT(85 20)", box3,
513 ps_distance<Point>("POINT(85 20)",
514 "SEGMENT(-150 -50,-150 70)", strategy_ps),
515 strategy_pb);
516
517 // case 2 - point is at equal distance from eastern and western meridian
518 tester::apply("pb3-2c2", "POINT(85 20)", box3,
519 ps_distance<Point>("POINT(85 20)",
520 "SEGMENT(-40 -50,-40 70)", strategy_ps),
521 strategy_pb);
522
523 // box that is symmetric wrt the prime meridian
524 std::string const box4 = "BOX(-75 -45,75 65)";
525
526 // case 1 - point is closer to western meridian
527 tester::apply("pb4-1a", "POINT(-100 10)", box4,
528 ps_distance<Point>("POINT(-100 10)",
529 "SEGMENT(-75 -45,-75 65)", strategy_ps),
530 strategy_pb);
531
532 // case 2 - point is closer to eastern meridian
533 tester::apply("pb4-2a", "POINT(90 15)", box4,
534 ps_distance<Point>("POINT(90 15)",
535 "SEGMENT(75 -45,75 65)", strategy_ps),
536 strategy_pb);
537
538 // case 2 - point is at equal distance from eastern and western meridian
539 tester::apply("pb4-2c1", "POINT(-180 20)", box4,
540 ps_distance<Point>("POINT(-180 20)",
541 "SEGMENT(-75 -45,-75 65)", strategy_ps),
542 strategy_pb);
543
544 // case 2 - point is at equal distance from eastern and western meridian
545 tester::apply("pb4-2c2", "POINT(-180 20)", box4,
546 ps_distance<Point>("POINT(-180 20)",
547 "SEGMENT(75 -45,75 65)", strategy_ps),
548 strategy_pb);
549
550
551 //box degenerates to a meridian segment
552 std::string const boxdeg1 = "BOX(0 10,0 20)";
553
554 tester::apply("pbd1", "POINT(1 10)", boxdeg1,
555 ps_distance<Point>("POINT(1 10)",
556 "SEGMENT(0 10, 0 20)", strategy_ps),
557 strategy_pb);
558 tester::apply("pbd2", "POINT(1 5)", boxdeg1,
559 ps_distance<Point>("POINT(1 5)",
560 "SEGMENT(0 10, 0 20)", strategy_ps),
561 strategy_pb);
562 tester::apply("pbd3", "POINT(1 15)", boxdeg1,
563 ps_distance<Point>("POINT(1 15)",
564 "SEGMENT(0 10, 0 20)", strategy_ps),
565 strategy_pb);
566 tester::apply("pbd4", "POINT(1 25)", boxdeg1,
567 ps_distance<Point>("POINT(1 25)",
568 "SEGMENT(0 10, 0 20)", strategy_ps),
569 strategy_pb);
570
571 //box degenerates to a horizontal line; that is not a geodesic segment
572 std::string const boxdeg2 = "BOX(10 10,20 10)";
573
574 tester::apply("pbd5", "POINT(15 15)", boxdeg2,
575 pp_distance<Point>("POINT(15 15)",
576 "POINT(15 10)", strategy_pp),
577 strategy_pb);
578 tester::apply("pbd6", "POINT(5 15)", boxdeg2,
579 pp_distance<Point>("POINT(5 15)",
580 "POINT(10 10)", strategy_pp),
581 strategy_pb);
582 tester::apply("pbd7", "POINT(25 15)", boxdeg2,
583 pp_distance<Point>("POINT(25 15)",
584 "POINT(20 10)", strategy_pp),
585 strategy_pb);
586
587 //box degenerates to a point
588 std::string const boxdeg3 = "BOX(0 10,0 10)";
589
590 tester::apply("pbd8", "POINT(1 11)", boxdeg3,
591 pp_distance<Point>("POINT(1 11)",
592 "POINT(0 10)", strategy_pp),
593 strategy_pb);
594 }
595
596 template
597 <
598 typename Point,
599 typename Strategy_pp,
600 typename Strategy_ps,
601 typename Strategy_pb
602 >
test_distance_multipoint_box(Strategy_pp const & strategy_pp,Strategy_ps const & strategy_ps,Strategy_pb const & strategy_pb)603 void test_distance_multipoint_box(Strategy_pp const& strategy_pp,
604 Strategy_ps const& strategy_ps,
605 Strategy_pb const& strategy_pb)
606 {
607
608 #ifdef BOOST_GEOMETRY_TEST_DEBUG
609 std::cout << std::endl;
610 std::cout << "multipoint/box distance tests" << std::endl;
611 #endif
612 typedef bg::model::box<Point> box_type;
613 typedef bg::model::multi_point<Point> multi_point_type;
614 typedef test_distance_of_geometries<multi_point_type, box_type> tester;
615
616 std::string const box1 = "BOX(10 10,20 20)";
617
618 tester::apply("mpb1", "MULTIPOINT(5 25,25 26)", box1,
619 pp_distance<Point>("POINT(5 25)", "POINT(10 20)", strategy_pp),
620 strategy_pb, true, false, false);
621
622 tester::apply("mpb2", "MULTIPOINT(110 10,110 9,110 0)", box1,
623 ps_distance<Point>("POINT(110 10)",
624 "SEGMENT(20 10,20 20)", strategy_ps),
625 strategy_pb, true, false, false);
626
627 tester::apply("mpb3", "MULTIPOINT(110 10,110 9,110 0,10 20)", box1,
628 0, strategy_pb, true, false, false);
629
630 tester::apply("mpb3", "MULTIPOINT(110 10,110 9,110 0,15 15)", box1,
631 0, strategy_pb, true, false, false);
632 }
633
634 //===========================================================================
635 //===========================================================================
636 //===========================================================================
637
638 template
639 <
640 typename Point,
641 typename Strategy_pp,
642 typename Strategy_ps,
643 typename Strategy_pb
644 >
test_all_pl_ar(Strategy_pp pp_strategy,Strategy_ps ps_strategy,Strategy_pb pb_strategy)645 void test_all_pl_ar(Strategy_pp pp_strategy,
646 Strategy_ps ps_strategy,
647 Strategy_pb pb_strategy)
648 {
649 test_distance_point_ring<Point>(pp_strategy, ps_strategy);
650 test_distance_multipoint_ring<Point>(ps_strategy);
651
652 test_distance_point_polygon<Point>(pp_strategy, ps_strategy);
653 test_distance_multipoint_polygon<Point>(pp_strategy, ps_strategy);
654
655 test_distance_point_multipolygon<Point>(pp_strategy, ps_strategy);
656 test_distance_multipoint_multipolygon<Point>(pp_strategy, ps_strategy);
657
658 test_distance_point_box<Point>(pp_strategy, ps_strategy, pb_strategy);
659 test_distance_multipoint_box<Point>(pp_strategy, ps_strategy, pb_strategy);
660
661 test_more_empty_input_pointlike_areal<Point>(ps_strategy);
662 }
663
BOOST_AUTO_TEST_CASE(test_all_pointlike_areal)664 BOOST_AUTO_TEST_CASE( test_all_pointlike_areal )
665 {
666 typedef bg::model::point
667 <
668 double, 2,
669 bg::cs::spherical_equatorial<bg::degree>
670 > sph_point;
671
672 test_all_pl_ar<sph_point>(spherical_pp(), spherical_ps(), spherical_pb());
673
674 typedef bg::model::point
675 <
676 double, 2,
677 bg::cs::geographic<bg::degree>
678 > geo_point;
679
680 test_all_pl_ar<geo_point>(vincenty_pp(), vincenty_ps(), vincenty_pb());
681 test_all_pl_ar<geo_point>(thomas_pp(), thomas_ps(), thomas_pb());
682 test_all_pl_ar<geo_point>(andoyer_pp(), andoyer_ps(), andoyer_pb());
683
684 // test with different spheroid
685 stype spheroid(6372000, 6370000);
686 test_all_pl_ar<geo_point>(andoyer_pp(spheroid), andoyer_ps(spheroid), andoyer_pb(spheroid));
687 }
688