PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ test_rect_tree_intersects_tree()

static void test_rect_tree_intersects_tree ( void  )
static

Definition at line 346 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(), and LWPOLY::rings.

Referenced by measures_suite_setup().

347 {
348  LWPOLY *poly1, *poly2;
349  RECT_NODE *tree1, *tree2;
350  int result;
351 
352  /* total overlap, A == B */
353  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);
354  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);
355  tree1 = rect_tree_new(poly1->rings[0]);
356  tree2 = rect_tree_new(poly2->rings[0]);
357  result = rect_tree_intersects_tree(tree1, tree2);
358  CU_ASSERT_EQUAL(result, LW_TRUE);
359  lwpoly_free(poly1);
360  lwpoly_free(poly2);
361  rect_tree_free(tree1);
362  rect_tree_free(tree2);
363 
364  /* hiding between the tines of the comb */
365  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);
366  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);
367  tree1 = rect_tree_new(poly1->rings[0]);
368  tree2 = rect_tree_new(poly2->rings[0]);
369  result = rect_tree_intersects_tree(tree1, tree2);
370  CU_ASSERT_EQUAL(result, LW_FALSE);
371  lwpoly_free(poly1);
372  lwpoly_free(poly2);
373  rect_tree_free(tree1);
374  rect_tree_free(tree2);
375 
376  /* between the tines, but with a corner overlapping */
377  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);
378  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);
379  tree1 = rect_tree_new(poly1->rings[0]);
380  tree2 = rect_tree_new(poly2->rings[0]);
381  result = rect_tree_intersects_tree(tree1, tree2);
382  CU_ASSERT_EQUAL(result, LW_TRUE);
383  lwpoly_free(poly1);
384  lwpoly_free(poly2);
385  rect_tree_free(tree1);
386  rect_tree_free(tree2);
387 
388  /* Just touching the top left corner of the comb */
389  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);
390  poly2 = (LWPOLY*)lwgeom_from_wkt("POLYGON((-1 5, 0 5, 0 7, -1 7, -1 5))", LW_PARSER_CHECK_NONE);
391  tree1 = rect_tree_new(poly1->rings[0]);
392  tree2 = rect_tree_new(poly2->rings[0]);
393  result = rect_tree_intersects_tree(tree1, tree2);
394  CU_ASSERT_EQUAL(result, LW_TRUE);
395  lwpoly_free(poly1);
396  lwpoly_free(poly2);
397  rect_tree_free(tree1);
398  rect_tree_free(tree2);
399 
400 
401 }
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
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:175
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1985
#define LW_FALSE
Definition: liblwgeom.h:76
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:152
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
POINTARRAY ** rings
Definition: liblwgeom.h:456
int rect_tree_intersects_tree(const RECT_NODE *n1, const RECT_NODE *n2)
Definition: lwtree.c:79
void rect_tree_free(RECT_NODE *node)
Recurse from top of node tree and free all children.
Definition: lwtree.c:42
Here is the call graph for this function:
Here is the caller graph for this function: