PostGIS  2.2.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 889 of file lwgeom_functions_analytic.c.

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

Referenced by contains(), coveredby(), covers(), and geos_intersects().

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