]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/touches/touches.cpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / relational_operations / touches / touches.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2//
3// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
4
5// This file was modified by Oracle on 2013, 2014. 2015.
6// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
7
8// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#include "test_touches.hpp"
15
16template <typename P>
17void test_all()
18{
b32b8144 19 typedef bg::model::multi_point<P> mpoint;
7c673cae
FG
20 typedef bg::model::ring<P> ring;
21 typedef bg::model::polygon<P> polygon;
22 typedef bg::model::linestring<P> linestring;
23 typedef bg::model::multi_polygon<polygon> mpolygon;
24 typedef bg::model::multi_linestring<linestring> mlinestring;
25
26 // Touching at corner
27 test_touches<polygon, polygon>
28 (
29 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
30 "POLYGON((100 100,100 200,200 200, 200 100,100 100))",
31 true
32 );
33
34 // Intersecting at corner
35 test_touches<polygon, polygon>
36 (
37 "POLYGON((0 0,0 100,101 101,100 0,0 0))",
38 "POLYGON((100 100,100 200,200 200, 200 100,100 100))",
39 false
40 );
41
42 // Touching at side (interior of a segment)
43 test_touches<polygon, polygon>
44 (
45 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
46 "POLYGON((200 0,100 50,200 100,200 0))",
47 true
48 );
49
50 // Touching at side (partly collinear)
51 test_touches<polygon, polygon>
52 (
53 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
54 "POLYGON((200 20,100 20,100 80,200 80,200 20))",
55 true
56 );
57
58 // Completely equal
59 test_touches<polygon, polygon>
60 (
61 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
62 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
63 false
64 );
65
66 // Spatially equal
67 test_touches<polygon, polygon>
68 (
69 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
70 "POLYGON((0 0,0 100,100 100,100 80,100 20,100 0,0 0))",
71 false
72 );
73
74 // Spatially equal (without equal segments)
75 test_touches<polygon, polygon>
76 (
77 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
78 "POLYGON((0 0,0 50,0 100,50 100,100 100,100 50,100 0,50 0,0 0))",
79 false
80 );
81
82
83 // Touching at side (opposite equal)
84 test_touches<polygon, polygon>
85 (
86 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
87 "POLYGON((200 0,100 0,100 100,200 100,200 0))",
88 true
89 );
90
91 // Touching at side (opposite equal - but with real "equal" turning point)
92 test_touches<polygon, polygon>
93 (
94 "POLYGON((0 0,0 100,100 100,100 80,100 20,100 0,0 0))",
95 "POLYGON((200 0,100 0,100 20,100 80,100 100,200 100,200 0))",
96 true
97 );
98 // First partly collinear to side, than overlapping
99 test_touches<polygon, polygon>
100 (
101 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
102 "POLYGON((200 20,100 20,100 50,50 50,50 80,100 80,200 80,200 20))",
103 false
104 );
105
106 // Touching interior (= no touch)
107 test_touches<polygon, polygon>
108 (
109 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
110 "POLYGON((20 20,20 80,100 50,20 20))",
111 false
112 );
113
114 // Fitting in hole
115 test_touches<polygon, polygon>
116 (
117 "POLYGON((0 0,0 100,100 100,100 0,0 0),(40 40,60 40,60 60,40 60,40 40))",
118 "POLYGON((40 40,40 60,60 60,60 40,40 40))",
119 true
120 );
121
122 // mysql 21873343
123 test_touches<polygon, polygon>
124 (
125 "POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
126 "POLYGON((0 8,-8 5,-8 8,0 8))",
127 true
128 );
129 test_touches<polygon, polygon>
130 (
131 "POLYGON((0 0,0 10,10 10,10 0,0 0), (0 6, 6 3, 6 6, 0 6))",
132 "POLYGON((0 6,-6 3,-6 6,0 6))",
133 true
134 );
135
136 // Point-Polygon
137 test_touches<P, ring>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
138 test_touches<P, polygon>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
139 test_touches<P, polygon>("POINT(60 60)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
140 test_touches<P, polygon>("POINT(50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
141 test_touches<P, polygon>("POINT(30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
142
143 // Point-MultiPolygon
144 test_touches<P, mpolygon>("POINT(40 50)", "MULTIPOLYGON(((40 40,40 60,60 60,60 40,40 40)),((0 0,0 10,10 10,10 0)))", true);
145
146 // Point-Linestring
147 test_touches<P, linestring>("POINT(0 0)", "LINESTRING(0 0, 2 2, 10 2)", true);
148 test_touches<P, linestring>("POINT(2 2)", "LINESTRING(0 0, 2 2, 10 2)", false);
149 test_touches<P, linestring>("POINT(1 1)", "LINESTRING(0 0, 2 2, 10 2)", false);
150 test_touches<P, linestring>("POINT(5 5)", "LINESTRING(0 0, 2 2, 10 2)", false);
151
152 // Point-MultiLinestring
153 test_touches<P, mlinestring>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(5 5, 6 6))", true);
154 test_touches<P, mlinestring>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(0 0, 6 6))", false);
155
b32b8144
FG
156 // MultiPoint-Polygon
157 test_touches<mpoint, ring>("MULTIPOINT(40 50, 30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
158 test_touches<mpoint, polygon>("MULTIPOINT(40 50, 50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
159
7c673cae
FG
160 // Linestring-Linestring
161 test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(0 0,0 2)", true);
162 test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(2 0,2 2)", true);
163 test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(0 2,0 0)", true);
164 test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(2 2,2 0)", true);
165 test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(0 0,0 2)", true);
166 test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(2 0,2 2)", true);
167 test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(0 2,0 0)", true);
168 test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(2 2,2 0)", true);
169 test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(1 0,1 1)", true);
170 test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(1 1,1 0)", true);
171 test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(1 0,1 1)", true);
172 test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(1 1,1 0)", true);
173
174 test_touches<linestring, linestring>("LINESTRING(0 0,10 0)", "LINESTRING(0 0,5 5,10 0)", true);
175 test_touches<linestring, linestring>("LINESTRING(0 0,10 10)", "LINESTRING(0 0,0 5,10 5)", false);
176
177 test_touches<linestring, linestring>("LINESTRING(0 5,5 6,10 5)", "LINESTRING(0 7,5 6,10 7)", false);
178 test_touches<linestring, linestring>("LINESTRING(0 5,5 6,10 5)", "LINESTRING(10 7,5 6,0 7)", false);
179 test_touches<linestring, linestring>("LINESTRING(10 5,5 6,0 5)", "LINESTRING(0 7,5 6,10 7)", false);
180 test_touches<linestring, linestring>("LINESTRING(10 5,5 6,0 5)", "LINESTRING(10 7,5 6,0 7)", false);
181
182 test_touches<linestring, linestring>("LINESTRING(0 0,1 1,2 2)", "LINESTRING(2 0,2 2,1 2,1 1)", true);
183 test_touches<linestring, linestring>("LINESTRING(2 2,1 1,0 0)", "LINESTRING(2 0,2 2,1 2,1 1)", true);
184 test_touches<linestring, linestring>("LINESTRING(0 0,1 1,2 2)", "LINESTRING(1 1,1 2,2 2,2 0)", true);
185 test_touches<linestring, linestring>("LINESTRING(2 2,1 1,0 0)", "LINESTRING(1 1,1 2,2 2,2 0)", true);
186
187 test_touches<linestring, linestring>("LINESTRING(0 0,1 1,0 1)", "LINESTRING(1 1,2 2,1 2,1 1)", false);
188
189 test_touches<linestring, mlinestring>("LINESTRING(0 0,1 1,0 1)", "MULTILINESTRING((1 1,2 2),(1 2,1 1))", false);
190
191 //Linestring-Polygon
192 test_touches<linestring, polygon>("LINESTRING(10 0,15 5,10 10,5 15,5 10,0 10,5 15,5 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
193 test_touches<linestring, polygon>("LINESTRING(5 10,5 15,0 10,5 10,5 15,10 10,15 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
194 test_touches<linestring, polygon>("LINESTRING(5 10,5 15,0 10,5 10,5 15,10 10,5 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
195 test_touches<linestring, ring>("LINESTRING(0 15,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
196 test_touches<linestring, polygon>("LINESTRING(0 15,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
197 test_touches<linestring, polygon>("LINESTRING(0 15,5 10,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
198 test_touches<linestring, polygon>("LINESTRING(10 15,5 10,0 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
199
200 test_touches<linestring, polygon>("LINESTRING(0 0,3 3)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0))", true);
201
202 test_touches<linestring, mpolygon>("LINESTRING(-1 -1,3 3)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", true);
203
204 test_touches<mlinestring, mpolygon>("MULTILINESTRING((0 0,11 11))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", false);
205}
206
207int test_main( int , char* [] )
208{
209 test_all<bg::model::d2::point_xy<double> >();
210
211#if defined(HAVE_TTMATH)
212 test_all<bg::model::d2::point_xy<ttmath_big> >();
213#endif
214
215 return 0;
216}
217
218/*
219with viewy as
220(
221select geometry::STGeomFromText('POLYGON((0 0,0 100,100 100,100 0,0 0))',0) as p
222 , geometry::STGeomFromText('POLYGON((200 0,100 50,200 100,200 0))',0) as q
223)
224-- select p from viewy union all select q from viewy
225select p.STTouches(q) from viewy
226*/