3 // Copyright (c) 2016 Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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)
10 #include "test_crosses.hpp"
12 #include <algorithms/overlay/overlay_cases.hpp>
13 #include <algorithms/overlay/multi_overlay_cases.hpp>
15 #include <boost/geometry/geometries/geometries.hpp>
19 void test_linestring_polygon()
21 typedef bg::model::linestring
<P
> ls
;
22 typedef bg::model::polygon
<P
> poly
;
23 typedef bg::model::polygon
<P
> ring
;
25 test_geometry
<ls
, poly
>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
26 test_geometry
<ls
, ring
>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
27 test_geometry
<ls
, poly
>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
28 test_geometry
<ls
, poly
>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
29 test_geometry
<ls
, poly
>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
30 test_geometry
<ls
, poly
>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
32 test_geometry
<ls
, poly
>("LINESTRING(9 1,10 5,9 9)",
33 "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
36 test_geometry
<ls
, poly
>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
37 "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
40 test_geometry
<ls
, poly
>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
41 "POLYGON((0 0,0 10,10 10,10 0,0 0))",
46 void test_linestring_multi_polygon()
48 typedef bg::model::linestring
<P
> ls
;
49 typedef bg::model::polygon
<P
> poly
;
50 typedef bg::model::multi_polygon
<poly
> mpoly
;
52 test_geometry
<ls
, mpoly
>("LINESTRING(10 1,10 5,10 9)",
53 "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)))",
58 void test_multi_linestring_polygon()
60 typedef bg::model::linestring
<P
> ls
;
61 typedef bg::model::polygon
<P
> poly
;
62 typedef bg::model::ring
<P
> ring
;
63 typedef bg::model::multi_linestring
<ls
> mls
;
65 test_geometry
<mls
, poly
>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
66 "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
69 test_geometry
<mls
, ring
>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
70 "POLYGON((5 5,5 15,15 15,15 5,5 5))",
73 test_geometry
<mls
, poly
>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))",
74 "POLYGON((0 0,0 10,10 10,10 0,0 0))",
79 void test_multi_linestring_multi_polygon()
81 typedef bg::model::linestring
<P
> ls
;
82 typedef bg::model::polygon
<P
> poly
;
83 typedef bg::model::multi_linestring
<ls
> mls
;
84 typedef bg::model::multi_polygon
<poly
> mpoly
;
86 test_geometry
<mls
, mpoly
>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))",
87 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))",
90 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))",
91 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
94 test_geometry
<mls
, mpoly
>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
95 "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
100 template <typename P
>
103 test_linestring_polygon
<P
>();
104 test_linestring_multi_polygon
<P
>();
105 test_multi_linestring_polygon
<P
>();
106 test_multi_linestring_multi_polygon
<P
>();
110 int test_main( int , char* [] )
112 test_all
<bg::model::point
<double, 2, bg::cs::spherical_equatorial
<bg::degree
> > >();
114 #if defined(HAVE_TTMATH)
115 test_cs
<bg::model::point
<ttmath_big
, 2, bg::cs::spherical_equatorial
<bg::degree
> > >();