PostGIS  2.3.7dev-r@@SVN_REVISION@@
int point_in_polygon ( LWPOLY polygon,
LWPOINT point 
)

Definition at line 974 of file lwgeom_functions_analytic.c.

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

Referenced by pip_short_circuit().

975 {
976  int i, result, in_ring;
977  POINT2D pt;
978 
979  POSTGIS_DEBUG(2, "point_in_polygon called.");
980 
981  getPoint2d_p(point->point, 0, &pt);
982  /* assume bbox short-circuit has already been attempted */
983 
984  /* everything is outside of an empty polygon */
985  if ( polygon->nrings == 0 ) return -1;
986 
987  in_ring = point_in_ring(polygon->rings[0], &pt);
988  if ( in_ring == -1) /* outside the exterior ring */
989  {
990  POSTGIS_DEBUG(3, "point_in_polygon: outside exterior ring.");
991  return -1;
992  }
993  result = in_ring;
994 
995  for (i=1; i<polygon->nrings; i++)
996  {
997  in_ring = point_in_ring(polygon->rings[i], &pt);
998  if (in_ring == 1) /* inside a hole => outside the polygon */
999  {
1000  POSTGIS_DEBUGF(3, "point_in_polygon: within hole %d.", i);
1001  return -1;
1002  }
1003  if (in_ring == 0) /* on the edge of a hole */
1004  {
1005  POSTGIS_DEBUGF(3, "point_in_polygon: on edge of hole %d.", i);
1006  return 0;
1007  }
1008  }
1009  return result; /* -1 = outside, 0 = boundary, 1 = inside */
1010 }
static int point_in_ring(POINTARRAY *pts, const POINT2D *point)
POINTARRAY * point
Definition: liblwgeom.h:410
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

Here is the call graph for this function:

Here is the caller graph for this function: