1 //
2 // Test Suite for geos::operation::overlayng::OverlayNG class.
3
4 #include <tut/tut.hpp>
5 #include <utility.h>
6
7 // geos
8 #include <geos/operation/overlayng/OverlayNG.h>
9
10 // std
11 #include <memory>
12
13 using namespace geos::geom;
14 using namespace geos::operation::overlayng;
15 using geos::io::WKTReader;
16 using geos::io::WKTWriter;
17
18 namespace tut {
19 //
20 // Test Group
21 //
22
23 // Common data used by all tests
24 struct test_overlayng_data {
25
26 WKTReader r;
27 WKTWriter w;
28
29 void
testOverlaytut::test_overlayng_data30 testOverlay(const std::string& a, const std::string& b, const std::string& expected, int opCode, double scaleFactor)
31 {
32 std::unique_ptr<PrecisionModel> pm;
33 if (scaleFactor > 0)
34 pm.reset(new PrecisionModel(scaleFactor));
35 else
36 pm.reset(new PrecisionModel());
37
38 std::unique_ptr<Geometry> geom_a = r.read(a);
39 std::unique_ptr<Geometry> geom_b = r.read(b);
40 std::unique_ptr<Geometry> geom_expected = r.read(expected);
41 std::unique_ptr<Geometry> geom_result = OverlayNG::overlay(geom_a.get(), geom_b.get(), opCode, pm.get());
42 // std::string wkt_result = w.write(geom_result.get());
43 // std::cout << std::endl << wkt_result << std::endl;
44 ensure_equals_geometry(geom_expected.get(), geom_result.get());
45 }
46
47 void
testOverlayExacttut::test_overlayng_data48 testOverlayExact(const std::string& a, const std::string& b, const std::string& expected, int opCode, double scaleFactor)
49 {
50 std::unique_ptr<PrecisionModel> pm;
51 if (scaleFactor > 0)
52 pm.reset(new PrecisionModel(scaleFactor));
53 else
54 pm.reset(new PrecisionModel());
55
56 std::unique_ptr<Geometry> geom_a = r.read(a);
57 std::unique_ptr<Geometry> geom_b = r.read(b);
58 std::unique_ptr<Geometry> geom_expected = r.read(expected);
59 std::unique_ptr<Geometry> geom_result = OverlayNG::overlay(geom_a.get(), geom_b.get(), opCode, pm.get());
60 // std::string wkt_result = w.write(geom_result.get());
61 // std::cout << std::endl << wkt_result << std::endl;
62 ensure_equals_exact_geometry(geom_expected.get(), geom_result.get(), 0);
63 }
64
65 void
testOverlayNoOpttut::test_overlayng_data66 testOverlayNoOpt(const std::string& a, const std::string& b, const std::string& expected, int opCode, double scaleFactor)
67 {
68 PrecisionModel pm(scaleFactor);
69 std::unique_ptr<Geometry> geom_a = r.read(a);
70 std::unique_ptr<Geometry> geom_b = r.read(b);
71 std::unique_ptr<Geometry> geom_expected = r.read(expected);
72 OverlayNG ov(geom_a.get(), geom_b.get(), &pm, opCode);
73 ov.setOptimized(true);
74 std::unique_ptr<Geometry> geom_result = ov.getResult();
75 ensure_equals_geometry(geom_expected.get(), geom_result.get());
76 }
77
78 };
79
80 typedef test_group<test_overlayng_data> group;
81 typedef group::object object;
82
83 group test_overlayng_group("geos::operation::overlayng::OverlayNG");
84
85 //
86 // Test Cases
87 //
88
89 // Square overlapping square
90 template<>
91 template<>
test()92 void object::test<1> ()
93 {
94 std::string a = "POLYGON((1000 1000, 2000 1000, 2000 2000, 1000 2000, 1000 1000))";
95 std::string b = "POLYGON((1500 1500, 2500 1500, 2500 2500, 1500 2500, 1500 1500))";
96 std::string exp = "POLYGON((1500 2000,2000 2000,2000 1500,1500 1500,1500 2000))";
97 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
98 }
99
100 // testEmptyGCBothIntersection
101 template<>
102 template<>
test()103 void object::test<2> ()
104 {
105 std::string a = "GEOMETRYCOLLECTION EMPTY";
106 std::string b = "GEOMETRYCOLLECTION EMPTY";
107 std::string exp = "GEOMETRYCOLLECTION EMPTY";
108 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
109 }
110
111 // testEmptyAPolygonIntersection
112 template<>
113 template<>
test()114 void object::test<3> ()
115 {
116 std::string a = "POLYGON EMPTY";
117 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
118 std::string exp = "POLYGON EMPTY";
119 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
120 }
121
122 // testEmptyBIntersection
123 template<>
124 template<>
test()125 void object::test<4> ()
126 {
127 std::string a = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
128 std::string b = "POLYGON EMPTY";
129 std::string exp = "POLYGON EMPTY";
130 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
131 }
132
133 // testEmptyABIntersection
134 template<>
135 template<>
test()136 void object::test<5> ()
137 {
138 std::string a = "POLYGON EMPTY";
139 std::string b = "POLYGON EMPTY";
140 std::string exp = "POLYGON EMPTY";
141 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
142 }
143
144 // testEmptyADifference
145 template<>
146 template<>
test()147 void object::test<6> ()
148 {
149 std::string a = "POLYGON EMPTY";
150 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
151 std::string exp = "POLYGON EMPTY";
152 testOverlay(a, b, exp, OverlayNG::DIFFERENCE, 1);
153 }
154
155 // testEmptyAUnion
156 template<>
157 template<>
test()158 void object::test<7> ()
159 {
160 std::string a = "POLYGON EMPTY";
161 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
162 std::string exp = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
163 testOverlay(a, b, exp, OverlayNG::UNION, 1);
164 }
165
166 // testEmptyASymDifference
167 template<>
168 template<>
test()169 void object::test<8> ()
170 {
171 std::string a = "POLYGON EMPTY";
172 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
173 std::string exp = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
174 testOverlay(a, b, exp, OverlayNG::SYMDIFFERENCE, 1);
175 }
176
177 // testEmptyLinePolygonIntersection
178 template<>
179 template<>
test()180 void object::test<9> ()
181 {
182 std::string a = "LINESTRING EMPTY";
183 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
184 std::string exp = "LINESTRING EMPTY";
185 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
186 }
187
188 // testEmptyLinePolygonDifference
189 template<>
190 template<>
test()191 void object::test<10> ()
192 {
193 std::string a = "LINESTRING EMPTY";
194 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
195 std::string exp = "LINESTRING EMPTY";
196 testOverlay(a, b, exp, OverlayNG::DIFFERENCE, 1);
197 }
198
199 // testEmptyPointPolygonIntersection
200 template<>
201 template<>
test()202 void object::test<11> ()
203 {
204 std::string a = "POINT EMPTY";
205 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
206 std::string exp = "POINT EMPTY";
207 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
208 }
209
210 // testDisjointIntersection
211 template<>
212 template<>
test()213 void object::test<12> ()
214 {
215 std::string a = "POLYGON ((60 90, 90 90, 90 60, 60 60, 60 90))";
216 std::string b = "POLYGON ((200 300, 300 300, 300 200, 200 200, 200 300))";
217 std::string exp = "POLYGON EMPTY";
218 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
219 }
220
221 // testAreaLineIntersection
222 template<>
223 template<>
test()224 void object::test<13> ()
225 {
226 std::string a = "POLYGON ((360 200, 220 200, 220 180, 300 180, 300 160, 300 140, 360 200))";
227 std::string b = "MULTIPOLYGON (((280 180, 280 160, 300 160, 300 180, 280 180)), ((220 230, 240 230, 240 180, 220 180, 220 230)))";
228 // std::string exp = "POLYGON ((220 200, 240 200, 240 180, 220 180, 220 200))";
229 std::string exp = "GEOMETRYCOLLECTION (LINESTRING (280 180, 300 180), LINESTRING (300 160, 300 180), POLYGON ((220 180, 220 200, 240 200, 240 180, 220 180)))";
230 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
231 }
232
233 // testBoxTriIntersection
234 template<>
235 template<>
test()236 void object::test<14> ()
237 {
238 std::string a = "POLYGON ((0 6, 4 6, 4 2, 0 2, 0 6))";
239 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
240 std::string exp = "POLYGON ((3 2, 1 2, 2 5, 3 2))";
241 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
242 }
243
244 // testBoxTriUnion
245 template<>
246 template<>
test()247 void object::test<15> ()
248 {
249 std::string a = "POLYGON ((0 6, 4 6, 4 2, 0 2, 0 6))";
250 std::string b = "POLYGON ((1 0, 2 5, 3 0, 1 0))";
251 std::string exp = "POLYGON ((0 6, 4 6, 4 2, 3 2, 3 0, 1 0, 1 2, 0 2, 0 6))";
252 testOverlay(a, b, exp, OverlayNG::UNION, 1);
253 }
254
255 // test2spikesIntersection
256 template<>
257 template<>
test()258 void object::test<16> ()
259 {
260 std::string a = "POLYGON ((0 100, 40 100, 40 0, 0 0, 0 100))";
261 std::string b = "POLYGON ((70 80, 10 80, 60 50, 11 20, 69 11, 70 80))";
262 std::string exp = "MULTIPOLYGON (((40 80, 40 62, 10 80, 40 80)), ((40 38, 40 16, 11 20, 40 38)))";
263 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
264 }
265
266 // // test2spikesUnion
267 template<>
268 template<>
test()269 void object::test<17> ()
270 {
271 std::string a = "POLYGON ((0 100, 40 100, 40 0, 0 0, 0 100))";
272 std::string b = "POLYGON ((70 80, 10 80, 60 50, 11 20, 69 11, 70 80))";
273 std::string exp = "POLYGON ((0 100, 40 100, 40 80, 70 80, 69 11, 40 16, 40 0, 0 0, 0 100), (40 62, 40 38, 60 50, 40 62))";
274 testOverlay(a, b, exp, OverlayNG::UNION, 1);
275 }
276
277 // testTriBoxIntersection
278 template<>
279 template<>
test()280 void object::test<18> ()
281 {
282 std::string a = "POLYGON ((68 35, 35 42, 40 9, 68 35))";
283 std::string b = "POLYGON ((20 60, 50 60, 50 30, 20 30, 20 60))";
284 std::string exp = "POLYGON ((37 30, 35 42, 50 39, 50 30, 37 30))";
285 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
286 }
287
288 // testNestedShellsIntersection
289 template<>
290 template<>
test()291 void object::test<19> ()
292 {
293 std::string a = "POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))";
294 std::string b = "POLYGON ((120 180, 180 180, 180 120, 120 120, 120 180))";
295 std::string exp = "POLYGON ((120 180, 180 180, 180 120, 120 120, 120 180))";
296 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
297 }
298
299 // testNestedShellsUnion
300 template<>
301 template<>
test()302 void object::test<20> ()
303 {
304 std::string a = "POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))";
305 std::string b = "POLYGON ((120 180, 180 180, 180 120, 120 120, 120 180))";
306 std::string exp = "POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))";
307 testOverlay(a, b, exp, OverlayNG::UNION, 1);
308 }
309
310 // testATouchingNestedPolyUnion
311 template<>
312 template<>
test()313 void object::test<21> ()
314 {
315 std::string a = "MULTIPOLYGON (((0 200, 200 200, 200 0, 0 0, 0 200), (50 50, 190 50, 50 200, 50 50)), ((60 100, 100 60, 50 50, 60 100)))";
316 std::string b = "POLYGON ((135 176, 180 176, 180 130, 135 130, 135 176))";
317 std::string exp = "MULTIPOLYGON (((0 0, 0 200, 50 200, 200 200, 200 0, 0 0), (50 50, 190 50, 50 200, 50 50)), ((50 50, 60 100, 100 60, 50 50)))";
318 testOverlay(a, b, exp, OverlayNG::UNION, 1);
319 }
320
321
322 // testTouchingPolyDifference
323 template<>
324 template<>
test()325 void object::test<22> ()
326 {
327 std::string a = "POLYGON ((200 200, 200 0, 0 0, 0 200, 200 200), (100 100, 50 100, 50 200, 100 100))";
328 std::string b = "POLYGON ((150 100, 100 100, 150 200, 150 100))";
329 std::string exp = "MULTIPOLYGON (((0 0, 0 200, 50 200, 50 100, 100 100, 150 100, 150 200, 200 200, 200 0, 0 0)), ((50 200, 150 200, 100 100, 50 200)))";
330 testOverlay(a, b, exp, OverlayNG::DIFFERENCE, 1);
331 }
332
333 // testTouchingHoleUnion
334 template<>
335 template<>
test()336 void object::test<23> ()
337 {
338 std::string a = "POLYGON ((100 300, 300 300, 300 100, 100 100, 100 300), (200 200, 150 200, 200 300, 200 200))";
339 std::string b = "POLYGON ((130 160, 260 160, 260 120, 130 120, 130 160))";
340 std::string exp = "POLYGON ((100 100, 100 300, 200 300, 300 300, 300 100, 100 100), (150 200, 200 200, 200 300, 150 200))";
341 testOverlay(a, b, exp, OverlayNG::UNION, 1);
342 }
343
344 // testTouchingMultiHoleUnion
345 template<>
346 template<>
test()347 void object::test<24> ()
348 {
349 std::string a = "POLYGON ((100 300, 300 300, 300 100, 100 100, 100 300), (200 200, 150 200, 200 300, 200 200), (250 230, 216 236, 250 300, 250 230), (235 198, 300 200, 237 175, 235 198))";
350 std::string b = "POLYGON ((130 160, 260 160, 260 120, 130 120, 130 160))";
351 std::string exp = "POLYGON ((100 300, 200 300, 250 300, 300 300, 300 200, 300 100, 100 100, 100 300), (200 300, 150 200, 200 200, 200 300), (250 300, 216 236, 250 230, 250 300), (300 200, 235 198, 237 175, 300 200))";
352 testOverlay(a, b, exp, OverlayNG::UNION, 1);
353 }
354
355 // testBoxLineIntersection
356 template<>
357 template<>
test()358 void object::test<25> ()
359 {
360 std::string a = "POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))";
361 std::string b = "LINESTRING (50 150, 150 150)";
362 std::string exp = "LINESTRING (100 150, 150 150)";
363 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
364 }
365
366 // testBoxLineUnion
367 template<>
368 template<>
test()369 void object::test<26> ()
370 {
371 std::string a = "POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))";
372 std::string b = "LINESTRING (50 150, 150 150)";
373 std::string exp = "GEOMETRYCOLLECTION (POLYGON ((100 200, 200 200, 200 100, 100 100, 100 150, 100 200)), LINESTRING (50 150, 100 150))";
374 testOverlay(a, b, exp, OverlayNG::UNION, 1);
375 }
376
377 // testAdjacentBoxesIntersection
378 template<>
379 template<>
test()380 void object::test<27> ()
381 {
382 std::string a = "POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))";
383 std::string b = "POLYGON ((300 200, 300 100, 200 100, 200 200, 300 200))";
384 std::string exp = "LINESTRING (200 100, 200 200)";
385 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
386 }
387
388 // testAdjacentBoxesUnion
389 template<>
390 template<>
test()391 void object::test<28> ()
392 {
393 std::string a = "POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))";
394 std::string b = "POLYGON ((300 200, 300 100, 200 100, 200 200, 300 200))";
395 std::string exp = "POLYGON ((100 100, 100 200, 200 200, 300 200, 300 100, 200 100, 100 100))";
396 testOverlay(a, b, exp, OverlayNG::UNION, 1);
397 }
398
399 // testCollapseBoxGoreIntersection
400 template<>
401 template<>
test()402 void object::test<29> ()
403 {
404 std::string a = "MULTIPOLYGON (((1 1, 5 1, 5 0, 1 0, 1 1)), ((1 1, 5 2, 5 4, 1 4, 1 1)))";
405 std::string b = "POLYGON ((1 0, 1 2, 2 2, 2 0, 1 0))";
406 std::string exp = "POLYGON ((2 0, 1 0, 1 1, 1 2, 2 2, 2 1, 2 0))";
407 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
408 }
409
410 // testCollapseBoxGoreUnion
411 template<>
412 template<>
test()413 void object::test<30> ()
414 {
415 std::string a = "MULTIPOLYGON (((1 1, 5 1, 5 0, 1 0, 1 1)), ((1 1, 5 2, 5 4, 1 4, 1 1)))";
416 std::string b = "POLYGON ((1 0, 1 2, 2 2, 2 0, 1 0))";
417 std::string exp = "POLYGON ((2 0, 1 0, 1 1, 1 2, 1 4, 5 4, 5 2, 2 1, 5 1, 5 0, 2 0))";
418 testOverlay(a, b, exp, OverlayNG::UNION, 1);
419 }
420
421 // testSnapBoxGoreIntersection
422 template<>
423 template<>
test()424 void object::test<31> ()
425 {
426 std::string a = "MULTIPOLYGON (((1 1, 5 1, 5 0, 1 0, 1 1)), ((1 1, 5 2, 5 4, 1 4, 1 1)))";
427 std::string b = "POLYGON ((4 3, 5 3, 5 0, 4 0, 4 3))";
428 std::string exp = "MULTIPOLYGON (((4 3, 5 3, 5 2, 4 2, 4 3)), ((4 0, 4 1, 5 1, 5 0, 4 0)))";
429 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
430 }
431
432 // testSnapBoxGoreUnion
433 template<>
434 template<>
test()435 void object::test<32> ()
436 {
437 std::string a = "MULTIPOLYGON (((1 1, 5 1, 5 0, 1 0, 1 1)), ((1 1, 5 2, 5 4, 1 4, 1 1)))";
438 std::string b = "POLYGON ((4 3, 5 3, 5 0, 4 0, 4 3))";
439 std::string exp = "POLYGON ((1 1, 1 4, 5 4, 5 3, 5 2, 5 1, 5 0, 4 0, 1 0, 1 1), (1 1, 4 1, 4 2, 1 1))";
440 testOverlay(a, b, exp, OverlayNG::UNION, 1);
441 }
442
443 // testCollapseTriBoxIntersection
444 template<>
445 template<>
test()446 void object::test<33> ()
447 {
448 std::string a = "POLYGON ((1 2, 1 1, 9 1, 1 2))";
449 std::string b = "POLYGON ((9 2, 9 1, 8 1, 8 2, 9 2))";
450 std::string exp = "LINESTRING (8 1, 9 1)";
451 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
452 }
453
454 // testCollapseTriBoxUnion
455 template<>
456 template<>
test()457 void object::test<34> ()
458 {
459 std::string a = "POLYGON ((1 2, 1 1, 9 1, 1 2))";
460 std::string b = "POLYGON ((9 2, 9 1, 8 1, 8 2, 9 2))";
461 std::string exp = "MULTIPOLYGON (((1 1, 1 2, 8 1, 1 1)), ((8 1, 8 2, 9 2, 9 1, 8 1)))";
462 testOverlay(a, b, exp, OverlayNG::UNION, 1);
463 }
464
465 // testDisjointIntersectionNoOpt
466 template<>
467 template<>
test()468 void object::test<35> ()
469 {
470 std::string a = "POLYGON ((60 90, 90 90, 90 60, 60 60, 60 90))";
471 std::string b = "POLYGON ((200 300, 300 300, 300 200, 200 200, 200 300))";
472 std::string exp = "POLYGON EMPTY";
473 testOverlayNoOpt(a, b, exp, OverlayNG::INTERSECTION, 1);
474 }
475
476 // testMultiPolygonNarrowGap
477 template<>
478 template<>
test()479 void object::test<36> ()
480 {
481 std::string a = "MULTIPOLYGON (((1 9, 5.7 9, 5.7 1, 1 1, 1 9)), ((9 9, 9 1, 6 1, 6 9, 9 9)))";
482 std::string b = "POLYGON EMPTY";
483 std::string exp = "POLYGON ((1 9, 6 9, 9 9, 9 1, 6 1, 1 1, 1 9))";
484 testOverlayNoOpt(a, b, exp, OverlayNG::UNION, 1);
485 }
486
487 // testCollapseTriBoxUnion
488 template<>
489 template<>
test()490 void object::test<37> ()
491 {
492 std::string a = "POLYGON ((1 3.3, 1.3 1.4, 3.1 1.4, 3.1 0.9, 1.3 0.9, 1 -0.2, 0.8 1.3, 1 3.3))";
493 std::string b = "POLYGON ((1 2.9, 2.9 2.9, 2.9 1.3, 1.7 1, 1.3 0.9, 1 0.4, 1 2.9))";
494 std::string exp = "MULTILINESTRING ((1 1, 1 0), (1 3, 1 1), (1 1, 2 1), (2 1, 3 1))";
495 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
496 }
497
498 // testAreaLinePointIntersection
499 template<>
500 template<>
test()501 void object::test<38> ()
502 {
503 std::string a = "POLYGON ((100 100, 200 100, 200 150, 250 100, 300 100, 300 150, 350 100, 350 200, 100 200, 100 100))";
504 std::string b = "POLYGON ((100 140, 170 140, 200 100, 400 100, 400 30, 100 30, 100 140))";
505 std::string exp = "GEOMETRYCOLLECTION (POINT (350 100), LINESTRING (250 100, 300 100), POLYGON ((100 100, 100 140, 170 140, 200 100, 100 100)))";
506 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
507 }
508
509 // testPolyPolyTouchIntersection
510 template<>
511 template<>
test()512 void object::test<39> ()
513 {
514 std::string a = "POLYGON ((300 0, 100 0, 100 100, 300 100, 300 0))";
515 std::string b = "POLYGON ((100 200, 300 200, 300 100, 200 100, 200 0, 100 0, 100 200))";
516 std::string exp = "GEOMETRYCOLLECTION (LINESTRING (200 100, 300 100), POLYGON ((200 0, 100 0, 100 100, 200 100, 200 0)))";
517 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
518 }
519
520 // testPolygonFlatCollapseIntersection
521 template<>
522 template<>
test()523 void object::test<40> ()
524 {
525 std::string a = "POLYGON ((200 100, 150 200, 250 200, 150 200, 100 100, 200 100))";
526 std::string b = "POLYGON ((50 150, 250 150, 250 50, 50 50, 50 150))";
527 std::string exp = "POLYGON ((175 150, 200 100, 100 100, 125 150, 175 150))";
528 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
529 }
530
531 // testCollapseTriBoxesIntersection
532 template<>
533 template<>
test()534 void object::test<41> ()
535 {
536 std::string a = "MULTIPOLYGON (((1 4, 1 1, 2 1, 2 4, 1 4)), ((9 4, 9 1, 10 1, 10 4, 9 4)))";
537 std::string b = "POLYGON ((0 2, 11 3, 11 2, 0 2))";
538 std::string exp = "GEOMETRYCOLLECTION (LINESTRING (1 2, 2 2), POLYGON ((9 2, 9 3, 10 3, 10 2, 9 2)))";
539 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 1);
540 }
541
542 template<>
543 template<>
test()544 void object::test<42> ()
545 {
546 std::string a = "POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 1, 1 1), (1 2, 1 3, 2 3, 1 2), (2 3, 3 3, 3 2, 2 3))";
547 std::string b = "POLYGON ((2 1, 3 1, 3 2, 2 1))";
548 std::string exp = "POLYGON ((3 2, 3 1, 2 1, 3 2))";
549 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 0);
550 }
551
552 template<>
553 template<>
test()554 void object::test<43> ()
555 {
556 set_test_name("testPolygonLineIntersectionOrder");
557 std::string a = "POLYGON ((1 1, 1 9, 9 9, 9 7, 3 7, 3 3, 9 3, 9 1, 1 1))";
558 std::string b = "MULTILINESTRING ((2 10, 2 0), (4 10, 4 0))";
559 std::string exp = "MULTILINESTRING ((2 9, 2 1), (4 9, 4 7), (4 3, 4 1))";
560 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 0);
561 }
562
563 template<>
564 template<>
test()565 void object::test<44> ()
566 {
567 set_test_name("testPolygonLineVerticalntersection");
568 std::string a = "POLYGON ((-200 -200, 200 -200, 200 200, -200 200, -200 -200))";
569 std::string b = "LINESTRING (-100 100, -100 -100)";
570 std::string exp = "LINESTRING (-100 100, -100 -100)";
571 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 0);
572 }
573
574 template<>
575 template<>
test()576 void object::test<45> ()
577 {
578 set_test_name("testPolygonLineHorizontalIntersection");
579 std::string a = "POLYGON ((10 90, 90 90, 90 10, 10 10, 10 90))";
580 std::string b = "LINESTRING (20 50, 80 50)";
581 std::string exp = "LINESTRING (20 50, 80 50)";
582 testOverlay(a, b, exp, OverlayNG::INTERSECTION, 0);
583 }
584
585 } // namespace tut
586