PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ point_in_multipolygon()

int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT point 
)

Definition at line 1040 of file lwgeom_functions_analytic.c.

1041 {
1042  uint32_t i, j;
1043  int result, in_ring;
1044  POINT2D pt;
1045 
1046  POSTGIS_DEBUG(2, "point_in_polygon called.");
1047 
1048  getPoint2d_p(point->point, 0, &pt);
1049  /* assume bbox short-circuit has already been attempted */
1050 
1051  result = -1;
1052 
1053  for (j = 0; j < mpolygon->ngeoms; j++ )
1054  {
1055 
1056  LWPOLY *polygon = mpolygon->geoms[j];
1057 
1058  /* everything is outside of an empty polygon */
1059  if ( polygon->nrings == 0 ) continue;
1060 
1061  in_ring = point_in_ring(polygon->rings[0], &pt);
1062  if ( in_ring == -1) /* outside the exterior ring */
1063  {
1064  POSTGIS_DEBUG(3, "point_in_polygon: outside exterior ring.");
1065  continue;
1066  }
1067  if ( in_ring == 0 )
1068  {
1069  return 0;
1070  }
1071 
1072  result = in_ring;
1073 
1074  for (i=1; i<polygon->nrings; i++)
1075  {
1076  in_ring = point_in_ring(polygon->rings[i], &pt);
1077  if (in_ring == 1) /* inside a hole => outside the polygon */
1078  {
1079  POSTGIS_DEBUGF(3, "point_in_polygon: within hole %d.", i);
1080  result = -1;
1081  break;
1082  }
1083  if (in_ring == 0) /* on the edge of a hole */
1084  {
1085  POSTGIS_DEBUGF(3, "point_in_polygon: on edge of hole %d.", i);
1086  return 0;
1087  }
1088  }
1089  if ( result != -1)
1090  {
1091  return result;
1092  }
1093  }
1094  return result;
1095 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:342
static int point_in_ring(POINTARRAY *pts, const POINT2D *point)
uint32_t ngeoms
Definition: liblwgeom.h:566
LWPOLY ** geoms
Definition: liblwgeom.h:561
POINTARRAY * point
Definition: liblwgeom.h:471
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint32_t nrings
Definition: liblwgeom.h:524

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

Referenced by pip_short_circuit().

Here is the call graph for this function:
Here is the caller graph for this function: