]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry |
2 | ||
3 | // Copyright (c) 2016 Oracle and/or its affiliates. | |
4 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
5 | ||
6 | // Use, modification and distribution is subject to the Boost Software License, | |
7 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
8 | // http://www.boost.org/LICENSE_1_0.txt) | |
9 | ||
10 | #include "test_covered_by.hpp" | |
11 | ||
12 | #include <algorithms/overlay/overlay_cases.hpp> | |
13 | #include <algorithms/overlay/multi_overlay_cases.hpp> | |
14 | ||
15 | #include <boost/geometry/geometries/geometries.hpp> | |
16 | ||
17 | ||
18 | template <typename P> | |
19 | void test_polygon_polygon() | |
20 | { | |
21 | typedef bg::model::polygon<P> poly; | |
22 | typedef bg::model::ring<P> ring; | |
23 | ||
24 | test_geometry<ring, ring>(case_1[0], case_1[1], | |
25 | false); | |
26 | test_geometry<ring, poly>(case_1[0], case_1[1], | |
27 | false); | |
28 | ||
29 | test_geometry<poly, poly>(case_1[0], case_1[1], | |
30 | false); | |
31 | test_geometry<poly, poly>(case_2[0], case_2[1], | |
32 | false); | |
33 | test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1], | |
34 | true); | |
35 | test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1], | |
36 | true); | |
37 | test_geometry<poly, poly>(case_4[0], case_4[1], | |
38 | false); | |
39 | test_geometry<poly, poly>(case_5[0], case_5[1], | |
40 | false); | |
41 | test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1], | |
42 | false); | |
43 | test_geometry<poly, poly>(case_6_sph[1], case_6_sph[0], | |
44 | true); | |
45 | ||
46 | test_geometry<poly, poly>(case_7[0], case_7[1], | |
47 | false); | |
48 | test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1], | |
49 | false); | |
50 | test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1], | |
51 | false); | |
52 | test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1], | |
53 | false); | |
54 | test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1], | |
55 | false); | |
56 | test_geometry<poly, poly>(case_11_sph[1], case_11_sph[0], | |
57 | true); | |
58 | test_geometry<poly, poly>(case_12[0], case_12[1], | |
59 | false); | |
60 | ||
61 | test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1], | |
62 | false); | |
63 | test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1], | |
64 | false); | |
65 | test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1], | |
66 | false); | |
67 | test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1], | |
68 | false); | |
69 | test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1], | |
70 | false); | |
71 | test_geometry<poly, poly>(case_17_sph[1], case_17_sph[0], | |
72 | true); | |
73 | test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1], | |
74 | false); | |
75 | test_geometry<poly, poly>(case_18_sph[1], case_18_sph[0], | |
76 | true); | |
77 | } | |
78 | ||
79 | template <typename P> | |
80 | void test_polygon_multi_polygon() | |
81 | { | |
82 | typedef bg::model::polygon<P> poly; | |
83 | typedef bg::model::ring<P> ring; | |
84 | typedef bg::model::multi_polygon<poly> mpoly; | |
85 | ||
86 | test_geometry<ring, mpoly>(case_1[0], case_multi_2[0], | |
87 | false); | |
88 | test_geometry<poly, mpoly>(case_2[0], case_multi_2[0], | |
89 | false); | |
90 | } | |
91 | ||
92 | template <typename P> | |
93 | void test_multi_polygon_multi_polygon() | |
94 | { | |
95 | typedef bg::model::polygon<P> poly; | |
96 | typedef bg::model::multi_polygon<poly> mpoly; | |
97 | ||
98 | test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1], | |
99 | false); | |
100 | } | |
101 | ||
102 | template <typename P> | |
103 | void test_linestring_polygon() | |
104 | { | |
105 | typedef bg::model::linestring<P> ls; | |
106 | typedef bg::model::polygon<P> poly; | |
107 | typedef bg::model::polygon<P> ring; | |
108 | ||
109 | test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); | |
110 | test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); | |
111 | test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); | |
112 | test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); | |
113 | test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); | |
114 | test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); | |
115 | ||
116 | test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)", | |
117 | "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", | |
118 | true); | |
119 | ||
120 | test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)", | |
121 | "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", | |
122 | true); | |
123 | ||
124 | test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)", | |
125 | "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
126 | true); | |
127 | } | |
128 | ||
129 | template <typename P> | |
130 | void test_linestring_multi_polygon() | |
131 | { | |
132 | typedef bg::model::linestring<P> ls; | |
133 | typedef bg::model::polygon<P> poly; | |
134 | typedef bg::model::multi_polygon<poly> mpoly; | |
135 | ||
136 | test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)", | |
137 | "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))", | |
138 | true); | |
139 | } | |
140 | ||
141 | template <typename P> | |
142 | void test_multi_linestring_polygon() | |
143 | { | |
144 | typedef bg::model::linestring<P> ls; | |
145 | typedef bg::model::polygon<P> poly; | |
146 | typedef bg::model::ring<P> ring; | |
147 | typedef bg::model::multi_linestring<ls> mls; | |
148 | ||
149 | test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))", | |
150 | "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))", | |
151 | false); | |
152 | ||
153 | test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))", | |
154 | "POLYGON((5 5,5 15,15 15,15 5,5 5))", | |
155 | false); | |
156 | ||
157 | test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))", | |
158 | "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
159 | true); | |
160 | } | |
161 | ||
162 | template <typename P> | |
163 | void test_multi_linestring_multi_polygon() | |
164 | { | |
165 | typedef bg::model::linestring<P> ls; | |
166 | typedef bg::model::polygon<P> poly; | |
167 | typedef bg::model::multi_linestring<ls> mls; | |
168 | typedef bg::model::multi_polygon<poly> mpoly; | |
169 | ||
170 | test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))", | |
171 | "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))", | |
172 | true); | |
173 | ||
174 | test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))", | |
175 | "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", | |
176 | false); | |
177 | ||
178 | test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))", | |
179 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
180 | true); | |
181 | } | |
182 | ||
183 | template <typename P> | |
184 | void test_linestring_linestring() | |
185 | { | |
186 | typedef bg::model::linestring<P> ls; | |
187 | ||
188 | test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true); | |
189 | ||
190 | test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", false); | |
191 | } | |
192 | ||
193 | template <typename P> | |
194 | void test_linestring_multi_linestring() | |
195 | { | |
196 | typedef bg::model::linestring<P> ls; | |
197 | typedef bg::model::multi_linestring<ls> mls; | |
198 | ||
199 | test_geometry<ls, mls>("LINESTRING(0 0,10 0)", | |
200 | "MULTILINESTRING((1 0,2 0),(1 1,2 1))", | |
201 | false); | |
202 | ||
203 | test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)", | |
204 | "MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))", | |
205 | true); | |
206 | } | |
207 | ||
208 | template <typename P> | |
209 | void test_multi_linestring_multi_linestring() | |
210 | { | |
211 | typedef bg::model::linestring<P> ls; | |
212 | typedef bg::model::multi_linestring<ls> mls; | |
213 | ||
214 | test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))", | |
215 | "MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))", | |
216 | false); | |
217 | } | |
218 | ||
219 | template <typename P> | |
220 | void test_point_polygon() | |
221 | { | |
222 | typedef bg::model::polygon<P> poly; | |
223 | ||
224 | // https://svn.boost.org/trac/boost/ticket/9162 | |
225 | test_geometry<P, poly>("POINT(0 90)", | |
226 | "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", | |
227 | true); | |
228 | test_geometry<P, poly>("POINT(-120 21)", | |
229 | "POLYGON((30 0,30 30,90 30, 90 0, 30 0))", | |
230 | false); | |
231 | // extended | |
b32b8144 FG |
232 | test_geometry<P, poly>("POINT(0 90)", |
233 | "POLYGON((0 80, 0 81, -90 80, -180 80, 90 80, 0 80))", | |
234 | true); | |
235 | test_geometry<P, poly>("POINT(0 90)", | |
236 | "POLYGON((0 80, -90 80, -90 81, -180 80, 90 80, 0 80))", | |
7c673cae FG |
237 | true); |
238 | test_geometry<P, poly>("POINT(0 89)", | |
239 | "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", | |
240 | true); | |
241 | test_geometry<P, poly>("POINT(-180 89)", | |
242 | "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", | |
243 | true); | |
b32b8144 FG |
244 | test_geometry<P, poly>("POINT(0 -90)", |
245 | "POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))", | |
246 | true); | |
247 | test_geometry<P, poly>("POINT(0 -89)", | |
248 | "POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))", | |
249 | true); | |
250 | test_geometry<P, poly>("POINT(1 -90)", | |
251 | "POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))", | |
252 | true); | |
253 | test_geometry<P, poly>("POINT(1 -89)", | |
254 | "POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))", | |
255 | true); | |
256 | test_geometry<P, poly>("POINT(1 90)", | |
257 | "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", | |
258 | true); | |
259 | test_geometry<P, poly>("POINT(1 90)", | |
260 | "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", | |
261 | true); | |
262 | ||
263 | ||
264 | ||
265 | // MySQL report 08.2017 | |
266 | test_geometry<P, poly>("POINT(-179 0)", | |
267 | "POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))", | |
268 | false); | |
269 | // extended | |
270 | test_geometry<P, poly>("POINT(179 0)", | |
271 | "POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))", | |
272 | false); | |
273 | test_geometry<P, poly>("POINT(180 0)", | |
274 | "POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))", | |
275 | false); | |
276 | test_geometry<P, poly>("POINT(-179 0)", | |
277 | "POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 10))", | |
278 | false); | |
279 | test_geometry<P, poly>("POINT(179 0)", | |
280 | "POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 10))", | |
281 | false); | |
282 | test_geometry<P, poly>("POINT(-179 0)", | |
283 | "POLYGON((0 0, 0 1, 1 0, 0 -1, 0 0))", | |
284 | false); | |
285 | test_geometry<P, poly>("POINT(179 0)", | |
286 | "POLYGON((0 0, 0 1, 1 0, 0 -1, 0 0))", | |
287 | false); | |
7c673cae FG |
288 | } |
289 | ||
290 | ||
291 | template <typename P> | |
292 | void test_all() | |
293 | { | |
294 | test_polygon_polygon<P>(); | |
295 | test_polygon_multi_polygon<P>(); | |
296 | test_multi_polygon_multi_polygon<P>(); | |
297 | ||
298 | test_linestring_polygon<P>(); | |
299 | test_linestring_multi_polygon<P>(); | |
300 | test_multi_linestring_polygon<P>(); | |
301 | test_multi_linestring_multi_polygon<P>(); | |
302 | ||
303 | test_linestring_linestring<P>(); | |
304 | test_linestring_multi_linestring<P>(); | |
305 | test_multi_linestring_multi_linestring<P>(); | |
306 | ||
307 | test_point_polygon<P>(); | |
308 | } | |
309 | ||
310 | ||
311 | int test_main( int , char* [] ) | |
312 | { | |
313 | test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >(); | |
314 | ||
315 | #if defined(HAVE_TTMATH) | |
316 | test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >(); | |
317 | #endif | |
318 | ||
319 | return 0; | |
320 | } |