1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | |
3 | // Copyright (c) 2014-2015, Oracle and/or its affiliates. |
4 | |
5 | // Licensed under the Boost Software License version 1.0. |
6 | // http://www.boost.org/users/license.html |
7 | |
8 | // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle |
9 | |
10 | #include <iostream> |
11 | |
12 | #ifndef BOOST_TEST_MODULE |
13 | #define BOOST_TEST_MODULE test_union_pointlike_pointlike |
14 | #endif |
15 | |
16 | #ifdef BOOST_GEOMETRY_TEST_DEBUG |
17 | #define BOOST_GEOMETRY_DEBUG_TURNS |
18 | #define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER |
19 | #endif |
20 | |
21 | #include <boost/test/included/unit_test.hpp> |
22 | |
23 | #include "../test_set_ops_pointlike.hpp" |
24 | |
25 | #include <boost/geometry/geometries/multi_point.hpp> |
26 | |
27 | typedef bg::model::point<double,2,bg::cs::cartesian> point_type; |
28 | typedef bg::model::multi_point<point_type> multi_point_type; |
29 | |
30 | |
31 | |
32 | //=========================================================================== |
33 | //=========================================================================== |
34 | //=========================================================================== |
35 | |
36 | |
37 | BOOST_AUTO_TEST_CASE( test_union_point_point ) |
38 | { |
39 | #ifdef BOOST_GEOMETRY_TEST_DEBUG |
40 | std::cout << std::endl << std::endl << std::endl; |
41 | std::cout << "*** POINT / POINT UNION ***" << std::endl; |
42 | std::cout << std::endl; |
43 | #endif |
44 | |
45 | typedef point_type P; |
46 | typedef multi_point_type MP; |
47 | |
48 | typedef test_set_op_of_pointlike_geometries |
49 | < |
50 | P, P, MP, bg::overlay_union |
51 | > tester; |
52 | |
53 | tester::apply |
54 | (case_id: "ppu01" , |
55 | geometry1: from_wkt<P>(wkt: "POINT(0 0)" ), |
56 | geometry2: from_wkt<P>(wkt: "POINT(1 1)" ), |
57 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 1)" ) |
58 | ); |
59 | |
60 | tester::apply |
61 | (case_id: "ppu02" , |
62 | geometry1: from_wkt<P>(wkt: "POINT(0 0)" ), |
63 | geometry2: from_wkt<P>(wkt: "POINT(0 0)" ), |
64 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0)" ) |
65 | ); |
66 | } |
67 | |
68 | |
69 | BOOST_AUTO_TEST_CASE( test_union_multipoint_point ) |
70 | { |
71 | #ifdef BOOST_GEOMETRY_TEST_DEBUG |
72 | std::cout << std::endl << std::endl << std::endl; |
73 | std::cout << "*** MULTIPOINT / POINT UNION ***" << std::endl; |
74 | std::cout << std::endl; |
75 | #endif |
76 | |
77 | typedef point_type P; |
78 | typedef multi_point_type MP; |
79 | |
80 | typedef test_set_op_of_pointlike_geometries |
81 | < |
82 | MP, P, MP, bg::overlay_union |
83 | > tester; |
84 | |
85 | tester::apply |
86 | (case_id: "mppu01" , |
87 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0)" ), |
88 | geometry2: from_wkt<P>(wkt: "POINT(1 1)" ), |
89 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 1)" ) |
90 | ); |
91 | |
92 | tester::apply |
93 | (case_id: "mppu02" , |
94 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0)" ), |
95 | geometry2: from_wkt<P>(wkt: "POINT(0 0)" ), |
96 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0)" ) |
97 | ); |
98 | |
99 | tester::apply |
100 | (case_id: "mppu03" , |
101 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0)" ), |
102 | geometry2: from_wkt<P>(wkt: "POINT(1 1)" ), |
103 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0,1 1)" ) |
104 | ); |
105 | |
106 | tester::apply |
107 | (case_id: "mppu04" , |
108 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0)" ), |
109 | geometry2: from_wkt<P>(wkt: "POINT(0 0)" ), |
110 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0)" ) |
111 | ); |
112 | |
113 | tester::apply |
114 | (case_id: "mppu05" , |
115 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0,1 0)" ), |
116 | geometry2: from_wkt<P>(wkt: "POINT(1 1)" ), |
117 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0,1 0,1 1)" ) |
118 | ); |
119 | |
120 | tester::apply |
121 | (case_id: "mppu06" , |
122 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0,1 0)" ), |
123 | geometry2: from_wkt<P>(wkt: "POINT(1 0)" ), |
124 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0,1 0)" ) |
125 | ); |
126 | |
127 | tester::apply |
128 | (case_id: "mppu07" , |
129 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,0 0,1 0)" ), |
130 | geometry2: from_wkt<P>(wkt: "POINT(0 0)" ), |
131 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 0)" ) |
132 | ); |
133 | |
134 | tester::apply |
135 | (case_id: "mppu08" , |
136 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT()" ), |
137 | geometry2: from_wkt<P>(wkt: "POINT(0 0)" ), |
138 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0)" ) |
139 | ); |
140 | } |
141 | |
142 | |
143 | BOOST_AUTO_TEST_CASE( test_union_multipoint_multipoint ) |
144 | { |
145 | #ifdef BOOST_GEOMETRY_TEST_DEBUG |
146 | std::cout << std::endl << std::endl << std::endl; |
147 | std::cout << "*** MULTIPOINT / MULTIPOINT UNION ***" << std::endl; |
148 | std::cout << std::endl; |
149 | #endif |
150 | |
151 | typedef multi_point_type MP; |
152 | |
153 | typedef test_set_op_of_pointlike_geometries |
154 | < |
155 | MP, MP, MP, bg::overlay_union |
156 | > tester; |
157 | |
158 | tester::apply |
159 | (case_id: "mpmpu01" , |
160 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)" ), |
161 | geometry2: from_wkt<MP>(wkt: "MULTIPOINT(1 0,1 1,1 1,1 1)" ), |
162 | mp_expected12: from_wkt<MP>(wkt: "MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)" ), |
163 | mp_expected21: from_wkt<MP>(wkt: "MULTIPOINT(1 0,1 1,1 1,1 1,2 2,3 3,0 0,0 0,2 2)" ) |
164 | ); |
165 | |
166 | tester::apply |
167 | (case_id: "mpmpu02" , |
168 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 1,1 0,1 1)" ), |
169 | geometry2: from_wkt<MP>(wkt: "MULTIPOINT(1 0,0 0,1 1,0 0)" ), |
170 | mp_expected12: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 1,1 0,1 1)" ), |
171 | mp_expected21: from_wkt<MP>(wkt: "MULTIPOINT(1 0,0 0,1 1,0 0)" ) |
172 | ); |
173 | |
174 | tester::apply |
175 | (case_id: "mpmpu03" , |
176 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT()" ), |
177 | geometry2: from_wkt<MP>(wkt: "MULTIPOINT(1 0,0 0,1 1,0 0)" ), |
178 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(1 0,0 0,1 1,0 0)" ) |
179 | ); |
180 | |
181 | tester::apply |
182 | (case_id: "mpmpu04" , |
183 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 1,1 0,1 1)" ), |
184 | geometry2: from_wkt<MP>(wkt: "MULTIPOINT()" ), |
185 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 1,1 0,1 1)" ) |
186 | ); |
187 | |
188 | tester::apply |
189 | (case_id: "mpmpu05" , |
190 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT()" ), |
191 | geometry2: from_wkt<MP>(wkt: "MULTIPOINT()" ), |
192 | mp_expected: from_wkt<MP>(wkt: "MULTIPOINT()" ) |
193 | ); |
194 | |
195 | tester::apply |
196 | (case_id: "mpmpu06" , |
197 | geometry1: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)" ), |
198 | geometry2: from_wkt<MP>(wkt: "MULTIPOINT(0 1,0 2,1 0,0 0,2 0)" ), |
199 | mp_expected12: from_wkt<MP>(wkt: "MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0,0 1,0 2)" ), |
200 | mp_expected21: from_wkt<MP>(wkt: "MULTIPOINT(0 1,0 2,1 0,0 0,2 0,3 0)" ) |
201 | ); |
202 | } |
203 | |