PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rect_tree_intersects_tree_recursive()

static int rect_tree_intersects_tree_recursive ( RECT_NODE n1,
RECT_NODE n2 
)
static

Definition at line 936 of file lwtree.c.

937 {
938  int i, j;
939 #if POSTGIS_DEBUG_LEVEL >= 4
940  char *n1_str = rect_node_to_str(n1);
941  char *n2_str = rect_node_to_str(n2);
942  LWDEBUGF(4,"n1 %s n2 %s", n1, n2);
943  lwfree(n1_str);
944  lwfree(n2_str);
945 #endif
946  /* There can only be an edge intersection if the rectangles overlap */
947  if (rect_node_intersects(n1, n2))
948  {
949  LWDEBUG(4," interaction found");
950  /* We can only test for a true intersection if the nodes are both leaf nodes */
951  if (rect_node_is_leaf(n1) && rect_node_is_leaf(n2))
952  {
953  LWDEBUG(4," leaf node test");
954  /* Check for true intersection */
955  return rect_leaf_node_intersects(&n1->l, &n2->l);
956  }
957  else if (rect_node_is_leaf(n2) && !rect_node_is_leaf(n1))
958  {
959  for (i = 0; i < n1->i.num_nodes; i++)
960  {
962  return LW_TRUE;
963  }
964  }
965  else if (rect_node_is_leaf(n1) && !rect_node_is_leaf(n2))
966  {
967  for (i = 0; i < n2->i.num_nodes; i++)
968  {
970  return LW_TRUE;
971  }
972  }
973  else
974  {
975  for (j = 0; j < n1->i.num_nodes; j++)
976  {
977  for (i = 0; i < n2->i.num_nodes; i++)
978  {
979  if (rect_tree_intersects_tree_recursive(n2->i.nodes[i], n1->i.nodes[j]))
980  return LW_TRUE;
981  }
982  }
983  }
984  }
985  return LW_FALSE;
986 }
#define LW_FALSE
Definition: liblwgeom.h:77
void lwfree(void *mem)
Definition: lwutil.c:244
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
static int rect_tree_intersects_tree_recursive(RECT_NODE *n1, RECT_NODE *n2)
Definition: lwtree.c:936
static int rect_leaf_node_intersects(RECT_NODE_LEAF *n1, RECT_NODE_LEAF *n2)
Definition: lwtree.c:85
static int rect_node_intersects(const RECT_NODE *n1, const RECT_NODE *n2)
Definition: lwtree.c:907
static int rect_node_is_leaf(const RECT_NODE *node)
Definition: lwtree.c:31
struct rect_node * nodes[RECT_NODE_SIZE]
Definition: lwtree.h:61
RECT_NODE_INTERNAL i
Definition: lwtree.h:75
RECT_NODE_LEAF l
Definition: lwtree.h:76

References rect_node::i, rect_node::l, LW_FALSE, LW_TRUE, LWDEBUG, LWDEBUGF, lwfree(), RECT_NODE_INTERNAL::nodes, RECT_NODE_INTERNAL::num_nodes, rect_leaf_node_intersects(), rect_node_intersects(), and rect_node_is_leaf().

Referenced by rect_tree_intersects_tree().

Here is the call graph for this function:
Here is the caller graph for this function: