]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. | |
5 | ||
6 | // This file was modified by Oracle on 2014, 2015, 2016. | |
7 | // Modifications copyright (c) 2014-2016 Oracle and/or its affiliates. | |
8 | ||
9 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
10 | ||
11 | // Use, modification and distribution is subject to the Boost Software License, | |
12 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
13 | // http://www.boost.org/LICENSE_1_0.txt) | |
14 | ||
15 | #include "test_within.hpp" | |
16 | ||
17 | ||
18 | #include <boost/geometry/geometries/geometries.hpp> | |
19 | #include <boost/geometry/geometries/point_xy.hpp> | |
20 | #include <boost/geometry/geometries/multi_linestring.hpp> | |
21 | #include <boost/geometry/geometries/multi_polygon.hpp> | |
22 | ||
23 | template <typename P1, typename P2> | |
24 | void test_l_a() | |
25 | { | |
26 | typedef bg::model::linestring<P1> ls; | |
27 | typedef bg::model::multi_linestring<ls> mls; | |
28 | typedef bg::model::polygon<P2> poly; | |
29 | typedef bg::model::ring<P2> ring; | |
30 | typedef bg::model::multi_polygon<poly> mpoly; | |
31 | ||
32 | // B,I | |
33 | test_geometry<ls, ring>("LINESTRING(0 0, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); | |
34 | ||
35 | // B,I | |
36 | test_geometry<ls, poly>("LINESTRING(0 0, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); | |
37 | // I | |
38 | test_geometry<ls, poly>("LINESTRING(1 1, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); | |
39 | // I,E | |
40 | test_geometry<ls, poly>("LINESTRING(1 1, 6 6)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false); | |
41 | // B | |
42 | test_geometry<ls, poly>("LINESTRING(0 0, 5 0)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false); | |
43 | test_geometry<ls, poly>("LINESTRING(0 0, 0 5)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false); | |
44 | // E | |
45 | test_geometry<ls, poly>("LINESTRING(6 0, 6 5)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false); | |
46 | ||
47 | // BIBIB | |
48 | test_geometry<ls, mpoly>("LINESTRING(0 0, 10 10)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true); | |
49 | // BIBEBIB | |
50 | test_geometry<ls, mpoly>("LINESTRING(0 0, 10 10)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((6 6,5 10,10 10,10 5,6 6)))", false); | |
51 | ||
52 | // MySQL report 18.12.2014 (https://svn.boost.org/trac/boost/ticket/10887) | |
53 | test_geometry<ls, mpoly>("LINESTRING(5 -2,5 2)", | |
54 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
55 | true); | |
56 | test_geometry<ls, mpoly>("LINESTRING(5 -2,5 5)", | |
57 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
58 | true); | |
59 | test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)", | |
60 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
61 | true); | |
62 | // MySQL report 18.12.2014 - extended | |
63 | test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)", | |
64 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))", | |
65 | true); | |
66 | test_geometry<ls, mpoly>("LINESTRING(0 0,5 0)", | |
67 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))", | |
68 | false); | |
69 | test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))", | |
70 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
71 | true); | |
72 | test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 0,0 -1,5 0))", | |
73 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
74 | false); | |
75 | test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(6 -2,5 0))", | |
76 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
77 | true); | |
78 | test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 -1,5 0))", | |
79 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
80 | false); | |
81 | test_geometry<mls, mpoly>("MULTILINESTRING((0 0,5 0),(5 -2,5 0))", | |
82 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
83 | false); | |
84 | test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,5 0),(0 0,5 0))", | |
85 | "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", | |
86 | false); | |
87 | ||
88 | // BI | |
89 | test_geometry<mls, poly>("MULTILINESTRING((0 0,2 2),(2 2,3 3))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); | |
90 | // I E | |
91 | test_geometry<mls, poly>("MULTILINESTRING((1 1,2 2),(6 6,7 7))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false); | |
92 | ||
93 | // I I | |
94 | test_geometry<mls, mpoly>("MULTILINESTRING((1 1,5 5),(6 6,7 7))", | |
95 | "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", | |
96 | true); | |
97 | // I E | |
98 | test_geometry<mls, mpoly>("MULTILINESTRING((1 1,5 5),(11 11,12 12))", | |
99 | "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", | |
100 | false); | |
101 | } | |
102 | ||
103 | template <typename P1, typename P2> | |
104 | void test_all() | |
105 | { | |
106 | test_l_a<P1, P2>(); | |
107 | } | |
108 | ||
109 | template <typename P> | |
110 | void test_all() | |
111 | { | |
112 | test_l_a<P, P>(); | |
113 | } | |
114 | ||
115 | int test_main( int , char* [] ) | |
116 | { | |
117 | test_all<bg::model::d2::point_xy<int> >(); | |
118 | test_all<bg::model::d2::point_xy<double> >(); | |
119 | test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >(); | |
120 | ||
7c673cae FG |
121 | return 0; |
122 | } |