]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Unit Test | |
3 | ||
4 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
6 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
7 | ||
8 | // This file was modified by Oracle on 2014, 2015. | |
9 | // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. | |
10 | ||
11 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
12 | ||
13 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
14 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
15 | ||
16 | // Use, modification and distribution is subject to the Boost Software License, | |
17 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
18 | // http://www.boost.org/LICENSE_1_0.txt) | |
19 | ||
20 | #include "test_get_turns.hpp" | |
21 | #include <boost/geometry/geometries/geometries.hpp> | |
22 | ||
23 | //TEST | |
24 | //#include <to_svg.hpp> | |
25 | ||
26 | template <typename T> | |
27 | void test_all() | |
28 | { | |
29 | typedef bg::model::point<T, 2, bg::cs::cartesian> pt; | |
30 | typedef bg::model::linestring<pt> ls; | |
31 | typedef bg::model::polygon<pt> poly; | |
32 | ||
33 | test_geometry<ls, poly>("LINESTRING(15 5,24 5,20 2,19 0,13 -4,1 0,10 0,13 3,15 7,16 10,10 10,8 10,4 6,2 8,1 10)", | |
34 | "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))", | |
35 | expected("miu+")("iuu+")("tcc+")("tuu=")("mcu+")("mic=")("muu+") | |
36 | ("tiu+")("mcu+")("mic=")("mcc+")("miu=")("mxu+")); | |
37 | ||
38 | test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
39 | "miu+", "mxu+"); | |
40 | test_geometry<ls, poly>("LINESTRING(0 0,5 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
41 | "tiu+", "txu+"); | |
42 | 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))", | |
43 | expected("tcu+")("mic=")("mcc+")("txu=")); | |
44 | 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))", | |
45 | expected("tcc+")("miu=")("mcu+")("txc=")); | |
46 | ||
47 | test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10)", | |
48 | "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))", | |
49 | expected("tcu+")("mic=")("mcu+")("mic=")("mxu+")); | |
50 | ||
51 | test_geometry<ls, poly>("LINESTRING(11 1,10 0,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
52 | "tcc+", "txu="); | |
53 | test_geometry<ls, poly>("LINESTRING(0 0,10 0,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
54 | "tcu+", "tuc="); | |
55 | test_geometry<ls, poly>("LINESTRING(10 0,0 0,-1 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
56 | "tcc+", "tuu="); | |
57 | ||
58 | // true hole | |
59 | test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)", | |
60 | "POLYGON((0 0,0 10,10 10,10 5,10 0,0 0)(2 2,10 5,2 8,2 2))", | |
61 | expected("tiu+")("tiu+")); | |
62 | test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)", | |
63 | "POLYGON((0 0,0 10,10 10,10 5,10 0,0 0)(2 2,10 5,2 8,2 2))", | |
64 | expected("mcu+")("ecc=")("tiu+")("mxc=")); | |
65 | ||
66 | // fake hole | |
67 | test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)", | |
68 | "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", | |
69 | expected("tuu+")("tiu+")); | |
70 | test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)", | |
71 | "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))", | |
72 | expected("mcu+")("tuc=")("tcu+")("mxc=")); | |
73 | ||
74 | // true hole | |
75 | test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 2)", | |
76 | "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", | |
77 | expected("mcu+")("mic=")("tcu+")("txc=")); | |
78 | test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 8)", | |
79 | "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", | |
80 | expected("mcu+")("mic=")("tcc+")("txu=")); | |
81 | ||
82 | // SPIKE - NON-ENDPOINT - NON-OPPOSITE | |
83 | ||
84 | // spike - neq eq | |
85 | test_geometry<ls, poly>("LINESTRING(2 2,4 4,1 1)", "POLYGON((0 0,4 4,6 3,6 0,0 0))", | |
86 | expected("mcc+")("txu=")("tcu=")("mxc=")); | |
87 | // spike - eq eq | |
88 | test_geometry<ls, poly>("LINESTRING(0 0,4 4,1 1)", "POLYGON((0 0,4 4,6 3,6 0,0 0))", | |
89 | expected("tcc+")("txu=")("tcu=")("mxc=")); | |
90 | // spike - eq neq | |
91 | test_geometry<ls, poly>("LINESTRING(0 0,3 3,1 1)", "POLYGON((0 0,4 4,6 3,6 0,0 0))", | |
92 | expected("tcc+")("mxu=")("mcu=")("mxc=")); | |
93 | // spike - neq neq | |
94 | test_geometry<ls, poly>("LINESTRING(1 1,3 3,2 2)", "POLYGON((0 0,4 4,6 3,6 0,0 0))", | |
95 | expected("mcc+")("mxu=")("mcu=")("mxc=")); | |
96 | // spike - out neq | |
97 | test_geometry<ls, poly>("LINESTRING(0 0,3 3,2 2)", "POLYGON((1 1,4 4,6 3,6 0,1 1))", | |
98 | expected("mcc+")("mxu=")("mcu=")("mxc=")); | |
99 | // spike - out eq | |
100 | test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2)", "POLYGON((1 1,4 4,6 3,6 0,1 1))", | |
101 | expected("mcc+")("txu=")("tcu=")("mxc=")); | |
102 | // spike - out out/eq | |
103 | test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2)", "POLYGON((1 0,4 4,6 3,1 0))", | |
104 | expected("tuu+")); | |
105 | test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2)", "POLYGON((0 1,4 4,6 3,6 0,-1 -1,0 1))", | |
106 | expected("tiu+")); | |
107 | // spike - out out/neq | |
108 | test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2)", "POLYGON((4 0,4 5,6 3,4 0))", | |
109 | expected("muu+")); | |
110 | test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2)", "POLYGON((0 4,5 4,6 3,6 0,-1 -1,0 4))", | |
111 | expected("miu+")); | |
112 | ||
113 | test_geometry<ls, poly>("LINESTRING(0 1,1 1,0 1)", "POLYGON((0 0,3 3,3 0,0 0))", | |
114 | expected("muu+")); | |
115 | test_geometry<ls, poly>("LINESTRING(0 1,3 3,0 1)", "POLYGON((0 0,3 3,3 0,0 0))", | |
116 | expected("tuu+")); | |
117 | test_geometry<ls, poly>("LINESTRING(0 1,0 0,0 1)", "POLYGON((0 0,3 3,3 0,0 0))", | |
118 | expected("tuu+")); | |
119 | ||
120 | // SPIKE - NON-ENDPOINT - OPPOSITE | |
121 | ||
122 | // opposite - eq eq | |
123 | test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2)", "POLYGON((-1 -1,0 0,4 4,6 3,-1 -1))", | |
124 | expected("tcu+")("txc=")("tcc=")("mxu=")); | |
125 | // opposite - neq eq | |
126 | test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2)", "POLYGON((-1 -1,0 0,5 5,6 3,-1 -1))", | |
127 | expected("mcu+")("txc=")("tcc=")("mxu=")); | |
128 | // opposite - eq, neq | |
129 | test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2)", "POLYGON((-2 -2,-1 -1,4 4,6 3,-2 -2))", | |
130 | expected("tcu+")("mxc=")("mcc=")("mxu=")); | |
131 | // opposite - neq neq | |
132 | test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2)", "POLYGON((-2 -2,-1 -1,3 3,6 3,-2 -2))", | |
133 | expected("mcu+")("mxc=")("mcc=")("mxu=")); | |
134 | // opposite - neq neq | |
135 | test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2)", "POLYGON((-2 -2,-1 -1,3 3,5 5,6 3,-2 -2))", | |
136 | expected("mcu+")("mxc=")("mcc=")("mxu=")); | |
137 | ||
138 | // spike vs internal | |
139 | test_geometry<ls, poly>("LINESTRING(0 1,1 1,0 1)", // -- | |
140 | "POLYGON((1 0,1 1,2 1,1 0))", | |
141 | expected("tuu+")); | |
142 | test_geometry<ls, poly>("LINESTRING(1 2,1 1,1 2)", // | | |
143 | "POLYGON((1 0,1 1,2 1,1 0))", | |
144 | expected("tuu+")); | |
145 | test_geometry<ls, poly>("LINESTRING(0 2,1 1,0 2)", | |
146 | "POLYGON((1 0,1 1,2 1,1 0))", | |
147 | expected("tuu+")); | |
148 | test_geometry<ls, poly>("LINESTRING(2 0,1 1,2 0)", | |
149 | "POLYGON((1 0,1 1,2 1,2 0,1 0))", | |
150 | expected("tiu+")("tiu+")("txu+")); // TODO: should spike point be duplicated? | |
151 | test_geometry<ls, poly>("LINESTRING(0 0,1 1,0 0)", // / | |
152 | "POLYGON((1 0,1 1,2 1,1 0))", | |
153 | expected("tuu+")); | |
154 | test_geometry<ls, poly>("LINESTRING(2 2,1 1,2 2)", // / | |
155 | "POLYGON((1 0,1 1,2 1,1 0))", | |
156 | expected("tuu+")); | |
157 | ||
158 | test_geometry<ls, poly>("LINESTRING(2 1,1 1,2 1)", | |
159 | "POLYGON((1 0,1 1,2 1,1 0))", | |
160 | expected("tcu+")("txc=")("tcc=")("txu=")); | |
161 | ||
162 | // 21.01.2015 | |
163 | test_geometry<ls, poly>("LINESTRING(1 3,3 1)", | |
164 | "POLYGON((0 0,0 4,4 4,4 0,2 2,0 0))", | |
165 | expected("mcu+")("mxc=")); | |
166 | // extended | |
167 | test_geometry<ls, poly>("LINESTRING(1 7,4 4,7 1)", | |
168 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
169 | expected("tcu+")("mxc=")); | |
170 | test_geometry<ls, poly>("LINESTRING(1 7,3 5,7 1)", | |
171 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
172 | expected("mcu+")("mxc=")); | |
173 | test_geometry<ls, poly>("LINESTRING(1 7,5 3,7 1)", | |
174 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
175 | expected("mcu+")("mxc=")); | |
176 | test_geometry<ls, poly>("LINESTRING(4 4,7 1)", | |
177 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
178 | expected("tcu+")("mxc=")); | |
179 | test_geometry<ls, poly>("LINESTRING(5 3,7 1)", | |
180 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
181 | expected("mcu+")("mxc=")); | |
182 | // reversed | |
183 | test_geometry<ls, poly>("LINESTRING(7 1,4 4,1 7)", | |
184 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
185 | expected("mcc+")("tiu=")); | |
186 | test_geometry<ls, poly>("LINESTRING(7 1,3 5,1 7)", | |
187 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
188 | expected("mcc+")("miu=")); | |
189 | test_geometry<ls, poly>("LINESTRING(7 1,5 3,1 7)", | |
190 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
191 | expected("mcc+")("ccc=")("miu=")); | |
192 | test_geometry<ls, poly>("LINESTRING(7 1,4 4)", | |
193 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
194 | expected("mcc+")("txu=")); | |
195 | test_geometry<ls, poly>("LINESTRING(7 1,5 3)", | |
196 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
197 | expected("mcc+")("mxu=")); | |
198 | test_geometry<ls, poly>("LINESTRING(7 1,3 5)", | |
199 | "POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))", | |
200 | expected("mcc+")("miu=")); | |
201 | ||
202 | // 23.01.2015 - spikes | |
203 | test_geometry<ls, poly>("LINESTRING(3 10, 1 5, 1 10, 3 4, 7 8, 6 10, 10 2)", | |
204 | "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
205 | expected("miu+")("miu+")("miu+")("mxu+")); | |
206 | // extended | |
207 | test_geometry<ls, poly>("LINESTRING(7 8, 6 10, 11 0)", | |
208 | "POLYGON((0 0,0 10,10 10,10 0,0 0))", | |
209 | expected("miu+")("iuu+")); | |
210 | ||
211 | // 25.01.2015 | |
212 | test_geometry<ls, poly>("LINESTRING(2 3, 4 5, 0 6, 5 6)", | |
213 | "POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))", | |
214 | expected("miu+")("miu+")("mcu+")("mxc=")); | |
215 | test_geometry<ls, poly>("LINESTRING(0 6, 5 6)", | |
216 | "POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))", | |
217 | expected("miu+")("mcu+")("mxc=")); | |
218 | ||
219 | } | |
220 | ||
221 | int test_main(int, char* []) | |
222 | { | |
223 | test_all<float>(); | |
224 | test_all<double>(); | |
225 | ||
226 | #if ! defined(_MSC_VER) | |
227 | test_all<long double>(); | |
228 | #endif | |
229 | ||
7c673cae FG |
230 | return 0; |
231 | } |