PostGIS  2.1.10dev-r@@SVN_REVISION@@
int point_in_multipolygon_rtree ( RTREE_NODE **  root,
int  polyCount,
int *  ringCounts,
LWPOINT point 
)

Definition at line 1119 of file lwgeom_functions_analytic.c.

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

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

1120 {
1121  int i, p, r, in_ring;
1122  POINT2D pt;
1123  int result = -1;
1124 
1125  POSTGIS_DEBUGF(2, "point_in_multipolygon_rtree called for %p %d %p.", root, polyCount, point);
1126 
1127  getPoint2d_p(point->point, 0, &pt);
1128  /* assume bbox short-circuit has already been attempted */
1129 
1130  i = 0; /* the current index into the root array */
1131 
1132  /* is the point inside any of the sub-polygons? */
1133  for ( p = 0; p < polyCount; p++ )
1134  {
1135  in_ring = point_in_ring_rtree(root[i], &pt);
1136  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: exterior ring (%d), point_in_ring returned %d", p, in_ring);
1137  if ( in_ring == -1 ) /* outside the exterior ring */
1138  {
1139  POSTGIS_DEBUG(3, "point_in_multipolygon_rtree: outside exterior ring.");
1140  }
1141  else if ( in_ring == 0 ) /* on the boundary */
1142  {
1143  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of exterior ring %d", p);
1144  return 0;
1145  } else {
1146  result = in_ring;
1147 
1148  for(r=1; r<ringCounts[p]; r++)
1149  {
1150  in_ring = point_in_ring_rtree(root[i+r], &pt);
1151  POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: interior ring (%d), point_in_ring returned %d", r, in_ring);
1152  if (in_ring == 1) /* inside a hole => outside the polygon */
1153  {
1154  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: within hole %d of exterior ring %d", r, p);
1155  result = -1;
1156  break;
1157  }
1158  if (in_ring == 0) /* on the edge of a hole */
1159  {
1160  POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of hole %d of exterior ring %d", r, p);
1161  return 0;
1162  }
1163  }
1164  /* if we have a positive result, we can short-circuit and return it */
1165  if ( result != -1)
1166  {
1167  return result;
1168  }
1169  }
1170  /* increment the index by the total number of rings in the sub-poly */
1171  /* we do this here in case we short-cutted out of the poly before looking at all the rings */
1172  i += ringCounts[p];
1173  }
1174 
1175  return result; /* -1 = outside, 0 = boundary, 1 = inside */
1176 
1177 }
char * r
Definition: cu_in_wkt.c:25
POINTARRAY * point
Definition: liblwgeom.h:367
char ** result
Definition: liblwgeom.h:218
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:434
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: