PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ point_in_multipolygon()

int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT point 
)

Definition at line 997 of file lwgeom_functions_analytic.c.

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

Referenced by pip_short_circuit().

998 {
999  uint32_t i, j;
1000  int result, in_ring;
1001  POINT2D pt;
1002 
1003  POSTGIS_DEBUG(2, "point_in_polygon called.");
1004 
1005  getPoint2d_p(point->point, 0, &pt);
1006  /* assume bbox short-circuit has already been attempted */
1007 
1008  result = -1;
1009 
1010  for (j = 0; j < mpolygon->ngeoms; j++ )
1011  {
1012 
1013  LWPOLY *polygon = mpolygon->geoms[j];
1014 
1015  /* everything is outside of an empty polygon */
1016  if ( polygon->nrings == 0 ) continue;
1017 
1018  in_ring = point_in_ring(polygon->rings[0], &pt);
1019  if ( in_ring == -1) /* outside the exterior ring */
1020  {
1021  POSTGIS_DEBUG(3, "point_in_polygon: outside exterior ring.");
1022  continue;
1023  }
1024  if ( in_ring == 0 )
1025  {
1026  return 0;
1027  }
1028 
1029  result = in_ring;
1030 
1031  for (i=1; i<polygon->nrings; i++)
1032  {
1033  in_ring = point_in_ring(polygon->rings[i], &pt);
1034  if (in_ring == 1) /* inside a hole => outside the polygon */
1035  {
1036  POSTGIS_DEBUGF(3, "point_in_polygon: within hole %d.", i);
1037  result = -1;
1038  break;
1039  }
1040  if (in_ring == 0) /* on the edge of a hole */
1041  {
1042  POSTGIS_DEBUGF(3, "point_in_polygon: on edge of hole %d.", i);
1043  return 0;
1044  }
1045  }
1046  if ( result != -1)
1047  {
1048  return result;
1049  }
1050  }
1051  return result;
1052 }
static int point_in_ring(POINTARRAY *pts, const POINT2D *point)
uint32_t ngeoms
Definition: liblwgeom.h:496
POINTARRAY * point
Definition: liblwgeom.h:413
uint32_t nrings
Definition: liblwgeom.h:457
unsigned int uint32_t
Definition: uthash.h:78
LWPOLY ** geoms
Definition: liblwgeom.h:498
POINTARRAY ** rings
Definition: liblwgeom.h:459
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: