PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ lwcompound_contains_point()

int lwcompound_contains_point ( const LWCOMPOUND comp,
const POINT2D pt 
)

Definition at line 153 of file lwcompound.c.

154 {
155  int intersections = 0;
156 
158  return LW_OUTSIDE;
159 
160  for (uint32_t j = 0; j < comp->ngeoms; j++)
161  {
162  int on_boundary = LW_FALSE;
163  const LWGEOM *sub = comp->geoms[j];
164  if (sub->type == LINETYPE)
165  {
166  LWLINE *lwline = lwgeom_as_lwline(sub);
167  intersections += ptarray_raycast_intersections(lwline->points, pt, &on_boundary);
168  }
169  else if (sub->type == CIRCSTRINGTYPE)
170  {
171  LWCIRCSTRING *lwcirc = lwgeom_as_lwcircstring(sub);
172  intersections += ptarrayarc_raycast_intersections(lwcirc->points, pt, &on_boundary);
173  }
174  else
175  {
176  lwerror("%s: unsupported type %s", __func__, lwtype_name(sub->type));
177  }
178  if (on_boundary)
179  return LW_BOUNDARY;
180  }
181 
182  /*
183  * Odd number of intersections means inside.
184  * Even means outside.
185  */
186  return (intersections % 2) ? LW_INSIDE : LW_OUTSIDE;
187 }
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:162
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
Definition: lwgeom.c:307
#define LW_FALSE
Definition: liblwgeom.h:108
#define LINETYPE
Definition: liblwgeom.h:117
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:123
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:171
#define LW_INSIDE
Constants for point-in-polygon return values.
#define LW_BOUNDARY
int ptarray_raycast_intersections(const POINTARRAY *pa, const POINT2D *p, int *on_boundary)
Definition: ptarray.c:818
int ptarrayarc_raycast_intersections(const POINTARRAY *pa, const POINT2D *p, int *on_boundary)
Definition: ptarray.c:935
#define LW_OUTSIDE
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:203
POINTARRAY * points
Definition: liblwgeom.h:521
uint32_t ngeoms
Definition: liblwgeom.h:608
LWGEOM ** geoms
Definition: liblwgeom.h:603
uint8_t type
Definition: liblwgeom.h:476
POINTARRAY * points
Definition: liblwgeom.h:497

References CIRCSTRINGTYPE, LWCOMPOUND::geoms, LINETYPE, LW_BOUNDARY, LW_FALSE, LW_INSIDE, LW_OUTSIDE, lwcompound_as_lwgeom(), lwerror(), lwgeom_as_lwcircstring(), lwgeom_as_lwline(), lwgeom_is_empty(), lwtype_name(), LWCOMPOUND::ngeoms, LWLINE::points, LWCIRCSTRING::points, ptarray_raycast_intersections(), ptarrayarc_raycast_intersections(), and LWGEOM::type.

Referenced by lwgeom_contains_point().

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