PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rect_tree_area_contains_point()

static int rect_tree_area_contains_point ( RECT_NODE node,
const POINT2D pt 
)
static

Definition at line 344 of file lwtree.c.

345 {
346  /* Can't do anything with a leaf node, makes no sense */
347  if (rect_node_is_leaf(node))
348  return 0;
349 
350  /* Iterate into area until we find ring heads */
351  if (node->i.ring_type == RECT_NODE_RING_NONE)
352  {
353  int i, sum = 0;
354  for (i = 0; i < node->i.num_nodes; i++)
355  sum += rect_tree_area_contains_point(node->i.nodes[i], pt);
356  return sum;
357  }
358  /* See if the ring encloses the point */
359  else
360  {
361  int on_boundary = 0;
362  int edge_crossing_count = rect_tree_ring_contains_point(node, pt, &on_boundary);
363  /* Odd number of crossings => contained */
364  int contained = (edge_crossing_count % 2 == 1);
365  /* External rings return positive containment, interior ones negative, */
366  /* so that a point-in-hole case nets out to zero (contained by both */
367  /* interior and exterior rings. */
368  if (node->i.ring_type == RECT_NODE_RING_INTERIOR)
369  {
370  return on_boundary ? 0 : -1 * contained;
371  }
372  else
373  {
374  return contained || on_boundary;
375  }
376 
377  }
378 }
static int rect_tree_ring_contains_point(RECT_NODE *node, const POINT2D *pt, int *on_boundary)
Definition: lwtree.c:314
static int rect_tree_area_contains_point(RECT_NODE *node, const POINT2D *pt)
Definition: lwtree.c:344
static int rect_node_is_leaf(const RECT_NODE *node)
Definition: lwtree.c:31
@ RECT_NODE_RING_INTERIOR
Definition: lwtree.h:37
@ RECT_NODE_RING_NONE
Definition: lwtree.h:35
struct rect_node * nodes[RECT_NODE_SIZE]
Definition: lwtree.h:61
RECT_NODE_RING_TYPE ring_type
Definition: lwtree.h:60
RECT_NODE_INTERNAL i
Definition: lwtree.h:75

References rect_node::i, RECT_NODE_INTERNAL::nodes, RECT_NODE_INTERNAL::num_nodes, rect_node_is_leaf(), RECT_NODE_RING_INTERIOR, RECT_NODE_RING_NONE, rect_tree_ring_contains_point(), and RECT_NODE_INTERNAL::ring_type.

Referenced by rect_tree_contains_point().

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