PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ point_in_multipolygon_rtree()

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

Definition at line 891 of file lwgeom_functions_analytic.c.

892 {
893  int i, p, r, in_ring;
894  POINT2D pt;
895  int result = -1;
896 
897  POSTGIS_DEBUGF(2, "point_in_multipolygon_rtree called for %p %d %p.", root, polyCount, point);
898 
899  getPoint2d_p(point->point, 0, &pt);
900  /* assume bbox short-circuit has already been attempted */
901 
902  i = 0; /* the current index into the root array */
903 
904  /* is the point inside any of the sub-polygons? */
905  for ( p = 0; p < polyCount; p++ )
906  {
907  in_ring = point_in_ring_rtree(root[i], &pt);
908  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: exterior ring (%d), point_in_ring returned %d", p, in_ring);
909  if ( in_ring == -1 ) /* outside the exterior ring */
910  {
911  POSTGIS_DEBUG(3, "point_in_multipolygon_rtree: outside exterior ring.");
912  }
913  else if ( in_ring == 0 ) /* on the boundary */
914  {
915  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of exterior ring %d", p);
916  return 0;
917  } else {
918  result = in_ring;
919 
920  for(r=1; r<ringCounts[p]; r++)
921  {
922  in_ring = point_in_ring_rtree(root[i+r], &pt);
923  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: interior ring (%d), point_in_ring returned %d", r, in_ring);
924  if (in_ring == 1) /* inside a hole => outside the polygon */
925  {
926  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: within hole %d of exterior ring %d", r, p);
927  result = -1;
928  break;
929  }
930  if (in_ring == 0) /* on the edge of a hole */
931  {
932  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of hole %d of exterior ring %d", r, p);
933  return 0;
934  }
935  }
936  /* if we have a positive result, we can short-circuit and return it */
937  if ( result != -1)
938  {
939  return result;
940  }
941  }
942  /* increment the index by the total number of rings in the sub-poly */
943  /* we do this here in case we short-cutted out of the poly before looking at all the rings */
944  i += ringCounts[p];
945  }
946 
947  return result; /* -1 = outside, 0 = boundary, 1 = inside */
948 
949 }
char * r
Definition: cu_in_wkt.c:24
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:348
static int point_in_ring_rtree(RTREE_NODE *root, const POINT2D *point)
POINTARRAY * point
Definition: liblwgeom.h:414

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

Referenced by pip_short_circuit().

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