]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/touches/touches.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2013, 2014. 2015.
6 // Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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)
14 #include "test_touches.hpp"
19 typedef bg::model::ring
<P
> ring
;
20 typedef bg::model::polygon
<P
> polygon
;
21 typedef bg::model::linestring
<P
> linestring
;
22 typedef bg::model::multi_polygon
<polygon
> mpolygon
;
23 typedef bg::model::multi_linestring
<linestring
> mlinestring
;
26 test_touches
<polygon
, polygon
>
28 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
29 "POLYGON((100 100,100 200,200 200, 200 100,100 100))",
33 // Intersecting at corner
34 test_touches
<polygon
, polygon
>
36 "POLYGON((0 0,0 100,101 101,100 0,0 0))",
37 "POLYGON((100 100,100 200,200 200, 200 100,100 100))",
41 // Touching at side (interior of a segment)
42 test_touches
<polygon
, polygon
>
44 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
45 "POLYGON((200 0,100 50,200 100,200 0))",
49 // Touching at side (partly collinear)
50 test_touches
<polygon
, polygon
>
52 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
53 "POLYGON((200 20,100 20,100 80,200 80,200 20))",
58 test_touches
<polygon
, polygon
>
60 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
61 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
66 test_touches
<polygon
, polygon
>
68 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
69 "POLYGON((0 0,0 100,100 100,100 80,100 20,100 0,0 0))",
73 // Spatially equal (without equal segments)
74 test_touches
<polygon
, polygon
>
76 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
77 "POLYGON((0 0,0 50,0 100,50 100,100 100,100 50,100 0,50 0,0 0))",
82 // Touching at side (opposite equal)
83 test_touches
<polygon
, polygon
>
85 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
86 "POLYGON((200 0,100 0,100 100,200 100,200 0))",
90 // Touching at side (opposite equal - but with real "equal" turning point)
91 test_touches
<polygon
, polygon
>
93 "POLYGON((0 0,0 100,100 100,100 80,100 20,100 0,0 0))",
94 "POLYGON((200 0,100 0,100 20,100 80,100 100,200 100,200 0))",
97 // First partly collinear to side, than overlapping
98 test_touches
<polygon
, polygon
>
100 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
101 "POLYGON((200 20,100 20,100 50,50 50,50 80,100 80,200 80,200 20))",
105 // Touching interior (= no touch)
106 test_touches
<polygon
, polygon
>
108 "POLYGON((0 0,0 100,100 100,100 0,0 0))",
109 "POLYGON((20 20,20 80,100 50,20 20))",
114 test_touches
<polygon
, polygon
>
116 "POLYGON((0 0,0 100,100 100,100 0,0 0),(40 40,60 40,60 60,40 60,40 40))",
117 "POLYGON((40 40,40 60,60 60,60 40,40 40))",
122 test_touches
<polygon
, polygon
>
124 "POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
125 "POLYGON((0 8,-8 5,-8 8,0 8))",
128 test_touches
<polygon
, polygon
>
130 "POLYGON((0 0,0 10,10 10,10 0,0 0), (0 6, 6 3, 6 6, 0 6))",
131 "POLYGON((0 6,-6 3,-6 6,0 6))",
136 test_touches
<P
, ring
>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
137 test_touches
<P
, polygon
>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
138 test_touches
<P
, polygon
>("POINT(60 60)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
139 test_touches
<P
, polygon
>("POINT(50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
140 test_touches
<P
, polygon
>("POINT(30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
142 // Point-MultiPolygon
143 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);
146 test_touches
<P
, linestring
>("POINT(0 0)", "LINESTRING(0 0, 2 2, 10 2)", true);
147 test_touches
<P
, linestring
>("POINT(2 2)", "LINESTRING(0 0, 2 2, 10 2)", false);
148 test_touches
<P
, linestring
>("POINT(1 1)", "LINESTRING(0 0, 2 2, 10 2)", false);
149 test_touches
<P
, linestring
>("POINT(5 5)", "LINESTRING(0 0, 2 2, 10 2)", false);
151 // Point-MultiLinestring
152 test_touches
<P
, mlinestring
>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(5 5, 6 6))", true);
153 test_touches
<P
, mlinestring
>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(0 0, 6 6))", false);
155 // Linestring-Linestring
156 test_touches
<linestring
, linestring
>("LINESTRING(0 0,2 0)", "LINESTRING(0 0,0 2)", true);
157 test_touches
<linestring
, linestring
>("LINESTRING(0 0,2 0)", "LINESTRING(2 0,2 2)", true);
158 test_touches
<linestring
, linestring
>("LINESTRING(0 0,2 0)", "LINESTRING(0 2,0 0)", true);
159 test_touches
<linestring
, linestring
>("LINESTRING(0 0,2 0)", "LINESTRING(2 2,2 0)", true);
160 test_touches
<linestring
, linestring
>("LINESTRING(2 0,0 0)", "LINESTRING(0 0,0 2)", true);
161 test_touches
<linestring
, linestring
>("LINESTRING(2 0,0 0)", "LINESTRING(2 0,2 2)", true);
162 test_touches
<linestring
, linestring
>("LINESTRING(2 0,0 0)", "LINESTRING(0 2,0 0)", true);
163 test_touches
<linestring
, linestring
>("LINESTRING(2 0,0 0)", "LINESTRING(2 2,2 0)", true);
164 test_touches
<linestring
, linestring
>("LINESTRING(0 0,2 0)", "LINESTRING(1 0,1 1)", true);
165 test_touches
<linestring
, linestring
>("LINESTRING(0 0,2 0)", "LINESTRING(1 1,1 0)", true);
166 test_touches
<linestring
, linestring
>("LINESTRING(2 0,0 0)", "LINESTRING(1 0,1 1)", true);
167 test_touches
<linestring
, linestring
>("LINESTRING(2 0,0 0)", "LINESTRING(1 1,1 0)", true);
169 test_touches
<linestring
, linestring
>("LINESTRING(0 0,10 0)", "LINESTRING(0 0,5 5,10 0)", true);
170 test_touches
<linestring
, linestring
>("LINESTRING(0 0,10 10)", "LINESTRING(0 0,0 5,10 5)", false);
172 test_touches
<linestring
, linestring
>("LINESTRING(0 5,5 6,10 5)", "LINESTRING(0 7,5 6,10 7)", false);
173 test_touches
<linestring
, linestring
>("LINESTRING(0 5,5 6,10 5)", "LINESTRING(10 7,5 6,0 7)", false);
174 test_touches
<linestring
, linestring
>("LINESTRING(10 5,5 6,0 5)", "LINESTRING(0 7,5 6,10 7)", false);
175 test_touches
<linestring
, linestring
>("LINESTRING(10 5,5 6,0 5)", "LINESTRING(10 7,5 6,0 7)", false);
177 test_touches
<linestring
, linestring
>("LINESTRING(0 0,1 1,2 2)", "LINESTRING(2 0,2 2,1 2,1 1)", true);
178 test_touches
<linestring
, linestring
>("LINESTRING(2 2,1 1,0 0)", "LINESTRING(2 0,2 2,1 2,1 1)", true);
179 test_touches
<linestring
, linestring
>("LINESTRING(0 0,1 1,2 2)", "LINESTRING(1 1,1 2,2 2,2 0)", true);
180 test_touches
<linestring
, linestring
>("LINESTRING(2 2,1 1,0 0)", "LINESTRING(1 1,1 2,2 2,2 0)", true);
182 test_touches
<linestring
, linestring
>("LINESTRING(0 0,1 1,0 1)", "LINESTRING(1 1,2 2,1 2,1 1)", false);
184 test_touches
<linestring
, mlinestring
>("LINESTRING(0 0,1 1,0 1)", "MULTILINESTRING((1 1,2 2),(1 2,1 1))", false);
187 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);
188 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);
189 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);
190 test_touches
<linestring
, ring
>("LINESTRING(0 15,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
191 test_touches
<linestring
, polygon
>("LINESTRING(0 15,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
192 test_touches
<linestring
, polygon
>("LINESTRING(0 15,5 10,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
193 test_touches
<linestring
, polygon
>("LINESTRING(10 15,5 10,0 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
195 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);
197 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);
199 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);
202 int test_main( int , char* [] )
204 test_all
<bg::model::d2::point_xy
<double> >();
206 #if defined(HAVE_TTMATH)
207 test_all
<bg::model::d2::point_xy
<ttmath_big
> >();
216 select geometry::STGeomFromText('POLYGON((0 0,0 100,100 100,100 0,0 0))',0) as p
217 , geometry::STGeomFromText('POLYGON((200 0,100 50,200 100,200 0))',0) as q
219 -- select p from viewy union all select q from viewy
220 select p.STTouches(q) from viewy