]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/distance/distance_geo_pl_l.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / distance / distance_geo_pl_l.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2016-2017, 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 #ifndef BOOST_TEST_MODULE
12 #define BOOST_TEST_MODULE test_distance_geographic_pl_l
13 #endif
14
15 #include <boost/geometry/core/srs.hpp>
16 #include <boost/test/included/unit_test.hpp>
17
18 #include "test_distance_geo_common.hpp"
19
20 typedef bg::cs::geographic<bg::degree> cs_type;
21 typedef bg::model::point<double, 2, cs_type> point_type;
22 typedef bg::model::segment<point_type> segment_type;
23 typedef bg::model::multi_point<point_type> multi_point_type;
24 typedef bg::model::segment<point_type> segment_type;
25 typedef bg::model::linestring<point_type> linestring_type;
26 typedef bg::model::multi_linestring<linestring_type> multi_linestring_type;
27
28 namespace services = bg::strategy::distance::services;
29 typedef bg::default_distance_result<point_type>::type return_type;
30
31 typedef bg::srs::spheroid<double> stype;
32
33 // Strategies for point-point distance
34
35 typedef bg::strategy::distance::andoyer<stype> andoyer_pp;
36 typedef bg::strategy::distance::thomas<stype> thomas_pp;
37 typedef bg::strategy::distance::vincenty<stype> vincenty_pp;
38
39 // Strategies for point-segment distance
40
41 typedef bg::strategy::distance::geographic_cross_track<bg::strategy::andoyer, stype, double>
42 andoyer_strategy;
43
44 typedef bg::strategy::distance::geographic_cross_track<bg::strategy::thomas, stype, double>
45 thomas_strategy;
46
47 typedef bg::strategy::distance::geographic_cross_track<bg::strategy::vincenty, stype, double>
48 vincenty_strategy;
49
50 //===========================================================================
51
52 template <typename Strategy>
53 inline bg::default_distance_result<point_type>::type
54 pp_distance(std::string const& wkt1,
55 std::string const& wkt2,
56 Strategy const& strategy)
57 {
58 point_type p1, p2;
59 bg::read_wkt(wkt1, p1);
60 bg::read_wkt(wkt2, p2);
61 return bg::distance(p1, p2, strategy);
62 }
63
64 template <typename Strategy>
65 inline bg::default_distance_result<point_type>::type
66 ps_distance(std::string const& wkt1,
67 std::string const& wkt2,
68 Strategy const& strategy)
69 {
70 point_type p;
71 segment_type s;
72 bg::read_wkt(wkt1, p);
73 bg::read_wkt(wkt2, s);
74 return bg::distance(p, s, strategy);
75 }
76
77 //===========================================================================
78
79 template <typename Strategy_pp, typename Strategy_ps>
80 void test_distance_point_segment(Strategy_pp const& strategy_pp,
81 Strategy_ps const& strategy_ps)
82 {
83
84 #ifdef BOOST_GEOMETRY_TEST_DEBUG
85 std::cout << std::endl;
86 std::cout << "point/segment distance tests" << std::endl;
87 #endif
88 typedef test_distance_of_geometries<point_type, segment_type> tester;
89
90 tester::apply("p-s-01",
91 "POINT(0 0)",
92 "SEGMENT(2 0,3 0)",
93 pp_distance("POINT(0 0)", "POINT(2 0)", strategy_pp),
94 strategy_ps);
95 tester::apply("p-s-02",
96 "POINT(2.5 3)",
97 "SEGMENT(2 0,3 0)",
98 pp_distance("POINT(2.5 3)", "POINT(2.49777 0)", strategy_pp),
99 strategy_ps);
100 tester::apply("p-s-03",
101 "POINT(2 0)",
102 "SEGMENT(2 0,3 0)",
103 0,
104 strategy_ps);
105 tester::apply("p-s-04",
106 "POINT(3 0)",
107 "SEGMENT(2 0,3 0)",
108 0,
109 strategy_ps);
110 tester::apply("p-s-05",
111 "POINT(2.5 0)",
112 "SEGMENT(2 0,3 0)",
113 0,
114 strategy_ps);
115 tester::apply("p-s-06",
116 "POINT(3.5 3)",
117 "SEGMENT(2 0,3 0)",
118 pp_distance("POINT(3 0)", "POINT(3.5 3)", strategy_pp),
119 strategy_ps);
120 tester::apply("p-s-07",
121 "POINT(15 80)",
122 "SEGMENT(10 15,30 15)",
123 7204174.8264546748,
124 strategy_ps);
125 tester::apply("p-s-08",
126 "POINT(15 10)",
127 "SEGMENT(10 15,30 15)",
128 571412.71247283253,
129 strategy_ps);
130 tester::apply("p-s-09",
131 "POINT(5 10)",
132 "SEGMENT(10 15,30 15)",
133 pp_distance("POINT(5 10)", "POINT(10 15)", strategy_pp),
134 strategy_ps);
135 tester::apply("p-s-10",
136 "POINT(35 10)",
137 "SEGMENT(10 15,30 15)",
138 pp_distance("POINT(35 10)", "POINT(30 15)", strategy_pp),
139 strategy_ps);
140 tester::apply("p-s-11",
141 "POINT(5 10)",
142 "SEGMENT(30 15,10 15)",
143 pp_distance("POINT(5 10)", "POINT(10 15)", strategy_pp),
144 strategy_ps);
145 tester::apply("p-s-12",
146 "POINT(35 10)",
147 "SEGMENT(30 15,10 15)",
148 pp_distance("POINT(35 10)", "POINT(30 15)", strategy_pp),
149 strategy_ps);
150
151 tester::apply("p-s-right-up",
152 "POINT(3.5 3)",
153 "SEGMENT(2 2,3 2)",
154 pp_distance("POINT(3 2)", "POINT(3.5 3)", strategy_pp),
155 strategy_ps);
156
157 tester::apply("p-s-left-up",
158 "POINT(1.5 3)",
159 "SEGMENT(2 2,3 2)",
160 pp_distance("POINT(2 2)", "POINT(1.5 3)", strategy_pp),
161 strategy_ps);
162
163 tester::apply("p-s-up-1",
164 "POINT(2 3)",
165 "SEGMENT(2 2,3 2)",
166 pp_distance("POINT(2.0003 2)", "POINT(2 3)", strategy_pp),
167 strategy_ps);
168
169 tester::apply("p-s-up-2",
170 "POINT(3 3)",
171 "SEGMENT(2 2,3 2)",
172 pp_distance("POINT(2.9997 2)", "POINT(3 3)", strategy_pp),
173 strategy_ps);
174
175 tester::apply("p-s-right-down",
176 "POINT(3.5 1)",
177 "SEGMENT(2 2,3 2)",
178 pp_distance("POINT(3 2)", "POINT(3.5 1)", strategy_pp),
179 strategy_ps);
180
181 tester::apply("p-s-left-down",
182 "POINT(1.5 1)",
183 "SEGMENT(2 2,3 2)",
184 pp_distance("POINT(2 2)", "POINT(1.5 1)", strategy_pp),
185 strategy_ps);
186
187 tester::apply("p-s-down-1",
188 "POINT(2 1)",
189 "SEGMENT(2 2,3 2)",
190 pp_distance("POINT(2.0003 2)", "POINT(2 1)", strategy_pp),
191 strategy_ps);
192
193 tester::apply("p-s-down-2",
194 "POINT(3 1)",
195 "SEGMENT(2 2,3 2)",
196 pp_distance("POINT(2.9997 2)", "POINT(3 1)", strategy_pp),
197 strategy_ps);
198
199 tester::apply("p-s-south",
200 "POINT(3 -1)",
201 "SEGMENT(2 -2,3 -2)",
202 pp_distance("POINT(2.9997 -2)", "POINT(3 -1)", strategy_pp),
203 strategy_ps);
204
205 tester::apply("p-s-antimeridian-1",
206 "POINT(3 1)",
207 "SEGMENT(220 2,3 2)",
208 pp_distance("POINT(3 2)", "POINT(3 1)", strategy_pp),
209 strategy_ps);
210
211 tester::apply("p-s-antimeridian-2",
212 "POINT(220 1)",
213 "SEGMENT(220 2,3 2)",
214 pp_distance("POINT(220 2)", "POINT(220 1)", strategy_pp),
215 strategy_ps);
216
217 // equator special case
218 tester::apply("p-s-eq1",
219 "POINT(2.5 0)",
220 "SEGMENT(2 0,3 0)",
221 0,
222 strategy_ps);
223 tester::apply("p-s-eq2",
224 "POINT(2.5 2)",
225 "SEGMENT(2 0,3 0)",
226 pp_distance("POINT(2.5 0)", "POINT(2.5 2)", strategy_pp),
227 strategy_ps);
228 tester::apply("p-s-eq3",
229 "POINT(2 2)",
230 "SEGMENT(2 0,3 0)",
231 pp_distance("POINT(2 0)", "POINT(2 2)", strategy_pp),
232 strategy_ps);
233 tester::apply("p-s-eq4",
234 "POINT(3 2)",
235 "SEGMENT(2 0,3 0)",
236 pp_distance("POINT(3 0)", "POINT(3 2)", strategy_pp),
237 strategy_ps);
238
239 // meridian special case
240 tester::apply("p-s-mer1",
241 "POINT(2.5 2)",
242 "SEGMENT(2 2,2 4)",
243 pp_distance("POINT(2.5 2)", "POINT(2 2)", strategy_pp),
244 strategy_ps);
245 tester::apply("p-s-mer3",
246 "POINT(2.5 5)",
247 "SEGMENT(2 2,2 4)",
248 pp_distance("POINT(2.5 5)", "POINT(2 4)", strategy_pp),
249 strategy_ps);
250
251 //degenerate segment
252 tester::apply("p-s-deg",
253 "POINT(1 80)",
254 "SEGMENT(0 0,0 0)",
255 pp_distance("POINT(0 0)", "POINT(1 80)", strategy_pp),
256 strategy_ps);
257
258 //point on segment
259 tester::apply("p-s-deg",
260 "POINT(0 80)",
261 "SEGMENT(0 0,0 90)",
262 0,
263 strategy_ps);
264
265 // very small distances to segment
266 tester::apply("p-s-07",
267 "POINT(90 1e-3)",
268 "SEGMENT(0.5 0,175.5 0)",
269 pp_distance("POINT(90 0)", "POINT(90 1e-3)", strategy_pp),
270 strategy_ps);
271 tester::apply("p-s-08",
272 "POINT(90 1e-4)",
273 "SEGMENT(0.5 0,175.5 0)",
274 pp_distance("POINT(90 0)", "POINT(90 1e-4)", strategy_pp),
275 strategy_ps);
276 tester::apply("p-s-09",
277 "POINT(90 1e-5)",
278 "SEGMENT(0.5 0,175.5 0)",
279 pp_distance("POINT(90 0)", "POINT(90 1e-5)", strategy_pp),
280 strategy_ps);
281 tester::apply("p-s-10",
282 "POINT(90 1e-6)",
283 "SEGMENT(0.5 0,175.5 0)",
284 pp_distance("POINT(90 0)", "POINT(90 1e-6)", strategy_pp),
285 strategy_ps);
286 tester::apply("p-s-11",
287 "POINT(90 1e-7)",
288 "SEGMENT(0.5 0,175.5 0)",
289 pp_distance("POINT(90 0)", "POINT(90 1e-7)", strategy_pp),
290 strategy_ps);
291 tester::apply("p-s-12",
292 "POINT(90 1e-8)",
293 "SEGMENT(0.5 0,175.5 0)",
294 pp_distance("POINT(90 0)", "POINT(90 1e-8)", strategy_pp),
295 strategy_ps);
296
297 // very large distance to segment
298 tester::apply("p-s-13",
299 "POINT(90 90)",
300 "SEGMENT(0.5 0,175.5 0)",
301 pp_distance("POINT(90 0)", "POINT(90 90)", strategy_pp),
302 strategy_ps);
303 tester::apply("p-s-14",
304 "POINT(90 90)",
305 "SEGMENT(0.5 -89,175.5 -89)",
306 pp_distance("POINT(90 -89)", "POINT(90 90)", strategy_pp),
307 strategy_ps);
308 // degenerate segment
309 tester::apply("p-s-15",
310 "POINT(90 90)",
311 "SEGMENT(0.5 -90,175.5 -90)",
312 pp_distance("POINT(0.5 -90)", "POINT(90 90)", strategy_pp),
313 strategy_ps);
314 tester::apply("p-s-16",
315 "POINT(90 90)",
316 "SEGMENT(0.5 -90,175.5 -90)",
317 pp_distance("POINT(90 -90)", "POINT(90 90)", strategy_pp),
318 strategy_ps);
319 // equatorial segment
320 tester::apply("p-s-17",
321 "POINT(90 90)",
322 "SEGMENT(0 0,175.5 0)",
323 pp_distance("POINT(90 90)", "POINT(0 0)", strategy_pp),
324 strategy_ps);
325 // segment pass by pole
326 tester::apply("p-s-18",
327 "POINT(90 90)",
328 "SEGMENT(0 0,180 0)",
329 0,
330 strategy_ps);
331
332 }
333
334 template <typename Strategy_pp, typename Strategy_ps>
335 void test_distance_point_segment_no_thomas(Strategy_pp const& strategy_pp,
336 Strategy_ps const& strategy_ps)
337 {
338
339 #ifdef BOOST_GEOMETRY_TEST_DEBUG
340 std::cout << std::endl;
341 std::cout << "point/segment distance tests" << std::endl;
342 #endif
343 typedef test_distance_of_geometries<point_type, segment_type> tester;
344
345 // thomas strategy is failing for those test cases
346
347 // meridian special case
348 tester::apply("p-s-mer2",
349 "POINT(2.5 3)",
350 "SEGMENT(2 2,2 4)",
351 pp_distance("POINT(2.5 3)", "POINT(2 3.000114792872075)", strategy_pp),
352 strategy_ps);
353
354 tester::apply("p-s-mer4",
355 "POINT(1 80)",
356 "SEGMENT(0 0,0 90)",
357 pp_distance("POINT(1 80)", "POINT(0 80.00149225834545)", strategy_pp),
358 strategy_ps);
359
360 // Half meridian segment passing through pole
361 tester::apply("p-s-19",
362 "POINT(90 89)",
363 "SEGMENT(0 0,180 0)",
364 pp_distance("POINT(90 89)", "POINT(90 90)", strategy_pp),
365 strategy_ps);
366
367 tester::apply("p-s-20",
368 "POINT(80 89)",
369 "SEGMENT(0 0,180 0)",
370 pp_distance("POINT(80 89)", "POINT(0 89.82633489283377)", strategy_pp),
371 strategy_ps);
372
373 tester::apply("p-s-20",
374 "POINT(80 89)",
375 "SEGMENT(0 -1,180 1)",
376 pp_distance("POINT(80 89)", "POINT(0 89.82633489283377)", strategy_pp),
377 strategy_ps);
378 }
379
380 //===========================================================================
381
382 template <typename Strategy_pp, typename Strategy_ps>
383 void test_distance_point_linestring(Strategy_pp const& strategy_pp,
384 Strategy_ps const& strategy_ps)
385 {
386 #ifdef BOOST_GEOMETRY_TEST_DEBUG
387 std::cout << std::endl;
388 std::cout << "point/linestring distance tests" << std::endl;
389 #endif
390 typedef test_distance_of_geometries<point_type, linestring_type> tester;
391
392 tester::apply("p-l-01",
393 "POINT(0 0)",
394 "LINESTRING(2 0,2 0)",
395 pp_distance("POINT(0 0)", "POINT(2 0)", strategy_pp),
396 strategy_ps);
397 tester::apply("p-l-02",
398 "POINT(0 0)",
399 "LINESTRING(2 0,3 0)",
400 pp_distance("POINT(0 0)", "POINT(2 0)", strategy_pp),
401 strategy_ps);
402 tester::apply("p-l-03",
403 "POINT(2.5 3)",
404 "LINESTRING(2 0,3 0)",
405 pp_distance("POINT(2.5 3)", "POINT(2.5 0)", strategy_pp),
406 strategy_ps);
407 tester::apply("p-l-04",
408 "POINT(2 0)",
409 "LINESTRING(2 0,3 0)",
410 0,
411 strategy_ps);
412 tester::apply("p-l-05",
413 "POINT(3 0)",
414 "LINESTRING(2 0,3 0)",
415 0,
416 strategy_ps);
417 tester::apply("p-l-06",
418 "POINT(2.5 0)",
419 "LINESTRING(2 0,3 0)",
420 0,
421 strategy_ps);
422 tester::apply("p-l-07",
423 "POINT(7.5 10)",
424 "LINESTRING(1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 0)",
425 ps_distance("POINT(7.5 10)", "SEGMENT(7 0,8 0)", strategy_ps),
426 strategy_ps);
427 tester::apply("p-l-08",
428 "POINT(7.5 10)",
429 "LINESTRING(1 1,2 1,3 1,4 1,5 1,6 1,7 1,20 2,21 2)",
430 ps_distance("POINT(7.5 10)", "SEGMENT(7 1,20 2)", strategy_ps),
431 strategy_ps);
432 }
433
434 void test_distance_point_linestring_strategies()
435 {
436 typedef test_distance_of_geometries<point_type, linestring_type> tester;
437
438 tester::apply("p-l-03",
439 "POINT(2.5 3)",
440 "LINESTRING(2 1,3 1)",
441 221147.24332788656,
442 vincenty_strategy());
443
444 tester::apply("p-l-03",
445 "POINT(2.5 3)",
446 "LINESTRING(2 1,3 1)",
447 221147.36682199029,
448 thomas_strategy());
449
450 tester::apply("p-l-03",
451 "POINT(2.5 3)",
452 "LINESTRING(2 1,3 1)",
453 221144.76527049288,
454 andoyer_strategy());
455 }
456
457 //===========================================================================
458
459 template <typename Strategy_pp, typename Strategy_ps>
460 void test_distance_point_multilinestring(Strategy_pp const& strategy_pp,
461 Strategy_ps const& strategy_ps)
462 {
463 #ifdef BOOST_GEOMETRY_TEST_DEBUG
464 std::cout << std::endl;
465 std::cout << "point/multilinestring distance tests" << std::endl;
466 #endif
467 typedef test_distance_of_geometries
468 <
469 point_type, multi_linestring_type
470 > tester;
471
472 tester::apply("p-ml-01",
473 "POINT(0 0)",
474 "MULTILINESTRING((-5 0,-3 0),(2 0,3 0))",
475 pp_distance("POINT(0 0)", "POINT(2 0)", strategy_pp),
476 strategy_ps);
477 tester::apply("p-ml-02",
478 "POINT(2.5 3)",
479 "MULTILINESTRING((-5 0,-3 0),(2 0,3 0))",
480 pp_distance("POINT(2.5 3)", "POINT(2.5 0)", strategy_pp),
481 strategy_ps);
482 tester::apply("p-ml-03",
483 "POINT(2 0)",
484 "MULTILINESTRING((-5 0,-3 0),(2 0,3 0))",
485 0,
486 strategy_ps);
487 tester::apply("p-ml-04",
488 "POINT(3 0)",
489 "MULTILINESTRING((-5 0,-3 0),(2 0,3 0))",
490 0,
491 strategy_ps);
492 tester::apply("p-ml-05",
493 "POINT(2.5 0)",
494 "MULTILINESTRING((-5 0,-3 0),(2 0,3 0))",
495 0,
496 strategy_ps);
497 tester::apply("p-ml-06",
498 "POINT(7.5 10)",
499 "MULTILINESTRING((-5 0,-3 0),(2 0,3 0,4 0,5 0,6 0,20 1,21 1))",
500 ps_distance("POINT(7.5 10)", "SEGMENT(6 0,20 1)", strategy_ps),
501 strategy_ps);
502 tester::apply("p-ml-07",
503 "POINT(-8 10)",
504 "MULTILINESTRING((-20 10,-19 11,-18 10,-6 0,-5 0,-3 0),(2 0,6 0,20 1,21 1))",
505 ps_distance("POINT(-8 10)", "SEGMENT(-6 0,-18 10)", strategy_ps),
506 strategy_ps);
507 }
508
509 //===========================================================================
510
511 template <typename Strategy_pp, typename Strategy_ps>
512 void test_distance_linestring_multipoint(Strategy_pp const& strategy_pp,
513 Strategy_ps const& strategy_ps)
514 {
515 #ifdef BOOST_GEOMETRY_TEST_DEBUG
516 std::cout << std::endl;
517 std::cout << "linestring/multipoint distance tests" << std::endl;
518 #endif
519 typedef test_distance_of_geometries
520 <
521 linestring_type, multi_point_type
522 > tester;
523
524 tester::apply("l-mp-01",
525 "LINESTRING(2 0,0 2,100 80)",
526 "MULTIPOINT(0 0,1 0,0 1,1 1)",
527 ps_distance("POINT(1 1)", "SEGMENT(2 0,0 2)", strategy_ps),
528 strategy_ps);
529
530 tester::apply("l-mp-02",
531 "LINESTRING(4 0,0 4,100 80)",
532 "MULTIPOINT(0 0,1 0,0 1,1 1)",
533 ps_distance("POINT(1 1)", "SEGMENT(0 4,4 0)", strategy_ps),
534 strategy_ps);
535 tester::apply("l-mp-03",
536 "LINESTRING(1 1,2 2,100 80)",
537 "MULTIPOINT(0 0,1 0,0 1,1 1)",
538 0,
539 strategy_ps);
540 tester::apply("l-mp-04",
541 "LINESTRING(3 3,4 4,100 80)",
542 "MULTIPOINT(0 0,1 0,0 1,1 1)",
543 pp_distance("POINT(1 1)", "POINT(3 3)", strategy_pp),
544 strategy_ps);
545 tester::apply("l-mp-05",
546 "LINESTRING(0 0,10 0,10 10,0 10,0 0)",
547 "MULTIPOINT(1 -1,80 80,5 0,150 90)",
548 0,
549 strategy_ps);
550 }
551
552 //===========================================================================
553 template <typename Strategy_pp, typename Strategy_ps>
554 void test_distance_multipoint_multilinestring(Strategy_pp const& strategy_pp,
555 Strategy_ps const& strategy_ps)
556 {
557 #ifdef BOOST_GEOMETRY_TEST_DEBUG
558 std::cout << std::endl;
559 std::cout << "multipoint/multilinestring distance tests" << std::endl;
560 #endif
561 typedef test_distance_of_geometries
562 <
563 multi_point_type, multi_linestring_type
564 > tester;
565
566 tester::apply("mp-ml-01",
567 "MULTIPOINT(0 0,1 0,0 1,1 1)",
568 "MULTILINESTRING((2 0,0 2),(2 2,3 3))",
569 ps_distance("POINT(1 1)", "SEGMENT(2 0,0 2)", strategy_ps),
570 strategy_ps);
571 tester::apply("mp-ml-02",
572 "MULTIPOINT(0 0,1 0,0 1,1 1)",
573 "MULTILINESTRING((3 0,0 3),(4 4,5 5))",
574 ps_distance("POINT(1 1)", "SEGMENT(3 0,0 3)", strategy_ps),
575 strategy_ps);
576 tester::apply("mp-ml-03",
577 "MULTIPOINT(0 0,1 0,0 1,1 1)",
578 "MULTILINESTRING((4 4,5 5),(1 1,2 2))",
579 0,
580 strategy_ps);
581 tester::apply("mp-ml-04",
582 "MULTIPOINT(0 0,1 0,0 1,1 1)",
583 "MULTILINESTRING((4 4,3 3),(4 4,5 5))",
584 pp_distance("POINT(1 1)", "POINT(3 3)", strategy_pp),
585 strategy_ps);
586 }
587
588 //===========================================================================
589
590 template <typename Strategy_pp, typename Strategy_ps>
591 void test_distance_multipoint_segment(Strategy_pp const& strategy_pp,
592 Strategy_ps const& strategy_ps)
593 {
594 #ifdef BOOST_GEOMETRY_TEST_DEBUG
595 std::cout << std::endl;
596 std::cout << "multipoint/segment distance tests" << std::endl;
597 #endif
598 typedef test_distance_of_geometries<multi_point_type, segment_type> tester;
599
600 tester::apply("mp-s-01",
601 "MULTIPOINT(0 0,1 0,0 1,1 1)",
602 "SEGMENT(2 0,0 2)",
603 ps_distance("POINT(1 1)", "SEGMENT(2 0,0 2)", strategy_ps),
604 strategy_ps);
605 tester::apply("mp-s-02",
606 "MULTIPOINT(0 0,1 0,0 1,1 1)",
607 "SEGMENT(0 -3,1 -10)",
608 pp_distance("POINT(0 0)", "POINT(0 -3)", strategy_pp),
609 strategy_ps);
610 tester::apply("mp-s-03",
611 "MULTIPOINT(0 0,1 0,0 1,1 1)",
612 "SEGMENT(1 1,2 2)",
613 0,
614 strategy_ps);
615 tester::apply("mp-s-04",
616 "MULTIPOINT(0 0,1 0,0 1,1 1)",
617 "SEGMENT(3 3,4 4)",
618 pp_distance("POINT(1 1)", "POINT(3 3)", strategy_pp),
619 strategy_ps);
620 tester::apply("mp-s-05",
621 "MULTIPOINT(0 0,1 0,0 1,1 1)",
622 "SEGMENT(0.5 -3,1 -10)",
623 pp_distance("POINT(1 0)", "POINT(0.5 -3)", strategy_pp),
624 strategy_ps);
625 }
626
627 //===========================================================================
628
629 template <typename Point, typename Strategy>
630 void test_empty_input_pointlike_linear(Strategy const& strategy)
631 {
632 #ifdef BOOST_GEOMETRY_TEST_DEBUG
633 std::cout << std::endl;
634 std::cout << "testing on empty inputs... " << std::flush;
635 #endif
636 bg::model::linestring<Point> line_empty;
637 bg::model::multi_point<Point> multipoint_empty;
638 bg::model::multi_linestring<bg::model::linestring<Point> > multiline_empty;
639
640 Point point = from_wkt<Point>("POINT(0 0)");
641 bg::model::linestring<Point> line =
642 from_wkt<bg::model::linestring<Point> >("LINESTRING(0 0,1 1)");
643
644 // 1st geometry is empty
645 //test_empty_input(multipoint_empty, line, strategy);
646
647 // 2nd geometry is empty
648 test_empty_input(point, line_empty, strategy);
649 test_empty_input(point, multiline_empty, strategy);
650
651 // both geometries are empty
652 //test_empty_input(multipoint_empty, line_empty, strategy);
653 //test_empty_input(multipoint_empty, multiline_empty, strategy);
654
655 #ifdef BOOST_GEOMETRY_TEST_DEBUG
656 std::cout << "done!" << std::endl;
657 #endif
658 }
659
660 //===========================================================================
661 //===========================================================================
662 //===========================================================================
663
664 BOOST_AUTO_TEST_CASE( test_all_point_segment )
665 {
666 //TODO: Operations with multipoints need geographic pt-box strategy
667 //before activating
668
669 test_distance_point_segment(vincenty_pp(), vincenty_strategy());
670 test_distance_point_segment(thomas_pp(), thomas_strategy());
671 test_distance_point_segment(andoyer_pp(), andoyer_strategy());
672
673 test_distance_point_segment_no_thomas(vincenty_pp(), vincenty_strategy());
674 //test_distance_point_segment_no_thomas(thomas_pp(), thomas_strategy());
675 test_distance_point_segment_no_thomas(andoyer_pp(), andoyer_strategy());
676
677 test_distance_point_linestring(vincenty_pp(), vincenty_strategy());
678 test_distance_point_linestring(thomas_pp(), thomas_strategy());
679 test_distance_point_linestring(andoyer_pp(), andoyer_strategy());
680 test_distance_point_linestring_strategies();
681
682 test_distance_point_multilinestring(vincenty_pp(), vincenty_strategy());
683 test_distance_point_multilinestring(thomas_pp(), thomas_strategy());
684 test_distance_point_multilinestring(andoyer_pp(), andoyer_strategy());
685
686 // test_distance_linestring_multipoint(vincenty_pp(), vincenty_strategy());
687 // test_distance_linestring_multipoint(thomas_pp(), thomas_strategy());
688 // test_distance_linestring_multipoint(andoyer_pp(), andoyer_strategy());
689
690 // test_distance_multipoint_multilinestring(vincenty_pp(), vincenty_strategy());
691 // test_distance_multipoint_multilinestring(thomas_pp(), thomas_strategy());
692 // test_distance_multipoint_multilinestring(andoyer_pp(), andoyer_strategy());
693
694 // test_distance_multipoint_segment(vincenty_pp(), vincenty_strategy());
695 // test_distance_multipoint_segment(thomas_pp(), thomas_strategy());
696 // test_distance_multipoint_segment(andoyer_pp(), andoyer_strategy());
697
698 test_empty_input_pointlike_linear<point_type>(vincenty_strategy());
699 }