PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_rect_tree_intersects_tree()

static void test_rect_tree_intersects_tree ( void  )
static

Definition at line 392 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().

393 {
394  LWPOLY *poly1, *poly2;
395  RECT_NODE *tree1, *tree2;
396  int result;
397 
398  /* total overlap, A == B */
399  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);
400  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);
401  tree1 = rect_tree_new(poly1->rings[0]);
402  tree2 = rect_tree_new(poly2->rings[0]);
403  result = rect_tree_intersects_tree(tree1, tree2);
404  CU_ASSERT_EQUAL(result, LW_TRUE);
405  lwpoly_free(poly1);
406  lwpoly_free(poly2);
407  rect_tree_free(tree1);
408  rect_tree_free(tree2);
409 
410  /* hiding between the tines of the comb */
411  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);
412  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);
413  tree1 = rect_tree_new(poly1->rings[0]);
414  tree2 = rect_tree_new(poly2->rings[0]);
415  result = rect_tree_intersects_tree(tree1, tree2);
416  CU_ASSERT_EQUAL(result, LW_FALSE);
417  lwpoly_free(poly1);
418  lwpoly_free(poly2);
419  rect_tree_free(tree1);
420  rect_tree_free(tree2);
421 
422  /* between the tines, but with a corner overlapping */
423  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);
424  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);
425  tree1 = rect_tree_new(poly1->rings[0]);
426  tree2 = rect_tree_new(poly2->rings[0]);
427  result = rect_tree_intersects_tree(tree1, tree2);
428  CU_ASSERT_EQUAL(result, LW_TRUE);
429  lwpoly_free(poly1);
430  lwpoly_free(poly2);
431  rect_tree_free(tree1);
432  rect_tree_free(tree2);
433 
434  /* Just touching the top left corner of the comb */
435  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);
436  poly2 = (LWPOLY*)lwgeom_from_wkt("POLYGON((-1 5, 0 5, 0 7, -1 7, -1 5))", LW_PARSER_CHECK_NONE);
437  tree1 = rect_tree_new(poly1->rings[0]);
438  tree2 = rect_tree_new(poly2->rings[0]);
439  result = rect_tree_intersects_tree(tree1, tree2);
440  CU_ASSERT_EQUAL(result, LW_TRUE);
441  lwpoly_free(poly1);
442  lwpoly_free(poly2);
443  rect_tree_free(tree1);
444  rect_tree_free(tree2);
445 
446 
447 }
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:2013
#define LW_FALSE
Definition: liblwgeom.h:77
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:174
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
POINTARRAY ** rings
Definition: liblwgeom.h:457
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: