PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ point_in_multipolygon_rtree()

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

Definition at line 931 of file lwgeom_functions_analytic.c.

932 {
933  int i, p, r, in_ring;
934  POINT2D pt;
935  int result = -1;
936 
937  POSTGIS_DEBUGF(2, "point_in_multipolygon_rtree called for %p %d %p.", root, polyCount, point);
938 
939  getPoint2d_p(point->point, 0, &pt);
940  /* assume bbox short-circuit has already been attempted */
941 
942  i = 0; /* the current index into the root array */
943 
944  /* is the point inside any of the sub-polygons? */
945  for ( p = 0; p < polyCount; p++ )
946  {
947  in_ring = point_in_ring_rtree(root[i], &pt);
948  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: exterior ring (%d), point_in_ring returned %d", p, in_ring);
949  if ( in_ring == -1 ) /* outside the exterior ring */
950  {
951  POSTGIS_DEBUG(3, "point_in_multipolygon_rtree: outside exterior ring.");
952  }
953  else if ( in_ring == 0 ) /* on the boundary */
954  {
955  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of exterior ring %d", p);
956  return 0;
957  } else {
958  result = in_ring;
959 
960  for(r=1; r<ringCounts[p]; r++)
961  {
962  in_ring = point_in_ring_rtree(root[i+r], &pt);
963  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: interior ring (%d), point_in_ring returned %d", r, in_ring);
964  if (in_ring == 1) /* inside a hole => outside the polygon */
965  {
966  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: within hole %d of exterior ring %d", r, p);
967  result = -1;
968  break;
969  }
970  if (in_ring == 0) /* on the edge of a hole */
971  {
972  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of hole %d of exterior ring %d", r, p);
973  return 0;
974  }
975  }
976  /* if we have a positive result, we can short-circuit and return it */
977  if ( result != -1)
978  {
979  return result;
980  }
981  }
982  /* increment the index by the total number of rings in the sub-poly */
983  /* we do this here in case we short-cutted out of the poly before looking at all the rings */
984  i += ringCounts[p];
985  }
986 
987  return result; /* -1 = outside, 0 = boundary, 1 = inside */
988 
989 }
char * r
Definition: cu_in_wkt.c:24
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:342
static int point_in_ring_rtree(RTREE_NODE *root, const POINT2D *point)
POINTARRAY * point
Definition: liblwgeom.h:471

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

Referenced by pip_short_circuit().

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