PostGIS  2.1.10dev-r@@SVN_REVISION@@
int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT point 
)

Definition at line 1227 of file lwgeom_functions_analytic.c.

References LWMPOLY::geoms, getPoint2d_p(), LWMPOLY::ngeoms, LWPOLY::nrings, LWPOINT::point, point_in_ring(), result, and LWPOLY::rings.

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

1228 {
1229  int i, j, result, in_ring;
1230  POINT2D pt;
1231 
1232  POSTGIS_DEBUG(2, "point_in_polygon called.");
1233 
1234  getPoint2d_p(point->point, 0, &pt);
1235  /* assume bbox short-circuit has already been attempted */
1236 
1237  result = -1;
1238 
1239  for (j = 0; j < mpolygon->ngeoms; j++ )
1240  {
1241 
1242  LWPOLY *polygon = mpolygon->geoms[j];
1243 
1244  /* everything is outside of an empty polygon */
1245  if ( polygon->nrings == 0 ) continue;
1246 
1247  in_ring = point_in_ring(polygon->rings[0], &pt);
1248  if ( in_ring == -1) /* outside the exterior ring */
1249  {
1250  POSTGIS_DEBUG(3, "point_in_polygon: outside exterior ring.");
1251  continue;
1252  }
1253  if ( in_ring == 0 )
1254  {
1255  return 0;
1256  }
1257 
1258  result = in_ring;
1259 
1260  for (i=1; i<polygon->nrings; i++)
1261  {
1262  in_ring = point_in_ring(polygon->rings[i], &pt);
1263  if (in_ring == 1) /* inside a hole => outside the polygon */
1264  {
1265  POSTGIS_DEBUGF(3, "point_in_polygon: within hole %d.", i);
1266  result = -1;
1267  break;
1268  }
1269  if (in_ring == 0) /* on the edge of a hole */
1270  {
1271  POSTGIS_DEBUGF(3, "point_in_polygon: on edge of hole %d.", i);
1272  return 0;
1273  }
1274  }
1275  if ( result != -1)
1276  {
1277  return result;
1278  }
1279  }
1280  return result;
1281 }
POINTARRAY * point
Definition: liblwgeom.h:367
char ** result
Definition: liblwgeom.h:218
LWPOLY ** geoms
Definition: liblwgeom.h:452
POINTARRAY ** rings
Definition: liblwgeom.h:413
int nrings
Definition: liblwgeom.h:411
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:434
int ngeoms
Definition: liblwgeom.h:450
int point_in_ring(POINTARRAY *pts, POINT2D *point)

Here is the call graph for this function:

Here is the caller graph for this function: