PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ point_in_multipolygon_rtree()

int point_in_multipolygon_rtree ( RTREE_NODE **  root,
int  polyCount,
int *  ringCounts,
LWPOINT point 
)

Definition at line 918 of file lwgeom_functions_analytic.c.

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

Referenced by pip_short_circuit().

919 {
920  int i, p, r, in_ring;
921  POINT2D pt;
922  int result = -1;
923 
924  POSTGIS_DEBUGF(2, "point_in_multipolygon_rtree called for %p %d %p.", root, polyCount, point);
925 
926  getPoint2d_p(point->point, 0, &pt);
927  /* assume bbox short-circuit has already been attempted */
928 
929  i = 0; /* the current index into the root array */
930 
931  /* is the point inside any of the sub-polygons? */
932  for ( p = 0; p < polyCount; p++ )
933  {
934  in_ring = point_in_ring_rtree(root[i], &pt);
935  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: exterior ring (%d), point_in_ring returned %d", p, in_ring);
936  if ( in_ring == -1 ) /* outside the exterior ring */
937  {
938  POSTGIS_DEBUG(3, "point_in_multipolygon_rtree: outside exterior ring.");
939  }
940  else if ( in_ring == 0 ) /* on the boundary */
941  {
942  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of exterior ring %d", p);
943  return 0;
944  } else {
945  result = in_ring;
946 
947  for(r=1; r<ringCounts[p]; r++)
948  {
949  in_ring = point_in_ring_rtree(root[i+r], &pt);
950  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: interior ring (%d), point_in_ring returned %d", r, in_ring);
951  if (in_ring == 1) /* inside a hole => outside the polygon */
952  {
953  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: within hole %d of exterior ring %d", r, p);
954  result = -1;
955  break;
956  }
957  if (in_ring == 0) /* on the edge of a hole */
958  {
959  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of hole %d of exterior ring %d", r, p);
960  return 0;
961  }
962  }
963  /* if we have a positive result, we can short-circuit and return it */
964  if ( result != -1)
965  {
966  return result;
967  }
968  }
969  /* increment the index by the total number of rings in the sub-poly */
970  /* we do this here in case we short-cutted out of the poly before looking at all the rings */
971  i += ringCounts[p];
972  }
973 
974  return result; /* -1 = outside, 0 = boundary, 1 = inside */
975 
976 }
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:411
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:347
Here is the call graph for this function:
Here is the caller graph for this function: