PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ point_in_multipolygon()

int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT pont 
)

Definition at line 1000 of file lwgeom_functions_analytic.c.

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

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

Referenced by pip_short_circuit().

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