17 #include "CUnit/Basic.h"
33 #define DIST2DTEST(str1, str2, res, accepted_error) \
34 do_test_mindistance_tolerance(str1, str2, res, __LINE__, lwgeom_mindistance2d_tolerance, accepted_error);\
35 do_test_mindistance_tolerance(str2, str1, res, __LINE__, lwgeom_mindistance2d_tolerance, accepted_error)
36 #define DIST3DTEST(str1, str2, res, accepted_error) \
37 do_test_mindistance_tolerance(str1, str2, res, __LINE__, lwgeom_mindistance3d_tolerance, accepted_error);\
38 do_test_mindistance_tolerance(str2, str1, res, __LINE__, lwgeom_mindistance3d_tolerance, accepted_error)
45 double (*distancef)(
const LWGEOM *,
const LWGEOM *,
double),
46 double accepted_error)
51 char *msg1 =
"test_mindistance2d_tolerance failed (got %g expected %g) at line %d\n";
52 char *msg2 =
"\n\ndo_test_mindistance2d_tolerance: NULL lwgeom generated from WKT\n %s\n\n";
75 if ( fabs(
distance - expected_res) > accepted_error )
77 printf(msg1,
distance, expected_res, line);
89 double default_accepted_error = 0.00001;
90 double zero_accepted_error = 0.0;
94 DIST2DTEST(
"POINT(0 0)",
"MULTIPOINT(0 1.5,0 2,0 2.5)", 1.5, default_accepted_error);
99 DIST2DTEST(
"POINT(0 0)",
"GEOMETRYCOLLECTION(POINT(3 4))", 5.0, default_accepted_error);
104 DIST2DTEST(
"POINT(0 0)",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0, default_accepted_error);
109 DIST2DTEST(
"POINT(0 0)",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4))))", 5.0, default_accepted_error);
114 DIST2DTEST(
"POINT(0 0)",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4))))", 5.0, default_accepted_error);
119 DIST2DTEST(
"GEOMETRYCOLLECTION(POINT(0 0))",
"GEOMETRYCOLLECTION(POINT(3 4))", 5.0, default_accepted_error);
124 DIST2DTEST(
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0, default_accepted_error);
129 DIST2DTEST(
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0)))",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4)))", 5.0, default_accepted_error);
134 DIST2DTEST(
"LINESTRING(-2 0, -0.2 0)",
"POINT(-2 0)", 0, zero_accepted_error);
139 DIST2DTEST(
"LINESTRING(-0.2 0, -2 0)",
"POINT(-2 0)", 0, zero_accepted_error);
144 DIST2DTEST(
"LINESTRING(-1e-8 0, -0.2 0)",
"POINT(-1e-8 0)", 0, zero_accepted_error);
149 DIST2DTEST(
"LINESTRING(-0.2 0, -1e-8 0)",
"POINT(-1e-8 0)", 0, zero_accepted_error);
154 DIST2DTEST(
"CIRCULARSTRING(-1 0, 0 1, 1 0)",
"POINT(0 0)", 1, default_accepted_error);
155 DIST2DTEST(
"CIRCULARSTRING(-3 0, -2 0, -1 0, 0 1, 1 0)",
"POINT(0 0)", 1, default_accepted_error);
160 DIST2DTEST(
"CIRCULARSTRING(-1 0, 0 1, 1 0)",
"CIRCULARSTRING(0 0, 1 -1, 2 0)", 1, default_accepted_error);
165 static char *cs1 =
"CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(1 6, 6 1, 9 7),(9 7, 3 13, 1 6)),COMPOUNDCURVE((3 6, 5 4, 7 4, 7 6),CIRCULARSTRING(7 6,5 8,3 6)))";
166 DIST2DTEST(cs1,
"POINT(3 14)", 1, default_accepted_error);
167 DIST2DTEST(cs1,
"POINT(3 8)", 0, default_accepted_error);
168 DIST2DTEST(cs1,
"POINT(6 5)", 1, default_accepted_error);
169 DIST2DTEST(cs1,
"POINT(6 4)", 0, default_accepted_error);
174 DIST2DTEST(cs1,
"LINESTRING(0 0, 50 0)", 0.917484, default_accepted_error);
175 DIST2DTEST(cs1,
"LINESTRING(6 0, 10 7)", 0, default_accepted_error);
176 DIST2DTEST(cs1,
"LINESTRING(4 4, 4 8)", 0, default_accepted_error);
177 DIST2DTEST(cs1,
"LINESTRING(4 7, 5 6, 6 7)", 0.585786, default_accepted_error);
178 DIST2DTEST(cs1,
"LINESTRING(10 0, 10 2, 10 0)", 1.52913, default_accepted_error);
183 DIST2DTEST(cs1,
"POLYGON((10 4, 10 8, 13 8, 13 4, 10 4))", 0.58415, default_accepted_error);
184 DIST2DTEST(cs1,
"POLYGON((9 4, 9 8, 12 8, 12 4, 9 4))", 0, default_accepted_error);
185 DIST2DTEST(cs1,
"POLYGON((1 4, 1 8, 4 8, 4 4, 1 4))", 0, default_accepted_error);
190 DIST2DTEST(cs1,
"CURVEPOLYGON(CIRCULARSTRING(-1 4, 0 5, 1 4, 0 3, -1 4))", 0.0475666, default_accepted_error);
191 DIST2DTEST(cs1,
"CURVEPOLYGON(CIRCULARSTRING(1 4, 2 5, 3 4, 2 3, 1 4))", 0.0, default_accepted_error);
196 static char *cs2 =
"MULTISURFACE(POLYGON((0 0,0 4,4 4,4 0,0 0)),CURVEPOLYGON(CIRCULARSTRING(8 2,10 4,12 2,10 0,8 2)))";
197 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(5 2,6 3,7 2,6 1,5 2))", 1, default_accepted_error);
198 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(4 2,5 3,6 2,5 1,4 2))", 0, default_accepted_error);
199 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(5 3,6 2,5 1,4 2,5 3))", 0, default_accepted_error);
200 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(4.5 3,5.5 2,4.5 1,3.5 2,4.5 3))", 0, default_accepted_error);
201 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(5.5 3,6.5 2,5.5 1,4.5 2,5.5 3))", 0.5, default_accepted_error);
202 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(10 3,11 2,10 1,9 2,10 3))", 0, default_accepted_error);
203 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(2 3,3 2,2 1,1 2,2 3))", 0, default_accepted_error);
204 DIST2DTEST(cs2,
"CURVEPOLYGON(CIRCULARSTRING(5 7,6 8,7 7,6 6,5 7))", 2.60555, default_accepted_error);
209 DIST2DTEST(
"LINESTRING(0.5 1,0.5 3)",
"MULTICURVE(CIRCULARSTRING(2 3,3 2,2 1,1 2,2 3),(0 0, 0 5))", 0.5, default_accepted_error);
215 "CURVEPOLYGON(CIRCULARSTRING(7874821 8715927,8907663 8715927,8844683 7750316,7937800 7750316,7874821 8715927))",
216 "POINT(5433865 8243495)", 2271704.2698450615, default_accepted_error);
222 double default_accepted_error = 0.00001;
223 double zero_accepted_error = 0.0;
225 DIST3DTEST(
"POINT(0 0 0)",
"MULTIPOINT(0 1.5 0, 0 2 0, 0 2.5 0)", 1.5, default_accepted_error);
226 DIST3DTEST(
"POINT(0 0 0)",
"MULTIPOINT(0 1.5 0, 0 2 0, 0 2.5 0)", 1.5, default_accepted_error);
227 DIST3DTEST(
"POINT(0 0 0)",
"GEOMETRYCOLLECTION(POINT(3 4 0))", 5.0, default_accepted_error);
228 DIST3DTEST(
"POINT(0 0 0)",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4 0)))", 5.0, default_accepted_error);
229 DIST3DTEST(
"POINT(0 0 0)",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4 0))))", 5.0, default_accepted_error);
230 DIST3DTEST(
"POINT(0 0)",
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4))))", 5.0, default_accepted_error);
231 DIST3DTEST(
"GEOMETRYCOLLECTION(POINT(0 0 0))",
"GEOMETRYCOLLECTION(POINT(3 4 0))", 5.0, default_accepted_error);
232 DIST3DTEST(
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0 0)))",
233 "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4 0)))",
234 5.0, default_accepted_error);
235 DIST3DTEST(
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0 0)))",
236 "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4 0)))",
237 5.0, default_accepted_error);
238 DIST3DTEST(
"LINESTRING(-2 0 0, -0.2 0 0)",
"POINT(-2 0 0)", 0, zero_accepted_error);
239 DIST3DTEST(
"LINESTRING(-0.2 0 0, -2 0 0)",
"POINT(-2 0 0)", 0, zero_accepted_error);
240 DIST3DTEST(
"LINESTRING(-1e-8 0 0, -0.2 0 0)",
"POINT(-1e-8 0 0)", 0, zero_accepted_error);
241 DIST3DTEST(
"LINESTRING(-0.2 0 0, -1e-8 0 0)",
"POINT(-1e-8 0 0)", 0, zero_accepted_error);
244 DIST3DTEST(
"LINESTRING(1 0 0 , 2 0 0)",
"POLYGON((1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0))", 1.0, default_accepted_error);
245 DIST3DTEST(
"LINESTRING(1 1 1 , 2 1 0)",
"POLYGON((1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0))", 0.0, zero_accepted_error);
246 DIST3DTEST(
"LINESTRING(1 1 1 , 2 1 1)",
"POLYGON((1 1 0, 2 1 0, 2 2 0, 1 2 0, 1 1 0))", 1.0, default_accepted_error);
249 DIST3DTEST(
"LINESTRING(1 0 0 , 2 0 0)",
"TRIANGLE((1 1 0, 2 1 0, 1 2 0, 1 1 0))", 1.0, default_accepted_error);
250 DIST3DTEST(
"LINESTRING(1 1 1 , 2 1 0)",
"TRIANGLE((1 1 0, 2 1 0, 1 2 0, 1 1 0))", 0.0, zero_accepted_error);
251 DIST3DTEST(
"LINESTRING(1 1 1 , 2 1 1)",
"TRIANGLE((1 1 0, 2 1 0, 1 2 0, 1 1 0))", 1.0, default_accepted_error);
254 DIST3DTEST(
"TRIANGLE((-1 1 0, -2 1 0, -1 2 0, -1 1 0))",
"TRIANGLE((1 1 0, 2 1 0, 1 2 0, 1 1 0))", 2.0, default_accepted_error);
257 DIST3DTEST(
"LINESTRING(1 1 1 , 2 2 2)",
"POLYGON((0 0 0, 2 2 2, 3 3 1, 0 0 0))", 0.0, zero_accepted_error);
260 DIST3DTEST(
"LINESTRING(-10000 -10000 0, 0 0 1)",
"POLYGON((0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 0))", 1, default_accepted_error);
263 DIST3DTEST(
"LINESTRING(1 1 1, 2 2 2)",
"POLYGON((0 0 0, 2 2 2, 3 3 3, 0 0 0))", 0, zero_accepted_error);
264 DIST3DTEST(
"TRIANGLE((1 1 1, 2 2 2, 3 3 3, 1 1 1))",
"POLYGON((0 0 0, 2 2 2, 3 3 3, 0 0 0))", 0, zero_accepted_error);
265 DIST3DTEST(
"POLYGON((0 0 0, 2 2 2, 3 3 3, 0 0 0))",
"TRIANGLE((1 1 1, 2 2 2, 3 3 3, 1 1 1))", 0, zero_accepted_error);
266 DIST3DTEST(
"TRIANGLE((0 0 0, 2 2 2, 3 3 3, 0 0 0))",
"LINESTRING(1 1 1, 2 2 2)", 0, zero_accepted_error);
270 "POLYHEDRALSURFACE Z (((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)),((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),((1 0 0,1 1 0,1 1 1,1 0 1,1 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)))",
271 "POLYHEDRALSURFACE Z (((-1 -1 -1,-1 2 -1,2 2 -1,2 -1 -1,-1 -1 -1)),((-1 -1 2,2 -1 2,2 2 2,-1 2 2,-1 -1 2)),((-1 -1 -1,-1 -1 2,-1 2 2,-1 2 -1,-1 -1 -1)),((2 -1 -1,2 2 -1,2 2 2,2 -1 2,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 -1,-1 -1 -1,2 2 -1,2 -1 -1)),((-1 -1 2,2 -1 -1,2 -1 2,-1 -1 2)),((2 2 -1,2 -1 2,2 -1 -1,2 2 -1)))",
296 0, zero_accepted_error);
300 "POLYHEDRALSURFACE Z (((0 -1 1,-1 -1 1,-1 -1 -1,0 -1 -1,1 -1 -1,0 -1 2,0 -1 1)),((0 1 1,0 1 2,1 1 -1,0 1 -1,-1 1 -1,-1 1 1,0 1 1)),((0 -1 1,0 1 1,-1 1 1,-1 -1 1,0 -1 1)),((-1 -1 1,-1 1 1,-1 1 -1,-1 -1 -1,-1 -1 1)),((-1 -1 -1,-1 1 -1,0 1 -1,0 -1 -1,-1 -1 -1)),((0 -1 -1,0 1 -1,1 1 -1,1 -1 -1,0 -1 -1)),((1 -1 -1,1 1 -1,0 1 2,0 -1 2,1 -1 -1)),((0 -1 2,0 1 2,0 1 1,0 -1 1,0 -1 2)))",
302 0, zero_accepted_error);
306 "POLYHEDRALSURFACE Z (((-3 -3 0,-3 3 0,3 3 0,3 -3 0,-3 -3 0),(-1 -1 0,1 -1 0,1 1 0,-1 1 0,-1 -1 0)),((-3 -3 3,3 -3 3,3 3 3,-3 3 3,-3 -3 3),(-1 -1 3,-1 1 3,1 1 3,1 -1 3,-1 -1 3)),((-3 -3 0,-3 -3 3,-3 3 3,-3 3 0,-3 -3 0)),((-3 3 0,-3 3 3,3 3 3,3 3 0,-3 3 0)),((3 3 0,3 3 3,3 -3 3,3 -3 0,3 3 0)),((3 -3 0,3 -3 3,-3 -3 3,-3 -3 0,3 -3 0)),((-1 -1 0,-1 -1 3,1 -1 3,1 -1 0,-1 -1 0)),((1 -1 0,1 -1 3,1 1 3,1 1 0,1 -1 0)),((1 1 0,1 1 3,-1 1 3,-1 1 0,1 1 0)),((-1 1 0,-1 1 3,-1 -1 3,-1 -1 0,-1 1 0)))",
308 1, zero_accepted_error);
312 "POLYHEDRALSURFACE Z (((-3 -3 0,-3 3 0,3 3 0,3 -3 0,-3 -3 0),(-1 -1 0,1 -1 0,1 1 0,-1 1 0,-1 -1 0)),((-3 -3 3,3 -3 3,3 3 3,-3 3 3,-3 -3 3),(-1 -1 3,-1 1 3,1 1 3,1 -1 3,-1 -1 3)),((-3 -3 0,-3 -3 3,-3 3 3,-3 3 0,-3 -3 0)),((-3 3 0,-3 3 3,3 3 3,3 3 0,-3 3 0)),((3 3 0,3 3 3,3 -3 3,3 -3 0,3 3 0)),((3 -3 0,3 -3 3,-3 -3 3,-3 -3 0,3 -3 0)),((-1 -1 0,-1 -1 3,1 -1 3,1 -1 0,-1 -1 0)),((1 -1 0,1 -1 3,1 1 3,1 1 0,1 -1 0)),((1 1 0,1 1 3,-1 1 3,-1 1 0,1 1 0)),((-1 1 0,-1 1 3,-1 -1 3,-1 -1 0,-1 1 0)))",
314 0, zero_accepted_error);
318 "LINESTRING Z (-27974.1264 -110211.5032 148.9768,-27975.4229 -110210.9441 149.0093)",
319 "LINESTRING Z (-27995.4183 -110201.8041 149.3354,-27975.4229 -110210.9441 149.0093)",
320 0, zero_accepted_error);
338 poly =
lwgeom_from_wkt(
"CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0,1 5,0 10),(0 10,10 10,10 0, 0 0)),COMPOUNDCURVE(CIRCULARSTRING(3 7,5 8,7 7),(7 7,7 3,3 3, 3 7)))",
LW_PARSER_CHECK_NONE);
346 CU_ASSERT_EQUAL(
tree_pt(tree, 5, 7.5), 0);
348 CU_ASSERT_EQUAL(
tree_pt(tree, 8, 9), 1);
350 CU_ASSERT_EQUAL(
tree_pt(tree, -1, 5), 0);
352 CU_ASSERT_EQUAL(
tree_pt(tree, -1, 7.5), 0);
354 CU_ASSERT_EQUAL(
tree_pt(tree, 0.2, 7.5), 0);
356 CU_ASSERT_EQUAL(
tree_pt(tree, 0.5, 0.5), 1);
358 CU_ASSERT_EQUAL(
tree_pt(tree, 2, 7.5), 1);
360 CU_ASSERT_EQUAL(
tree_pt(tree, 7, 7), 1);
369 poly =
lwgeom_from_wkt(
"POLYGON((0 0,0 10,10 10,10 0,9 0,9 9,8 6,8 0,2 0,2 9,1 6,1 0,0 0),(4 4,4 6,6 6,6 4,4 4))",
LW_PARSER_CHECK_NONE);
373 CU_ASSERT_EQUAL(
tree_pt(tree, 3, 6), 1);
375 CU_ASSERT_EQUAL(
tree_pt(tree, 3, 5.5), 1);
377 CU_ASSERT_EQUAL(
tree_pt(tree, -3, 5.5), 0);
379 CU_ASSERT_EQUAL(
tree_pt(tree, 4, 4), 1);
380 CU_ASSERT_EQUAL(
tree_pt(tree, 6, 6), 1);
382 CU_ASSERT_EQUAL(
tree_pt(tree, 4.5, 4), 1);
384 CU_ASSERT_EQUAL(
tree_pt(tree, 8, 0), 1);
385 CU_ASSERT_EQUAL(
tree_pt(tree, 9, 0), 1);
386 CU_ASSERT_EQUAL(
tree_pt(tree, 10, 1), 1);
387 CU_ASSERT_EQUAL(
tree_pt(tree, 9.5, 1), 1);
388 CU_ASSERT_EQUAL(
tree_pt(tree, 0, 10), 1);
390 CU_ASSERT_EQUAL(
tree_pt(tree, 1, 6), 1);
392 CU_ASSERT_EQUAL(
tree_pt(tree, -1, 6), 0);
394 CU_ASSERT_EQUAL(
tree_pt(tree, 5, 5), 0);
396 CU_ASSERT_EQUAL(
tree_pt(tree, 0.5, 4), 1);
397 CU_ASSERT_EQUAL(
tree_pt(tree, 0.5, 6), 1);
398 CU_ASSERT_EQUAL(
tree_pt(tree, 0.5, 9), 1);
410 CU_ASSERT_EQUAL(
tree_pt(tree, 0.5, 0.5), 1);
412 CU_ASSERT_EQUAL(
tree_pt(tree, 1.5, 0.5), 0);
414 CU_ASSERT_EQUAL(
tree_pt(tree, -1, 1), 0);
416 CU_ASSERT_EQUAL(
tree_pt(tree, 1, 1), 1);
418 CU_ASSERT_EQUAL(
tree_pt(tree, 0.5, 1), 1);
420 CU_ASSERT_EQUAL(
tree_pt(tree, 1, 0.5), 1);
430 CU_ASSERT_EQUAL(
tree_pt(tree, -0.5, 0.5), 0);
432 CU_ASSERT_EQUAL(
tree_pt(tree, 3, 1), 0);
434 CU_ASSERT_EQUAL(
tree_pt(tree, 2, 1), 1);
436 CU_ASSERT_EQUAL(
tree_pt(tree, 0, 1), 1);
438 CU_ASSERT_EQUAL(
tree_pt(tree, 0, 3), 1);
440 CU_ASSERT_EQUAL(
tree_pt(tree, 4, 0), 1);
442 CU_ASSERT_EQUAL(
tree_pt(tree, 3, 3), 1);
444 CU_ASSERT_EQUAL(
tree_pt(tree, 2, 0), 1);
452 poly =
lwgeom_from_wkt(
"POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
LW_PARSER_CHECK_NONE);
456 CU_ASSERT_EQUAL(
tree_pt(tree, -0.5, 3.5), 0);
458 CU_ASSERT_EQUAL(
tree_pt(tree, 6.0, 2.2), 0);
460 CU_ASSERT_EQUAL(
tree_pt(tree, 3, 2), 1);
462 CU_ASSERT_EQUAL(
tree_pt(tree, 1, 0), 1);
464 CU_ASSERT_EQUAL(
tree_pt(tree, 3, 6), 1);
466 CU_ASSERT_EQUAL(
tree_pt(tree, 3, 1), 1);
468 CU_ASSERT_EQUAL(
tree_pt(tree, 0, 2), 1);
470 CU_ASSERT_EQUAL(
tree_pt(tree, 0, 6), 1);
495 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
496 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))"),
502 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
503 "POLYGON((0.3 0.7, 0.3 0.8, 0.4 0.8, 0.4 0.7, 0.3 0.7))"),
509 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
510 "POLYGON((0.3 0.7, 0.3 0.8, 0.4 0.8, 1.3 0.3, 0.3 0.7))"),
516 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
517 "POLYGON((-1 5, 0 5, 0 7, -1 7, -1 5))"),
523 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
524 "GEOMETRYCOLLECTION(MULTILINESTRING((1 2, 3 2)),POINT(1 2))"),
530 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
531 "GEOMETRYCOLLECTION(MULTILINESTRING((6 3, 8 4)),POINT(5 3))"),
537 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
538 "GEOMETRYCOLLECTION(MULTILINESTRING((6 3, 8 4)),POINT(1 3.5))"),
544 "POLYGON((0 0, 3 1, 0 2, 3 3, 0 4, 3 5, 0 6, 5 6, 5 0, 0 0))",
545 "GEOMETRYCOLLECTION(MULTILINESTRING((1.5 4.1, 1.6 2)),POINT(1 3.5))"),
574 #define TDT(w1, w2, d) CU_ASSERT_DOUBLE_EQUAL(test_rect_tree_distance_tree_case(w1, w2), d, 0.00001);
581 wkt =
"MULTIPOLYGON(((-123.35702791281 48.4232302445918,-123.35689654493 48.4237265810249,-123.354053908057 48.4234039978588,-123.35417179975 48.4229151379279,-123.354369811539 48.4220987102936,-123.355779071731 48.4222571534228,-123.357238860904 48.4224209369449,-123.35702791281 48.4232302445918)))";
582 TDT(wkt,
"MULTIPOLYGON(((-123.353452578038 48.4259519079838,-123.35072012771 48.4256699150083,-123.347337809991 48.4254740864963,-123.347469111645 48.4245757659326,-123.349409235923 48.4246224093429,-123.349966167324 48.4246562342604,-123.353650661317 48.4250703224683,-123.353452578038 48.4259519079838)))", 0.0017144228293396);
585 TDT(wkt,
"MULTIPOINT(0 1.5,0 2,0 2.5)", 1.5);
586 TDT(wkt,
"GEOMETRYCOLLECTION(POINT(3 4))", 5.0);
587 TDT(wkt,
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0);
588 TDT(wkt,
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4))))", 5.0);
589 TDT(wkt,
"GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4))))", 5.0);
591 TDT(
"LINESTRING(-2 0, -0.2 0)",
"POINT(-2 0)", 0);
592 TDT(
"LINESTRING(-0.2 0, -2 0)",
"POINT(-2 0)", 0);
593 TDT(
"LINESTRING(-1e-8 0, -0.2 0)",
"POINT(-1e-8 0)", 0);
594 TDT(
"LINESTRING(-0.2 0, -1e-8 0)",
"POINT(-1e-8 0)", 0);
596 wkt =
"CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(1 6, 6 1, 9 7),(9 7, 3 13, 1 6)),COMPOUNDCURVE((3 6, 5 4, 7 4, 7 6),CIRCULARSTRING(7 6,5 8,3 6)))";
597 TDT(wkt,
"POINT(3 14)", 1);
598 TDT(wkt,
"POINT(3 8)", 0);
599 TDT(wkt,
"POINT(6 5)", 1);
600 TDT(wkt,
"POINT(6 4)", 0);
602 wkt =
"MULTISURFACE(POLYGON((0 0,0 4,4 4,4 0,0 0)),CURVEPOLYGON(CIRCULARSTRING(8 2,10 4,12 2,10 0,8 2)))";
603 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(5 7,6 8,7 7,6 6,5 7))", 2.60555);
604 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(5 2,6 3,7 2,6 1,5 2))", 1);
605 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(4 2,5 3,6 2,5 1,4 2))", 0);
606 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(5 3,6 2,5 1,4 2,5 3))", 0);
607 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(4.5 3,5.5 2,4.5 1,3.5 2,4.5 3))", 0);
608 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(5.5 3,6.5 2,5.5 1,4.5 2,5.5 3))", 0.5);
609 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(10 3,11 2,10 1,9 2,10 3))", 0);
610 TDT(wkt,
"CURVEPOLYGON(CIRCULARSTRING(2 3,3 2,2 1,1 2,2 3))", 0);
612 wkt =
"CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0,5 0,0 0)))";
613 TDT(wkt,
"POINT(3 0)", 0.0);
614 TDT(wkt,
"POINT(5 0)", 0.0);
615 TDT(wkt,
"POINT(7 0)", 2.0);
616 TDT(wkt,
"POINT(2.5 3.5)", 1.0);
619 TDT(wkt,
"POINT(0 1)", 1.0);
620 TDT(wkt,
"POINT(1 0)", 1.0);
622 wkt =
"LINESTRING(0 0,1 0)";
623 TDT(wkt,
"LINESTRING(1 0,1 1)", 0.0);
624 TDT(wkt,
"LINESTRING(0 1,1 1)", 1.0);
626 wkt =
"POLYGON((0 0,0 1,1 1,1 0,0 0))";
627 TDT(wkt,
"POINT(2 2)", sqrt(2));
628 TDT(wkt,
"POINT(0.5 0.5)", 0);
629 TDT(wkt,
"POINT(1 1)", 0);
631 wkt =
"POLYGON((0 0,0 10,10 10,10 0,0 0), (4 4,4 6,6 6,6 4,4 4))";
632 TDT(wkt,
"POINT(5 5)", 1);
633 TDT(wkt,
"POLYGON((5 5,5 5.5,5.5 5.5,5.5 5, 5 5))", 0.5);
660 CU_ASSERT_EQUAL(lineout, NULL);
668 CU_ASSERT_EQUAL(lineout, NULL);
674 CU_ASSERT_EQUAL(lineout, NULL);
678 "MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6)),((40 0,40 20,60 20,60 0,40 0),(42 2,42 4,44 4,44 2,42 2)))"
682 CU_ASSERT_EQUAL(lineout, NULL);
686 "GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6)),((40 0,40 20,60 20,60 0,40 0),(42 2,42 4,44 4,44 2,42 2))),MULTILINESTRING((0 0,10 0),(20 0, 30 0)),MULTIPOINT(0 0, 3 4))"
688 CU_ASSERT_FATAL(linein != NULL);
691 CU_ASSERT_EQUAL(lineout, NULL);
695 CU_ASSERT_FATAL(linein != NULL);
698 CU_ASSERT_NOT_EQUAL_FATAL(lineout, NULL);
711 double measure = 105.0;
751 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
758 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
765 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, sqrt(2.0), 0.000001);
772 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, sqrt(2.0)-1, 0.000001);
779 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0, 0.000001);
786 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0, 0.000001);
793 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
803 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
826 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
834 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
838 A1.
x = -2; A1.
y = -2;
842 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
847 A2.
x = 0; A2.
y = 0.5;
850 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
858 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0., 0.000001);
866 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, sqrt(2.0)-1, 0.000001);
874 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0, 0.000001);
883 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, sqrt(2.0)-1, 0.000001);
893 POINT2D A1, A2, A3, B1, B2, B3;
898 A1.
x = -1.0; A1.
y = 4.0;
899 A2.
x = 0.0; A2.
y = 5.0;
900 A3.
x = 1.0; A3.
y = 4.0;
901 B1.
x = 1.0; B1.
y = 6.0;
902 B2.
x = 6.0; B2.
y = 1.0;
903 B3.
x = 9.0; B3.
y = 7.0;
906 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.0475666, 0.000001);
920 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
929 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0, 0.000001);
938 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, sqrt(2)-1, 0.000001);
947 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0, 0.000001);
951 A1.
x = -2.0; A1.
y = 0.0;
952 A2.
x = 0.0; A2.
y = 2.0;
953 A3.
x = 2.0; A3.
y = 0.0;
956 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1.0, 0.000001);
960 A1.
x = -0.5 / sqrt(2.0); A1.
y = 0.5 / sqrt(2.0);
961 A2.
x = 0.0; A2.
y = 0.5;
962 A3.
x = 0.5 / sqrt(2.0); A3.
y = 0.5 / sqrt(2.0);
965 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
969 A1.
x = -0.5 / sqrt(2.0); A1.
y = -0.5 / sqrt(2.0);
970 A2.
x = -0.5; A2.
y = 0.0;
971 A3.
x = -0.5 / sqrt(2.0); A3.
y = 0.5 / sqrt(2.0);
974 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
978 A1.
x = -0.5 / sqrt(2.0); A1.
y = -0.5 / sqrt(2.0);
979 A2.
x = 0.0; A2.
y = -0.5;
980 A3.
x = 0.5 / sqrt(2.0); A3.
y = -0.5 / sqrt(2.0);
983 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.736813, 0.000001);
987 A1.
x = -1.0; A1.
y = 0.0;
988 A2.
x = 0.0; A2.
y = 1.0;
989 A3.
x = 1.0; A3.
y = 0.0;
992 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.0, 0.000001);
995 B1.
x = -10.0; B1.
y = 0.0;
996 B2.
x = 0.0 ; B2.
y = 10.0;
997 B3.
x = 10.0 ; B3.
y = 0.0;
1000 A1.
x = -22.0; A1.
y = 0.0;
1001 A2.
x = -17.0; A2.
y = -5.0;
1002 A3.
x = -12.0; A3.
y = 0.0;
1005 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 2.0, 0.000001);
1008 A1.
x = -19.0; A1.
y = 0.0;
1009 A2.
x = -14.0; A2.
y = -5.0;
1010 A3.
x = - 9.0; A3.
y = 0.0;
1013 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1.0, 0.000001);
1016 A1.
x = -9.0; A1.
y = 0.0;
1017 A2.
x = -4.0; A2.
y = -5.0;
1018 A3.
x = 1.0; A3.
y = 0.0;
1021 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1.0, 0.000001);
1024 A1.
x = -1.0; A1.
y = 0.0;
1025 A2.
x = 4.0; A2.
y = -5.0;
1026 A3.
x = 9.0; A3.
y = 0.0;
1029 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1.0, 0.000001);
1032 A1.
x = 1.0; A1.
y = 0.0;
1033 A2.
x = 6.0; A2.
y = -5.0;
1034 A3.
x = 11.0; A3.
y = 0.0;
1037 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1.0, 0.000001);
1040 A1.
x = 11.0; A1.
y = 0.0;
1041 A2.
x = 16.0; A2.
y = -5.0;
1042 A3.
x = 21.0; A3.
y = 0.0;
1045 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1.0, 0.000001);
1049 A1.
x = -15.0; A1.
y = -6.0;
1050 A2.
x = -10.0; A2.
y = -1.0;
1051 A3.
x = - 5.0; A3.
y = -6.0;
1054 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1.0, 0.000001);
1057 A1.
x = -5.0; A1.
y = 0.0;
1058 A2.
x = 0.0; A2.
y = 5.0;
1059 A3.
x = 5.0; A3.
y = 0.0;
1062 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 5.0, 0.000001);
1065 A1.
x = -5.0; A1.
y = 0.0;
1066 A2.
x = 0.0; A2.
y = -5.0;
1067 A3.
x = 5.0; A3.
y = 0.0;
1070 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 5.0, 0.000001);
1083 A1.
x = -1; A1.
y = 0;
1084 A2.
x = 0 ; A2.
y = 1;
1085 A3.
x = 1 ; A3.
y = 0;
1089 CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1091 CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1096 A3.
x = 0; A3.
y = -1;
1100 CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1102 CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1105 A1.
x = -1; A1.
y = 0;
1107 A3.
x = 0; A3.
y = -1;
1111 CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1113 CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1133 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
1140 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
1143 P.
y = P.
x = 2 * cos(M_PI_4);
1147 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
1158 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, sqrt(2.0), 0.000001);
1165 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
1168 P.
x = -1.5; P.
y = 0;
1172 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
1175 P.
x = -2.5; P.
y = 0;
1179 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
1182 P.
y = -2.5; P.
x = 0;
1186 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
1193 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, sqrt(2.0)-1.0, 0.000001);
1216 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
1226 "lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1235 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 1, 0.000001);
1244 CU_ASSERT_DOUBLE_EQUAL(dl.
distance, 0.5, 0.000001);
1266 "Both input geometries must have a measure dimension");
1277 "Both input geometries must be linestrings");
1291 "Both input lines must have at least 2 points"
1305 "Both input lines must have at least 2 points"
1543 CU_pSuite suite = CU_add_suite(
"measures", NULL, NULL);
static void test_lw_dist2d_ptarray_ptarrayarc(void)
static void test_lw_arc_length(void)
static void test_rect_tree_intersects_tree(void)
static void test_mindistance2d_tolerance(void)
static void test_lwgeom_is_trajectory(void)
void measures_suite_setup(void)
static int tree_inter(const char *wkt1, const char *wkt2)
static void test_lwgeom_tcpa(void)
static void test_lw_dist2d_seg_arc(void)
static void test_rect_tree_distance_tree(void)
static void test_lw_dist2d_pt_ptarrayarc(void)
static void test_lw_dist2d_arc_arc(void)
#define DIST3DTEST(str1, str2, res, accepted_error)
static void test_rect_tree_contains_point(void)
static void do_test_mindistance_tolerance(char *in1, char *in2, double expected_res, int line, double(*distancef)(const LWGEOM *, const LWGEOM *, double), double accepted_error)
static void test_lwgeom_locate_along(void)
static void test_lwgeom_segmentize2d(void)
static LWGEOM * lwgeom_from_text(const char *str)
static void test_lw_dist2d_pt_arc(void)
static double test_rect_tree_distance_tree_case(const char *wkt1, const char *wkt2)
static void test_mindistance3d_tolerance(void)
static int tree_pt(RECT_NODE *tree, double x, double y)
#define DIST2DTEST(str1, str2, res, accepted_error)
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
#define ASSERT_DOUBLE_EQUAL(o, e)
#define ASSERT_INT_EQUAL(o, e)
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
void lwgeom_request_interrupt(void)
Request interruption of any running code.
LWGEOM * lwgeom_locate_along(const LWGEOM *lwin, double m, double offset)
Determine the location(s) along a measured line where m occurs and return as a multipoint.
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
LWGEOM * lwgeom_segmentize2d(const LWGEOM *line, double dist)
int lwgeom_is_trajectory(const LWGEOM *geom)
Return LW_TRUE or LW_FALSE depending on whether or not a geometry is a linestring with measure value ...
int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int parse_flags)
Parse a WKT geometry string into an LWGEOM structure.
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
double lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist)
Find the time of closest point of approach.
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
#define LW_TRUE
Return types for functions with status returns.
#define FLAGS_SET_SOLID(flags, value)
void lwline_free(LWLINE *line)
int lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist)
Is the closest point of approach within a distance ?
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
RECT_NODE * rect_tree_from_lwgeom(const LWGEOM *lwgeom)
Create a tree index on top an LWGEOM.
int rect_tree_contains_point(RECT_NODE *node, const POINT2D *pt)
void rect_tree_free(RECT_NODE *node)
Recurse from top of node tree and free all children.
static double distance(double x1, double y1, double x2, double y2)
double rect_tree_distance_tree(RECT_NODE *n1, RECT_NODE *n2, double threshold)
Return the distance between two RECT_NODE trees.
int rect_tree_intersects_tree(RECT_NODE *n1, RECT_NODE *n2)
Test if two RECT_NODE trees intersect one another.
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
int lw_dist2d_seg_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Calculate the shortest distance between an arc and an edge.
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
int lw_dist2d_arc_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
int lw_dist2d_ptarray_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl)
Test each segment of pa against each arc of pb for distance.
int lw_dist2d_pt_ptarrayarc(const POINT2D *p, const POINTARRAY *pa, DISTPTS *dl)
Search all the arcs of pointarray to see which one is closest to p1 Returns minimum distance between ...
Structure used in distance-calculations.
Parser result structure: returns the result of attempting to convert (E)WKT/(E)WKB to LWGEOM.