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 #ifndef BOOST_TEST_MODULE
12 #define BOOST_TEST_MODULE test_distance_geographic_pointlike_pointlike
13 #endif
14
15 #include <boost/test/included/unit_test.hpp>
16
17 #include "test_distance_geo_common.hpp"
18 #include "test_empty_geometry.hpp"
19
20 //===========================================================================
21
22 template <typename Point, typename Strategy>
test_distance_point_point(Strategy const & strategy)23 void test_distance_point_point(Strategy const& strategy)
24 {
25
26 #ifdef BOOST_GEOMETRY_TEST_DEBUG
27 std::cout << std::endl;
28 std::cout << "point/point distance tests" << std::endl;
29 #endif
30 typedef test_distance_of_geometries<Point, Point> tester;
31
32 tester::apply("p-p-01",
33 "POINT(1 1)",
34 "POINT(0 0)",
35 strategy.apply(Point(1,1), Point(0,0)),
36 strategy, true, false, false);
37 }
38
39 //===========================================================================
40
41 template <typename Point, typename Strategy>
test_distance_multipoint_point(Strategy const & strategy)42 void test_distance_multipoint_point(Strategy const& strategy)
43 {
44
45 #ifdef BOOST_GEOMETRY_TEST_DEBUG
46 std::cout << std::endl;
47 std::cout << "multipoint/point distance tests" << std::endl;
48 #endif
49 typedef bg::model::multi_point<Point> multi_point_type;
50
51 typedef test_distance_of_geometries<multi_point_type, Point> tester;
52
53 tester::apply("mp-p-01",
54 "MULTIPOINT(1 1,1 2,2 3)",
55 "POINT(0 0)",
56 pp_distance<Point>("POINT(0 0)","POINT(1 1)",strategy),
57 strategy, true, false, false);
58
59 tester::apply("mp-p-01",
60 "MULTIPOINT(0 0,0 2,2 0,2 2)",
61 "POINT(1.1 1.1)",
62 pp_distance<Point>("POINT(1.1 1.1)","POINT(2 2)",strategy),
63 strategy, true, false, false);
64 }
65
66 //===========================================================================
67
68 template <typename Point, typename Strategy>
test_distance_multipoint_multipoint(Strategy const & strategy)69 void test_distance_multipoint_multipoint(Strategy const& strategy)
70 {
71
72 #ifdef BOOST_GEOMETRY_TEST_DEBUG
73 std::cout << std::endl;
74 std::cout << "multipoint/multipoint distance tests" << std::endl;
75 #endif
76 typedef bg::model::multi_point<Point> multi_point_type;
77
78 typedef test_distance_of_geometries<multi_point_type, multi_point_type> tester;
79
80 tester::apply("mp-mp-01",
81 "MULTIPOINT(1 1,1 2,2 3)",
82 "MULTIPOINT(0 0, 0 -1)",
83 pp_distance<Point>("POINT(0 0)","POINT(1 1)",strategy),
84 strategy, true, false, false);
85 }
86
87 //===========================================================================
88 //===========================================================================
89 //===========================================================================
90
91 template <typename Point, typename Strategy>
test_all_pl_pl(Strategy pp_strategy)92 void test_all_pl_pl(Strategy pp_strategy)
93 {
94 test_distance_point_point<Point>(pp_strategy);
95 test_distance_multipoint_point<Point>(pp_strategy);
96 test_distance_multipoint_multipoint<Point>(pp_strategy);
97
98 test_more_empty_input_pointlike_pointlike<Point>(pp_strategy);
99 }
100
BOOST_AUTO_TEST_CASE(test_all_pointlike_pointlike)101 BOOST_AUTO_TEST_CASE( test_all_pointlike_pointlike )
102 {
103 typedef bg::model::point
104 <
105 double, 2,
106 bg::cs::spherical_equatorial<bg::degree>
107 > sph_point;
108
109 test_all_pl_pl<sph_point>(spherical_pp());
110
111 typedef bg::model::point
112 <
113 double, 2,
114 bg::cs::geographic<bg::degree>
115 > geo_point;
116
117 test_all_pl_pl<geo_point>(vincenty_pp());
118 test_all_pl_pl<geo_point>(thomas_pp());
119 test_all_pl_pl<geo_point>(andoyer_pp());
120
121 test_all_pl_pl<geo_point>(andoyer_pp(stype(5000000,6000000)));
122 }
123