PostGIS  2.2.7dev-r@@SVN_REVISION@@
int rect_tree_intersects_tree ( const RECT_NODE n1,
const RECT_NODE n2 
)

Definition at line 55 of file lwtree.c.

References FP_GT, rect_node::left_node, LW_FALSE, lw_segment_intersects(), LW_TRUE, LWDEBUG, LWDEBUGF, rect_node::p1, rect_node::p2, rect_node_is_leaf(), rect_tree_intersects_tree(), rect_node::right_node, rect_node::xmax, rect_node::xmin, rect_node::ymax, and rect_node::ymin.

Referenced by rect_tree_intersects_tree(), and test_rect_tree_intersects_tree().

56 {
57  LWDEBUGF(4,"n1 (%.9g %.9g,%.9g %.9g) vs n2 (%.9g %.9g,%.9g %.9g)",n1->xmin,n1->ymin,n1->xmax,n1->ymax,n2->xmin,n2->ymin,n2->xmax,n2->ymax);
58  /* There can only be an edge intersection if the rectangles overlap */
59  if ( ! ( FP_GT(n1->xmin, n2->xmax) || FP_GT(n2->xmin, n1->xmax) || FP_GT(n1->ymin, n2->ymax) || FP_GT(n2->ymin, n1->ymax) ) )
60  {
61  LWDEBUG(4," interaction found");
62  /* We can only test for a true intersection if the nodes are both leaf nodes */
63  if ( rect_node_is_leaf(n1) && rect_node_is_leaf(n2) )
64  {
65  LWDEBUG(4," leaf node test");
66  /* Check for true intersection */
67  if ( lw_segment_intersects(n1->p1, n1->p2, n2->p1, n2->p2) )
68  return LW_TRUE;
69  else
70  return LW_FALSE;
71  }
72  else
73  {
74  LWDEBUG(4," internal node found, recursing");
75  /* Recurse to children */
76  if ( rect_node_is_leaf(n1) )
77  {
79  return LW_TRUE;
80  else
81  return LW_FALSE;
82  }
83  else
84  {
86  return LW_TRUE;
87  else
88  return LW_FALSE;
89  }
90  }
91  }
92  else
93  {
94  LWDEBUG(4," no interaction found");
95  return LW_FALSE;
96  }
97 }
struct rect_node * right_node
Definition: lwtree.h:11
POINT2D * p1
Definition: lwtree.h:12
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
POINT2D * p2
Definition: lwtree.h:13
double xmax
Definition: lwtree.h:7
static int rect_node_is_leaf(const RECT_NODE *node)
Internal nodes have their point references set to NULL.
Definition: lwtree.c:9
#define LW_FALSE
Definition: liblwgeom.h:62
#define FP_GT(A, B)
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
double ymax
Definition: lwtree.h:9
double xmin
Definition: lwtree.h:6
double ymin
Definition: lwtree.h:8
int rect_tree_intersects_tree(const RECT_NODE *n1, const RECT_NODE *n2)
Definition: lwtree.c:55
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
struct rect_node * left_node
Definition: lwtree.h:10
int lw_segment_intersects(const POINT2D *p1, const POINT2D *p2, const POINT2D *q1, const POINT2D *q2)
returns the kind of CG_SEGMENT_INTERSECTION_TYPE behavior of lineseg 1 (constructed from p1 and p2) a...
Definition: lwalgorithm.c:357

Here is the call graph for this function:

Here is the caller graph for this function: