PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ point_in_multipolygon_rtree()

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

Definition at line 909 of file lwgeom_functions_analytic.c.

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

Referenced by pip_short_circuit().

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