PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ point_in_multipolygon()

int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT pont 
)

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

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