PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lwcompound_contains_point ( const LWCOMPOUND comp,
const POINT2D pt 
)

Definition at line 132 of file lwcompound.c.

References LWCOMPOUND::geoms, LINETYPE, LW_BOUNDARY, LW_FALSE, LW_INSIDE, LW_OUTSIDE, lwerror(), lwgeom_as_lwcircstring(), lwgeom_as_lwline(), lwtype_name(), LWCOMPOUND::ngeoms, LWLINE::points, LWCIRCSTRING::points, ptarray_contains_point(), ptarray_contains_point_partial(), ptarrayarc_contains_point(), ptarrayarc_contains_point_partial(), result, and LWGEOM::type.

Referenced by lwgeom_contains_point().

133 {
134  int i;
135  LWLINE *lwline;
136  LWCIRCSTRING *lwcirc;
137  int wn = 0;
138  int winding_number = 0;
139  int result;
140 
141  for ( i = 0; i < comp->ngeoms; i++ )
142  {
143  LWGEOM *lwgeom = comp->geoms[i];
144  if ( lwgeom->type == LINETYPE )
145  {
146  lwline = lwgeom_as_lwline(lwgeom);
147  if ( comp->ngeoms == 1 )
148  {
149  return ptarray_contains_point(lwline->points, pt);
150  }
151  else
152  {
153  /* Don't check closure while doing p-i-p test */
154  result = ptarray_contains_point_partial(lwline->points, pt, LW_FALSE, &winding_number);
155  }
156  }
157  else
158  {
159  lwcirc = lwgeom_as_lwcircstring(lwgeom);
160  if ( ! lwcirc ) {
161  lwerror("Unexpected component of type %s in compound curve", lwtype_name(lwgeom->type));
162  return 0;
163  }
164  if ( comp->ngeoms == 1 )
165  {
166  return ptarrayarc_contains_point(lwcirc->points, pt);
167  }
168  else
169  {
170  /* Don't check closure while doing p-i-p test */
171  result = ptarrayarc_contains_point_partial(lwcirc->points, pt, LW_FALSE, &winding_number);
172  }
173  }
174 
175  /* Propogate boundary condition */
176  if ( result == LW_BOUNDARY )
177  return LW_BOUNDARY;
178 
179  wn += winding_number;
180  }
181 
182  /* Outside */
183  if (wn == 0)
184  return LW_OUTSIDE;
185 
186  /* Inside */
187  return LW_INSIDE;
188 }
#define LINETYPE
Definition: liblwgeom.h:61
int ptarrayarc_contains_point(const POINTARRAY *pa, const POINT2D *pt)
For POINTARRAYs representing CIRCULARSTRINGS.
Definition: ptarray.c:796
LWGEOM ** geoms
Definition: liblwgeom.h:478
char ** result
Definition: liblwgeom.h:218
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
#define LW_FALSE
Definition: liblwgeom.h:52
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
Definition: ptarray.c:703
#define LW_INSIDE
Constants for point-in-polygon return values.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:89
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
Definition: lwgeom.c:98
#define LW_BOUNDARY
int ngeoms
Definition: liblwgeom.h:476
uint8_t type
Definition: liblwgeom.h:352
int ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt)
Return 1 if the point is inside the POINTARRAY, -1 if it is outside, and 0 if it is on the boundary...
Definition: ptarray.c:697
POINTARRAY * points
Definition: liblwgeom.h:400
#define LW_OUTSIDE
int ptarrayarc_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
Definition: ptarray.c:802
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: