PostGIS  2.5.0dev-r@@SVN_REVISION@@
int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT point 
)

Definition at line 955 of file lwgeom_functions_analytic.c.

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

Referenced by pip_short_circuit().

956 {
957  uint32_t i, j;
958  int result, in_ring;
959  POINT2D pt;
960 
961  POSTGIS_DEBUG(2, "point_in_polygon called.");
962 
963  getPoint2d_p(point->point, 0, &pt);
964  /* assume bbox short-circuit has already been attempted */
965 
966  result = -1;
967 
968  for (j = 0; j < mpolygon->ngeoms; j++ )
969  {
970 
971  LWPOLY *polygon = mpolygon->geoms[j];
972 
973  /* everything is outside of an empty polygon */
974  if ( polygon->nrings == 0 ) continue;
975 
976  in_ring = point_in_ring(polygon->rings[0], &pt);
977  if ( in_ring == -1) /* outside the exterior ring */
978  {
979  POSTGIS_DEBUG(3, "point_in_polygon: outside exterior ring.");
980  continue;
981  }
982  if ( in_ring == 0 )
983  {
984  return 0;
985  }
986 
987  result = in_ring;
988 
989  for (i=1; i<polygon->nrings; i++)
990  {
991  in_ring = point_in_ring(polygon->rings[i], &pt);
992  if (in_ring == 1) /* inside a hole => outside the polygon */
993  {
994  POSTGIS_DEBUGF(3, "point_in_polygon: within hole %d.", i);
995  result = -1;
996  break;
997  }
998  if (in_ring == 0) /* on the edge of a hole */
999  {
1000  POSTGIS_DEBUGF(3, "point_in_polygon: on edge of hole %d.", i);
1001  return 0;
1002  }
1003  }
1004  if ( result != -1)
1005  {
1006  return result;
1007  }
1008  }
1009  return result;
1010 }
static int point_in_ring(POINTARRAY *pts, const POINT2D *point)
uint32_t ngeoms
Definition: liblwgeom.h:493
POINTARRAY * point
Definition: liblwgeom.h:410
uint32_t nrings
Definition: liblwgeom.h:454
unsigned int uint32_t
Definition: uthash.h:78
LWPOLY ** geoms
Definition: liblwgeom.h:495
POINTARRAY ** rings
Definition: liblwgeom.h:456
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: