1// Boost.Geometry
2// Unit Test
3
4// Copyright (c) 2016, Oracle and/or its affiliates.
5// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7// Use, modification and distribution is subject to the Boost Software License,
8// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10
11
12#include "test_get_turns.hpp"
13#include <boost/geometry/geometries/geometries.hpp>
14
15
16template <typename T>
17void test_all()
18{
19 typedef bg::model::point<T, 2, bg::cs::spherical_equatorial<bg::degree> > pt;
20 typedef bg::model::linestring<pt> ls;
21 typedef bg::model::polygon<pt> poly;
22
23 test_geometry<ls, poly>("LINESTRING(15 5,24 5,20 2,19 0,13 -4,1 0,10 0,13 3.0027386970408236,15 7,16 10.096620161421658,10 10.151081711048134,8 10.145026423873857,4 6.0128694190616088,2 8.0210217579873273,1 10.028657322246225)",
24 "POLYGON((0 0,5 5,0 10,20 10,20 2,19 0,0 0)(10 3,15 3,15 7,10 7,10 3))",
25 expected(ex: "miu+")("iuu+")("tcc+")("tuu=")("mcu+")("mic=")("muu+")
26 ("tiu+")("mcu+")("mic=")("mcc+")("miu=")("mxu+"));
27
28 test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
29 "miu+", "mxu+");
30 test_geometry<ls, poly>("LINESTRING(0 0,5 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
31 "tiu+", "txu+");
32 test_geometry<ls, poly>("LINESTRING(0 0,5 0,5 5,10 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
33 expected(ex: "tcu+")("mic=")("mcc+")("txu="));
34 test_geometry<ls, poly>("LINESTRING(10 0,5 0,5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
35 expected(ex: "tcc+")("miu=")("mcu+")("txc="));
36
37 test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10.151081711048134)",
38 "POLYGON((0 0,5 5,0 10,20 10,20 2,19 0,0 0)(10 3,15 3,15 7,10 7,10 3))",
39 expected(ex: "tcu+")("mic=")("mcu+")("mic=")("mxu+"));
40
41 test_geometry<ls, poly>("LINESTRING(11 1,10 0,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
42 "tcc+", "txu=");
43 test_geometry<ls, poly>("LINESTRING(0 0,10 0,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
44 "tcu+", "tuc=");
45 test_geometry<ls, poly>("LINESTRING(10 0,0 0,-1 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
46 "tcc+", "tuu=");
47
48 // true hole
49 test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
50 "POLYGON((0 0,0 10,10 10,10 5,10 0,0 0)(2 2,10 5,2 8,2 2))",
51 expected(ex: "tiu+")("tiu+"));
52 test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
53 "POLYGON((0 0,0 10,10 10,10 5,10 0,0 0)(2 2,10 5,2 8,2 2))",
54 expected(ex: "mcu+")("ecc=")("tiu+")("mxc="));
55
56 // fake hole
57 test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
58 "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
59 expected(ex: "tuu+")("tiu+"));
60 test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
61 "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
62 expected(ex: "mcu+")("tuc=")("tcu+")("mxc="));
63
64 // true hole
65 test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 2)",
66 "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
67 expected(ex: "mcu+")("mic=")("tcu+")("txc="));
68 test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 8)",
69 "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
70 expected(ex: "mcu+")("mic=")("tcc+")("txu="));
71
72 // SPIKE - NON-ENDPOINT - NON-OPPOSITE
73
74 // spike - neq eq
75 test_geometry<ls, poly>("LINESTRING(2 2.0036594926050877,4 4,1 1.0022887548647630)",
76 "POLYGON((0 0,4 4,6 3,6 0,0 0))",
77 expected(ex: "mcc+")("txu=")("tcu=")("mxc="));
78 // spike - eq eq
79 test_geometry<ls, poly>("LINESTRING(0 0,4 4,1 1.0022887548647630)",
80 "POLYGON((0 0,4 4,6 3,6 0,0 0))",
81 expected(ex: "tcc+")("txu=")("tcu=")("mxc="));
82 // spike - eq neq
83 test_geometry<ls, poly>("LINESTRING(0 0,3 3.0031983963093536,1 1.0022887548647630)",
84 "POLYGON((0 0,4 4,6 3,6 0,0 0))",
85 expected(ex: "tcc+")("mxu=")("mcu=")("mxc="));
86 // spike - neq neq
87 test_geometry<ls, poly>("LINESTRING(1 1.0022887548647630,3 3.0031983963093536,2 2.0036594926050877)",
88 "POLYGON((0 0,4 4,6 3,6 0,0 0))",
89 expected(ex: "mcc+")("mxu=")("mcu=")("mxc="));
90 // spike - out neq
91 test_geometry<ls, poly>("LINESTRING(0 -0.0030515201230775146,3 3.0024370300767784,2 2.0021346673827409)",
92 "POLYGON((1 1,4 4,6 3,6 0,1 1))",
93 expected(ex: "mcc+")("mxu=")("mcu=")("mxc="));
94 // spike - out eq
95 test_geometry<ls, poly>("LINESTRING(0 -0.0030515201230775146,4 4,2 2.0021346673827409)",
96 "POLYGON((1 1,4 4,6 3,6 0,1 1))",
97 expected(ex: "mcc+")("txu=")("tcu=")("mxc="));
98 // spike - out out/eq
99 test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2.0036594926050877)",
100 "POLYGON((1 0,4 4,6 3,1 0))",
101 expected(ex: "tuu+"));
102 test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2.0036594926050877)",
103 "POLYGON((0 1,4 4,6 3,6 0,-1 -1,0 1))",
104 expected(ex: "tiu+"));
105 // spike - out out/neq
106 test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2.0036594926050877)",
107 "POLYGON((4 0,4 5,6 3,4 0))",
108 expected(ex: "muu+"));
109 test_geometry<ls, poly>("LINESTRING(0 0,4 4.0024308111527205,2 2.0048800944714089)",
110 "POLYGON((0 4,5 4,6 3,6 0,-1 -1,0 4))",
111 expected(ex: "miu+"));
112
113 test_geometry<ls, poly>("LINESTRING(0 1,1 1.0012195839797347,0 1)",
114 "POLYGON((0 0,3 3,3 0,0 0))",
115 expected(ex: "muu+"));
116 test_geometry<ls, poly>("LINESTRING(0 1,3 3,0 1)",
117 "POLYGON((0 0,3 3,3 0,0 0))",
118 expected(ex: "tuu+"));
119 test_geometry<ls, poly>("LINESTRING(0 1,0 0,0 1)",
120 "POLYGON((0 0,3 3,3 0,0 0))",
121 expected(ex: "tuu+"));
122
123 // SPIKE - NON-ENDPOINT - OPPOSITE
124
125 // opposite - eq eq
126 test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
127 "POLYGON((-1 -1,0 0,4 4,6 3,-1 -1))",
128 expected(ex: "tcu+")("txc=")("tcc=")("mxu="));
129 // opposite - neq eq
130 test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
131 "POLYGON((-1 -1,0 0,5 4.9931712414532354,6 3,-1 -1))",
132 expected(ex: "mcu+")("txc=")("tcc=")("mxu="));
133 // opposite - eq, neq
134 test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
135 "POLYGON((-2 -2,-1 -1.0022887548647628,4 4,6 3,-2 -2))",
136 expected(ex: "tcu+")("mxc=")("mcc=")("mxu="));
137 // opposite - neq neq
138 test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
139 "POLYGON((-2 -2,-1 -1.0022887548647628,3 3.0031983963093536,6 3,-2 -2))",
140 expected(ex: "mcu+")("mxc=")("mcc=")("mxu="));
141 // opposite - neq neq
142 test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
143 "POLYGON((-2 -2,-1 -1.0022887548647628,3 3.0031983963093536,5 4.9931712414532354,6 3,-2 -2))",
144 expected(ex: "mcu+")("mxc=")("mcc=")("mxu="));
145
146 // spike vs internal
147 test_geometry<ls, poly>("LINESTRING(0 1,1 1,0 1)", // --
148 "POLYGON((1 0,1 1,2 1,1 0))",
149 expected(ex: "tuu+"));
150 test_geometry<ls, poly>("LINESTRING(1 2,1 1,1 2)", // |
151 "POLYGON((1 0,1 1,2 1,1 0))",
152 expected(ex: "tuu+"));
153 test_geometry<ls, poly>("LINESTRING(0 2,1 1,0 2)", // \ (avoid multi-line comment)
154 "POLYGON((1 0,1 1,2 1,1 0))",
155 expected(ex: "tuu+"));
156 test_geometry<ls, poly>("LINESTRING(2 0,1 1,2 0)", // \ (avoid multi-line comment)
157 "POLYGON((1 0,1 1,2 1,2 0,1 0))",
158 expected(ex: "tiu+")("tiu+")("txu+")); // TODO: should spike point be duplicated?
159 test_geometry<ls, poly>("LINESTRING(0 0,1 1,0 0)", // /
160 "POLYGON((1 0,1 1,2 1,1 0))",
161 expected(ex: "tuu+"));
162 test_geometry<ls, poly>("LINESTRING(2 2,1 1,2 2)", // /
163 "POLYGON((1 0,1 1,2 1,1 0))",
164 expected(ex: "tuu+"));
165
166 test_geometry<ls, poly>("LINESTRING(2 1,1 1,2 1)", // --
167 "POLYGON((1 0,1 1,2 1,1 0))",
168 expected(ex: "tcu+")("txc=")("tcc=")("txu="));
169
170 // 21.01.2015
171 test_geometry<ls, poly>("LINESTRING(1 2.9977189008308085,3 1.0004570537241195)",
172 "POLYGON((0 0,0 4,4 4,4 0,2 2,0 0))",
173 expected(ex: "mcu+")("mxc="));
174
175 // extended
176 test_geometry<ls, poly>("LINESTRING(1 6.9651356719477091,4 4,7 1.0022887548647630)",
177 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
178 expected(ex: "tcu+")("mxc="));
179 test_geometry<ls, poly>("LINESTRING(1 6.9651356719477091,3 4.9931712414532363,7 1.0022887548647630)",
180 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
181 expected(ex: "mcu+")("mxc="));
182 test_geometry<ls, poly>("LINESTRING(1 6.9651356719477091,5 3.0031983963093536,7 1.0022887548647630)",
183 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
184 expected(ex: "mcu+")("mxc="));
185 test_geometry<ls, poly>("LINESTRING(4 4,7 1.0022887548647630)",
186 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
187 expected(ex: "tcu+")("mxc="));
188 test_geometry<ls, poly>("LINESTRING(5 3.0031983963093536,7 1.0022887548647630)",
189 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
190 expected(ex: "mcu+")("mxc="));
191 // reversed
192 test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,4 4,1 6.9651356719477091)",
193 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
194 expected(ex: "mcc+")("tiu="));
195 test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,3 4.9931712414532363,1 6.9651356719477091)",
196 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
197 expected(ex: "mcc+")("miu="));
198 test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,5 3.0031983963093536,1 6.9651356719477091)",
199 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
200 expected(ex: "mcc+")("ccc=")("miu="));
201 test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,4 4)",
202 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
203 expected(ex: "mcc+")("txu="));
204 test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,5 3.0031983963093536)",
205 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
206 expected(ex: "mcc+")("mxu="));
207 test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,3 4.9931712414532363)",
208 "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
209 expected(ex: "mcc+")("miu="));
210
211 // 23.01.2015 - spikes
212 test_geometry<ls, poly>("LINESTRING(3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 1.7773315888299086)",
213 "POLYGON((0 0,0 10,10 10,10 0,0 0))",
214 expected(ex: "miu+")("miu+")("miu+")("mxu+"));
215 test_geometry<ls, poly>("LINESTRING(7 8, 6 10.035925377760330, 11 -0.31552621163523403)",
216 "POLYGON((0 0,0 10,10 10,10 0,0 0))",
217 expected(ex: "miu+")("iuu+"));
218
219 // 25.01.2015
220 test_geometry<ls, poly>("LINESTRING(2 3, 4 5, 0 5.9782377228588262, 5 6.0009072995372446)",
221 "POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))",
222 expected(ex: "miu+")("miu+")("mcu+")("mxc="));
223 test_geometry<ls, poly>("LINESTRING(0 5.9782377228588262, 5 6.0009072995372446)",
224 "POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))",
225 expected(ex: "miu+")("mcu+")("mxc="));
226}
227
228int test_main(int, char* [])
229{
230 test_all<float>();
231 test_all<double>();
232
233//#if ! defined(_MSC_VER)
234// test_all<long double>();
235//#endif
236
237 return 0;
238}
239

source code of boost/libs/geometry/test/algorithms/overlay/get_turns_linear_areal_sph.cpp