PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_rect_tree_intersects_tree ( void  )
static

Definition at line 345 of file cu_measures.c.

References LW_FALSE, LW_PARSER_CHECK_NONE, LW_TRUE, lwgeom_from_wkt(), lwpoly_free(), rect_tree_free(), rect_tree_intersects_tree(), rect_tree_new(), result, and LWPOLY::rings.

Referenced by measures_suite_setup().

346 {
347  LWPOLY *poly1, *poly2;
348  RECT_NODE *tree1, *tree2;
349  int result;
350 
351  /* total overlap, A == B */
352  poly1 = (LWPOLY*)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);
353  poly2 = (LWPOLY*)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);
354  tree1 = rect_tree_new(poly1->rings[0]);
355  tree2 = rect_tree_new(poly2->rings[0]);
356  result = rect_tree_intersects_tree(tree1, tree2);
357  CU_ASSERT_EQUAL(result, LW_TRUE);
358  lwpoly_free(poly1);
359  lwpoly_free(poly2);
360  rect_tree_free(tree1);
361  rect_tree_free(tree2);
362 
363  /* hiding between the tines of the comb */
364  poly1 = (LWPOLY*)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);
365  poly2 = (LWPOLY*)lwgeom_from_wkt("POLYGON((0.3 0.7, 0.3 0.8, 0.4 0.8, 0.4 0.7, 0.3 0.7))", LW_PARSER_CHECK_NONE);
366  tree1 = rect_tree_new(poly1->rings[0]);
367  tree2 = rect_tree_new(poly2->rings[0]);
368  result = rect_tree_intersects_tree(tree1, tree2);
369  CU_ASSERT_EQUAL(result, LW_FALSE);
370  lwpoly_free(poly1);
371  lwpoly_free(poly2);
372  rect_tree_free(tree1);
373  rect_tree_free(tree2);
374 
375  /* between the tines, but with a corner overlapping */
376  poly1 = (LWPOLY*)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);
377  poly2 = (LWPOLY*)lwgeom_from_wkt("POLYGON((0.3 0.7, 0.3 0.8, 0.4 0.8, 1.3 0.3, 0.3 0.7))", LW_PARSER_CHECK_NONE);
378  tree1 = rect_tree_new(poly1->rings[0]);
379  tree2 = rect_tree_new(poly2->rings[0]);
380  result = rect_tree_intersects_tree(tree1, tree2);
381  CU_ASSERT_EQUAL(result, LW_TRUE);
382  lwpoly_free(poly1);
383  lwpoly_free(poly2);
384  rect_tree_free(tree1);
385  rect_tree_free(tree2);
386 
387  /* Just touching the top left corner of the comb */
388  poly1 = (LWPOLY*)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);
389  poly2 = (LWPOLY*)lwgeom_from_wkt("POLYGON((-1 5, 0 5, 0 7, -1 7, -1 5))", LW_PARSER_CHECK_NONE);
390  tree1 = rect_tree_new(poly1->rings[0]);
391  tree2 = rect_tree_new(poly2->rings[0]);
392  result = rect_tree_intersects_tree(tree1, tree2);
393  CU_ASSERT_EQUAL(result, LW_TRUE);
394  lwpoly_free(poly1);
395  lwpoly_free(poly2);
396  rect_tree_free(tree1);
397  rect_tree_free(tree2);
398 
399 
400 }
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
char ** result
Definition: liblwgeom.h:218
RECT_NODE * rect_tree_new(const POINTARRAY *pa)
Build a tree of nodes from a point array, one node per edge, and each with an associated measure rang...
Definition: lwtree.c:151
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
#define LW_FALSE
Definition: liblwgeom.h:52
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:79
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
POINTARRAY ** rings
Definition: liblwgeom.h:413
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
Definition: lwtree.h:4
int rect_tree_intersects_tree(const RECT_NODE *n1, const RECT_NODE *n2)
Definition: lwtree.c:55
void rect_tree_free(RECT_NODE *node)
Recurse from top of node tree and free all children.
Definition: lwtree.c:18

Here is the call graph for this function:

Here is the caller graph for this function: