PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lwcompound_contains_point()

int lwcompound_contains_point ( const LWCOMPOUND comp,
const POINT2D pt 
)

Definition at line 188 of file lwcompound.c.

189 {
190  uint32_t i;
191  LWLINE *lwline;
192  LWCIRCSTRING *lwcirc;
193  int wn = 0;
194  int winding_number = 0;
195  int result;
196 
197  for ( i = 0; i < comp->ngeoms; i++ )
198  {
199  LWGEOM *lwgeom = comp->geoms[i];
200  if ( lwgeom->type == LINETYPE )
201  {
202  lwline = lwgeom_as_lwline(lwgeom);
203  if ( comp->ngeoms == 1 )
204  {
205  return ptarray_contains_point(lwline->points, pt);
206  }
207  else
208  {
209  /* Don't check closure while doing p-i-p test */
210  result = ptarray_contains_point_partial(lwline->points, pt, LW_FALSE, &winding_number);
211  }
212  }
213  else
214  {
215  lwcirc = lwgeom_as_lwcircstring(lwgeom);
216  if ( ! lwcirc ) {
217  lwerror("Unexpected component of type %s in compound curve", lwtype_name(lwgeom->type));
218  return 0;
219  }
220  if ( comp->ngeoms == 1 )
221  {
222  return ptarrayarc_contains_point(lwcirc->points, pt);
223  }
224  else
225  {
226  /* Don't check closure while doing p-i-p test */
227  result = ptarrayarc_contains_point_partial(lwcirc->points, pt, LW_FALSE, &winding_number);
228  }
229  }
230 
231  /* Propagate boundary condition */
232  if ( result == LW_BOUNDARY )
233  return LW_BOUNDARY;
234 
235  wn += winding_number;
236  }
237 
238  /* Outside */
239  if (wn == 0)
240  return LW_OUTSIDE;
241 
242  /* Inside */
243  return LW_INSIDE;
244 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:179
#define LW_FALSE
Definition: liblwgeom.h:94
#define LINETYPE
Definition: liblwgeom.h:103
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
Definition: lwgeom.c:188
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
Definition: ptarray.c:763
#define LW_INSIDE
Constants for point-in-polygon return values.
#define LW_BOUNDARY
int ptarrayarc_contains_point(const POINTARRAY *pa, const POINT2D *pt)
For POINTARRAYs representing CIRCULARSTRINGS.
Definition: ptarray.c:856
int ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt)
Return LW_INSIDE if the point is inside the POINTARRAY, LW_OUTSIDE if it is outside,...
Definition: ptarray.c:751
int ptarrayarc_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
Definition: ptarray.c:862
#define LW_OUTSIDE
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
POINTARRAY * points
Definition: liblwgeom.h:507
uint32_t ngeoms
Definition: liblwgeom.h:594
LWGEOM ** geoms
Definition: liblwgeom.h:589
uint8_t type
Definition: liblwgeom.h:462
POINTARRAY * points
Definition: liblwgeom.h:483

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().

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