PostGIS  2.5.0dev-r@@SVN_REVISION@@
int point_in_multipolygon_rtree ( RTREE_NODE **  root,
int  polyCount,
int *  ringCounts,
LWPOINT point 
)

Definition at line 846 of file lwgeom_functions_analytic.c.

References getPoint2d_p(), LWPOINT::point, point_in_ring_rtree(), and r.

Referenced by pip_short_circuit().

847 {
848  int i, p, r, in_ring;
849  POINT2D pt;
850  int result = -1;
851 
852  POSTGIS_DEBUGF(2, "point_in_multipolygon_rtree called for %p %d %p.", root, polyCount, point);
853 
854  getPoint2d_p(point->point, 0, &pt);
855  /* assume bbox short-circuit has already been attempted */
856 
857  i = 0; /* the current index into the root array */
858 
859  /* is the point inside any of the sub-polygons? */
860  for ( p = 0; p < polyCount; p++ )
861  {
862  in_ring = point_in_ring_rtree(root[i], &pt);
863  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: exterior ring (%d), point_in_ring returned %d", p, in_ring);
864  if ( in_ring == -1 ) /* outside the exterior ring */
865  {
866  POSTGIS_DEBUG(3, "point_in_multipolygon_rtree: outside exterior ring.");
867  }
868  else if ( in_ring == 0 ) /* on the boundary */
869  {
870  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of exterior ring %d", p);
871  return 0;
872  } else {
873  result = in_ring;
874 
875  for(r=1; r<ringCounts[p]; r++)
876  {
877  in_ring = point_in_ring_rtree(root[i+r], &pt);
878  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: interior ring (%d), point_in_ring returned %d", r, in_ring);
879  if (in_ring == 1) /* inside a hole => outside the polygon */
880  {
881  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: within hole %d of exterior ring %d", r, p);
882  result = -1;
883  break;
884  }
885  if (in_ring == 0) /* on the edge of a hole */
886  {
887  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of hole %d of exterior ring %d", r, p);
888  return 0;
889  }
890  }
891  /* if we have a positive result, we can short-circuit and return it */
892  if ( result != -1)
893  {
894  return result;
895  }
896  }
897  /* increment the index by the total number of rings in the sub-poly */
898  /* we do this here in case we short-cutted out of the poly before looking at all the rings */
899  i += ringCounts[p];
900  }
901 
902  return result; /* -1 = outside, 0 = boundary, 1 = inside */
903 
904 }
static int point_in_ring_rtree(RTREE_NODE *root, const POINT2D *point)
char * r
Definition: cu_in_wkt.c:24
POINTARRAY * point
Definition: liblwgeom.h:410
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:338

Here is the call graph for this function:

Here is the caller graph for this function: