PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ point_in_multipolygon_rtree()

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

Definition at line 888 of file lwgeom_functions_analytic.c.

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

Referenced by pip_short_circuit().

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