PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ itree_point_in_multipolygon()

IntervalTreeResult itree_point_in_multipolygon ( const IntervalTree itree,
const LWPOINT point 
)

Definition at line 461 of file intervaltree.c.

462 {
463  uint32_t i = 0;
464  const POINT2D *pt;
466 
467  /* Empty is not within anything */
468  if (lwpoint_is_empty(point))
469  return ITREE_OUTSIDE;
470 
471  /* Non-finite point is within anything */
472  pt = getPoint2d_cp(point->point, 0);
473  if (!pt || !(isfinite(pt->x) && isfinite(pt->y)))
474  return ITREE_OUTSIDE;
475 
476  /* Is the point inside any of the exterior rings of the sub-polygons? */
477  for (uint32_t p = 0; p < itree->numPolys; p++)
478  {
479  uint32_t ringCount = itree->ringCounts[p];
480 
481  /* Skip empty polygons */
482  if (ringCount == 0) continue;
483 
484  /* Check result against exterior ring. */
485  result = itree_point_in_ring(itree, i, pt);
486 
487  /* Boundary condition is a hard stop */
488  if (result == ITREE_BOUNDARY)
489  return ITREE_BOUNDARY;
490 
491  /* We are inside an exterior ring! Are we outside all the holes? */
492  if (result == ITREE_INSIDE)
493  {
494  for(uint32_t r = 1; r < itree->ringCounts[p]; r++)
495  {
496  result = itree_point_in_ring(itree, i+r, pt);
497 
498  /* Boundary condition is a hard stop */
499  if (result == ITREE_BOUNDARY)
500  return ITREE_BOUNDARY;
501 
502  /*
503  * Inside a hole => Outside the polygon!
504  * But there might be other polygons lurking
505  * inside this hole so we have to continue
506  * and check all the exterior rings.
507  */
508  if (result == ITREE_INSIDE)
509  goto holes_done;
510  }
511  return ITREE_INSIDE;
512  }
513 
514  holes_done:
515  /* Move to first ring of next polygon */
516  i += ringCount;
517  }
518 
519  /* Not in any rings */
520  return ITREE_OUTSIDE;
521 }
char * r
Definition: cu_in_wkt.c:24
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
static IntervalTreeResult itree_point_in_ring(const IntervalTree *itree, uint32_t ringNumber, const POINT2D *pt)
Definition: intervaltree.c:435
IntervalTreeResult
Definition: intervaltree.h:32
@ ITREE_BOUNDARY
Definition: intervaltree.h:34
@ ITREE_INSIDE
Definition: intervaltree.h:33
@ ITREE_OUTSIDE
Definition: intervaltree.h:35
int lwpoint_is_empty(const LWPOINT *point)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwinline.h:97
uint32_t * ringCounts
Definition: intervaltree.h:62
uint32_t numPolys
Definition: intervaltree.h:63
POINTARRAY * point
Definition: liblwgeom.h:471
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390

References getPoint2d_cp(), ITREE_BOUNDARY, ITREE_INSIDE, ITREE_OUTSIDE, itree_point_in_ring(), lwpoint_is_empty(), IntervalTree::numPolys, LWPOINT::point, r, result, IntervalTree::ringCounts, POINT2D::x, and POINT2D::y.

Referenced by itree_pip_contains(), itree_pip_covers(), itree_pip_intersects(), ST_IntersectsIntervalTree(), and test_itree_once().

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