]>
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 | ||
b32b8144 FG |
5 | // This file was modified by Oracle on 2013, 2014, 2015, 2017. |
6 | // Modifications copyright (c) 2013-2017 Oracle and/or its affiliates. | |
7c673cae FG |
7 | |
8 | // Use, modification and distribution is subject to the Boost Software License, | |
9 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
10 | // http://www.boost.org/LICENSE_1_0.txt) | |
11 | ||
12 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
13 | ||
14 | #include "test_relate.hpp" | |
15 | #include "../nan_cases.hpp" | |
16 | ||
17 | //TEST | |
18 | //#include <to_svg.hpp> | |
19 | ||
20 | template <typename P> | |
21 | void test_point_point() | |
22 | { | |
23 | test_geometry<P, P>("POINT(0 0)", "POINT(0 0)", "0FFFFFFF2"); | |
24 | test_geometry<P, P>("POINT(1 0)", "POINT(0 0)", "FF0FFF0F2"); | |
25 | } | |
26 | ||
27 | template <typename P> | |
28 | void test_point_multipoint() | |
29 | { | |
30 | typedef bg::model::multi_point<P> mpt; | |
31 | ||
32 | test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2"); | |
33 | test_geometry<P, mpt>("POINT(1 0)", "MULTIPOINT(0 0)", "FF0FFF0F2"); | |
34 | test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(0 0, 1 0)", "0FFFFF0F2"); | |
35 | } | |
36 | ||
37 | template <typename P> | |
38 | void test_multipoint_multipoint() | |
39 | { | |
40 | typedef bg::model::multi_point<P> mpt; | |
41 | ||
42 | test_geometry<mpt, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2"); | |
43 | test_geometry<mpt, mpt>("MULTIPOINT(1 0)", "MULTIPOINT(0 0)", "FF0FFF0F2"); | |
44 | test_geometry<mpt, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0, 1 0)", "0FFFFF0F2"); | |
45 | test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 0)", "MULTIPOINT(0 0)", "0F0FFFFF2"); | |
46 | test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 1 0)", "0F0FFF0F2"); | |
47 | ||
48 | //typedef bg::model::d2::point_xy<float> ptf; | |
49 | //typedef bg::model::multi_point<ptf> mptf; | |
50 | //test_geometry<mptf, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2"); | |
51 | ||
52 | // assertion failure in relate->boundary_checker->std::equal_range with msvc | |
53 | if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mpt>::value)) | |
54 | { | |
55 | mpt g; | |
56 | std::string wkt; | |
57 | nan_case(g, wkt); | |
58 | ||
59 | check_geometry(g, g, wkt, wkt, "*********"); | |
60 | } | |
61 | } | |
62 | ||
63 | template <typename P> | |
64 | void test_point_linestring() | |
65 | { | |
66 | typedef bg::model::linestring<P> ls; | |
67 | ||
b32b8144 FG |
68 | // degenerated |
69 | //test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0)", "0FFFFFFF2"); | |
70 | ||
7c673cae FG |
71 | test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102"); |
72 | test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0, 2 2, 3 2)", "0FFFFF102"); | |
73 | test_geometry<P, ls>("POINT(3 2)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102"); | |
74 | test_geometry<P, ls>("POINT(1 0)", "LINESTRING(0 0, 2 2, 3 2)", "FF0FFF102"); | |
75 | ||
76 | test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2"); | |
77 | test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2"); | |
78 | test_geometry<P, ls>("POINT(3 2)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2"); | |
79 | test_geometry<P, ls>("POINT(1 0)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "FF0FFF1F2"); | |
80 | } | |
81 | ||
82 | template <typename P> | |
83 | void test_point_multilinestring() | |
84 | { | |
85 | typedef bg::model::linestring<P> ls; | |
86 | typedef bg::model::multi_linestring<ls> mls; | |
87 | ||
88 | test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2))", "0FFFFF102"); | |
89 | test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2, 2 2))", "0FFFFF1F2"); | |
90 | test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2, 2 2),(0 0, 1 1))", "F0FFFF102"); | |
91 | ||
92 | test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2"); | |
93 | test_geometry<P, mls>("POINT(5 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2"); | |
94 | test_geometry<P, mls>("POINT(1 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2"); | |
95 | ||
96 | // assertion failure in relate->boundary_checker->std::equal_range with msvc | |
97 | if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mls>::value)) | |
98 | { | |
99 | // on the boundary | |
100 | std::string wkt0 = "POINT(3.1e+307 1)"; | |
101 | P g0; | |
102 | bg::read_wkt(wkt0, g0); | |
103 | ||
104 | // disjoint | |
105 | std::string wkt1 = "POINT(1.1e+308 1.2e+308)"; | |
106 | P g1; | |
107 | bg::read_wkt(wkt1, g1); | |
108 | ||
109 | mls g2; | |
110 | std::string wkt2; | |
111 | nan_case(g2, wkt2); | |
112 | ||
113 | check_geometry(g0, g2, wkt0, wkt2, "*********"); | |
114 | check_geometry(g1, g2, wkt1, wkt2, "*********"); | |
115 | } | |
116 | } | |
117 | ||
b32b8144 FG |
118 | template <typename P> |
119 | void test_multipoint_linestring() | |
120 | { | |
121 | typedef bg::model::multi_point<P> mpt; | |
122 | typedef bg::model::linestring<P> ls; | |
123 | ||
124 | // degenerated | |
125 | //test_geometry<mpt, ls>("MULTIPOINT(0 0)", "LINESTRING(0 0)", "0FFFFFFF2"); | |
126 | ||
127 | test_geometry<mpt, ls>("MULTIPOINT(0 0)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102"); | |
128 | test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1)", "LINESTRING(0 0, 2 2, 3 2)", "00FFFF102"); | |
129 | test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1, 3 3)", "LINESTRING(0 0, 2 2, 3 2)", "000FFF102"); | |
130 | test_geometry<mpt, ls>("MULTIPOINT(0 0, 3 3)", "LINESTRING(0 0, 2 2, 3 2)", "F00FFF102"); | |
131 | test_geometry<mpt, ls>("MULTIPOINT(1 1, 3 3)", "LINESTRING(0 0, 2 2, 3 2)", "0F0FFF102"); | |
132 | ||
133 | test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2"); | |
134 | test_geometry<mpt, ls>("MULTIPOINT(0 0, 3 3)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0F0FFF1F2"); | |
135 | ||
136 | test_geometry<mpt, ls>("MULTIPOINT(0 0)", "LINESTRING(0 0, 2 2)", "F0FFFF102"); | |
137 | test_geometry<mpt, ls>("MULTIPOINT(2 2)", "LINESTRING(0 0, 2 2)", "F0FFFF102"); | |
138 | test_geometry<mpt, ls>("MULTIPOINT(0 0, 2 2)", "LINESTRING(0 0, 2 2)", "F0FFFF1F2"); | |
139 | test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1, 0 1, 2 2)", "LINESTRING(0 0, 2 2)", "000FFF1F2"); | |
140 | } | |
141 | ||
142 | template <typename P> | |
143 | void test_multipoint_multilinestring() | |
144 | { | |
145 | typedef bg::model::multi_point<P> mpt; | |
146 | typedef bg::model::linestring<P> ls; | |
147 | typedef bg::model::multi_linestring<ls> mls; | |
148 | ||
149 | test_geometry<mpt, mls>("MULTIPOINT(0 0)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "F0FFFF102"); | |
150 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "00FFFF102"); | |
151 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "000FFF102"); | |
152 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "F00FFF102"); | |
153 | test_geometry<mpt, mls>("MULTIPOINT(1 1, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "0F0FFF102"); | |
154 | ||
155 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2, 0 0))", "0FFFFF1F2"); | |
156 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2, 0 0))", "0F0FFF1F2"); | |
157 | ||
158 | test_geometry<mpt, mls>("MULTIPOINT(0 0,1 1)", "MULTILINESTRING((0 0,0 1,1 1),(1 1,1 0,0 0))", "0FFFFF1F2"); | |
159 | ||
160 | test_geometry<mpt, mls>("MULTIPOINT(0 0)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "F0FFFF102"); | |
161 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "00FFFF102"); | |
162 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1, 2 2)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "00FFFF1F2"); | |
163 | test_geometry<mpt, mls>("MULTIPOINT(0 0, 2 2)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "F0FFFF1F2"); | |
164 | } | |
165 | ||
166 | template <typename P> | |
167 | void test_point_ring_polygon() | |
168 | { | |
169 | typedef bg::model::ring<P> ring; | |
170 | typedef bg::model::polygon<P> poly; | |
171 | ||
172 | test_geometry<P, ring>("POINT(0 0)", "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))", "F0FFFF212"); | |
173 | ||
174 | test_geometry<P, poly>("POINT(1 1)", "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))", "0FFFFF212"); | |
175 | test_geometry<P, poly>("POINT(1 3)", "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))", "FF0FFF212"); | |
176 | } | |
177 | ||
178 | template <typename P> | |
179 | void test_point_multipolygon() | |
180 | { | |
181 | typedef bg::model::polygon<P> poly; | |
182 | typedef bg::model::multi_polygon<poly> mpoly; | |
183 | ||
184 | test_geometry<P, mpoly>("POINT(0 0)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F0FFFF212"); | |
185 | test_geometry<P, mpoly>("POINT(1 1)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "0FFFFF212"); | |
186 | test_geometry<P, mpoly>("POINT(5 5)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F0FFFF212"); | |
187 | test_geometry<P, mpoly>("POINT(6 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "0FFFFF212"); | |
188 | test_geometry<P, mpoly>("POINT(1 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "FF0FFF212"); | |
189 | } | |
190 | ||
191 | template <typename P> | |
192 | void test_multipoint_ring_polygon() | |
193 | { | |
194 | typedef bg::model::multi_point<P> mpt; | |
195 | typedef bg::model::ring<P> ring; | |
196 | typedef bg::model::polygon<P> poly; | |
197 | ||
198 | test_geometry<mpt, ring>("MULTIPOINT(0 0)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "F0FFFF212"); | |
199 | test_geometry<mpt, ring>("MULTIPOINT(0 0, 1 1)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "00FFFF212"); | |
200 | test_geometry<mpt, ring>("MULTIPOINT(0 0, 1 1, 4 4)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "000FFF212"); | |
201 | test_geometry<mpt, ring>("MULTIPOINT(1 1, 4 4)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "0F0FFF212"); | |
202 | ||
203 | test_geometry<mpt, poly>("MULTIPOINT(2 2)", "POLYGON((0 0, 0 4, 4 4, 4 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "FF0FFF212"); | |
204 | test_geometry<mpt, poly>("MULTIPOINT(0 0, 1 1)", "POLYGON((0 0, 0 4, 4 4, 4 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "F0FFFF212"); | |
205 | test_geometry<mpt, poly>("MULTIPOINT(0 0, 1 1, 2 2)", "POLYGON((0 0, 0 4, 4 4, 4 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "F00FFF212"); | |
206 | test_geometry<mpt, poly>("MULTIPOINT(2 2, 4 4)", "POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "0F0FFF212"); | |
207 | } | |
208 | ||
209 | template <typename P> | |
210 | void test_multipoint_multipolygon() | |
211 | { | |
212 | typedef bg::model::multi_point<P> mpt; | |
213 | typedef bg::model::polygon<P> poly; | |
214 | typedef bg::model::multi_polygon<poly> mpoly; | |
215 | ||
216 | test_geometry<mpt, mpoly>("MULTIPOINT(0 0)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F0FFFF212"); | |
217 | test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 1 1)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "00FFFF212"); | |
218 | test_geometry<mpt, mpoly>("MULTIPOINT(1 1, 5 5)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "00FFFF212"); | |
219 | test_geometry<mpt, mpoly>("MULTIPOINT(1 6, 6 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "0F0FFF212"); | |
220 | test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 1 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F00FFF212"); | |
221 | } | |
222 | ||
7c673cae FG |
223 | template <typename P> |
224 | void test_all() | |
225 | { | |
226 | test_point_point<P>(); | |
227 | test_point_multipoint<P>(); | |
228 | test_multipoint_multipoint<P>(); | |
b32b8144 | 229 | |
7c673cae FG |
230 | test_point_linestring<P>(); |
231 | test_point_multilinestring<P>(); | |
b32b8144 FG |
232 | test_multipoint_linestring<P>(); |
233 | test_multipoint_multilinestring<P>(); | |
234 | ||
235 | test_point_ring_polygon<P>(); | |
236 | test_point_multipolygon<P>(); | |
237 | test_multipoint_ring_polygon<P>(); | |
238 | test_multipoint_multipolygon<P>(); | |
7c673cae FG |
239 | } |
240 | ||
241 | int test_main( int , char* [] ) | |
242 | { | |
243 | check_mask(); | |
244 | ||
245 | test_all<bg::model::d2::point_xy<int> >(); | |
246 | test_all<bg::model::d2::point_xy<double> >(); | |
247 | ||
248 | #if defined(HAVE_TTMATH) | |
249 | test_all<bg::model::d2::point_xy<ttmath_big> >(); | |
250 | #endif | |
251 | ||
252 | return 0; | |
253 | } |