PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ point_in_multipolygon()

int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT point 
)

Definition at line 1026 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().

1027 {
1028  int i, j, result, in_ring;
1029  POINT2D pt;
1030 
1031  POSTGIS_DEBUG(2, "point_in_polygon called.");
1032 
1033  getPoint2d_p(point->point, 0, &pt);
1034  /* assume bbox short-circuit has already been attempted */
1035 
1036  result = -1;
1037 
1038  for (j = 0; j < mpolygon->ngeoms; j++ )
1039  {
1040 
1041  LWPOLY *polygon = mpolygon->geoms[j];
1042 
1043  /* everything is outside of an empty polygon */
1044  if ( polygon->nrings == 0 ) continue;
1045 
1046  in_ring = point_in_ring(polygon->rings[0], &pt);
1047  if ( in_ring == -1) /* outside the exterior ring */
1048  {
1049  POSTGIS_DEBUG(3, "point_in_polygon: outside exterior ring.");
1050  continue;
1051  }
1052  if ( in_ring == 0 )
1053  {
1054  return 0;
1055  }
1056 
1057  result = in_ring;
1058 
1059  for (i=1; i<polygon->nrings; i++)
1060  {
1061  in_ring = point_in_ring(polygon->rings[i], &pt);
1062  if (in_ring == 1) /* inside a hole => outside the polygon */
1063  {
1064  POSTGIS_DEBUGF(3, "point_in_polygon: within hole %d.", i);
1065  result = -1;
1066  break;
1067  }
1068  if (in_ring == 0) /* on the edge of a hole */
1069  {
1070  POSTGIS_DEBUGF(3, "point_in_polygon: on edge of hole %d.", i);
1071  return 0;
1072  }
1073  }
1074  if ( result != -1)
1075  {
1076  return result;
1077  }
1078  }
1079  return result;
1080 }
static int point_in_ring(POINTARRAY *pts, const POINT2D *point)
POINTARRAY * point
Definition: liblwgeom.h:411
LWPOLY ** geoms
Definition: liblwgeom.h:496
POINTARRAY ** rings
Definition: liblwgeom.h:457
int nrings
Definition: liblwgeom.h:455
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:347
int ngeoms
Definition: liblwgeom.h:494
Here is the call graph for this function:
Here is the caller graph for this function: