PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwcompound_contains_point()

int lwcompound_contains_point ( const LWCOMPOUND comp,
const POINT2D pt 
)

Definition at line 195 of file lwcompound.c.

196{
197 int intersections = 0;
198
200 return LW_OUTSIDE;
201
202 for (uint32_t j = 0; j < comp->ngeoms; j++)
203 {
204 int on_boundary = LW_FALSE;
205 const LWGEOM *sub = comp->geoms[j];
206 if (sub->type == LINETYPE)
207 {
208 LWLINE *lwline = lwgeom_as_lwline(sub);
209 intersections += ptarray_raycast_intersections(lwline->points, pt, &on_boundary);
210 }
211 else if (sub->type == CIRCSTRINGTYPE)
212 {
214 intersections += ptarrayarc_raycast_intersections(lwcirc->points, pt, &on_boundary);
215 }
216 else
217 {
218 lwerror("%s: unsupported type %s", __func__, lwtype_name(sub->type));
219 }
220 if (on_boundary)
221 return LW_BOUNDARY;
222 }
223
224 /*
225 * Odd number of intersections means inside.
226 * Even means outside.
227 */
228 return (intersections % 2) ? LW_INSIDE : LW_OUTSIDE;
229}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define LW_FALSE
Definition liblwgeom.h:94
#define LINETYPE
Definition liblwgeom.h:103
LWGEOM * lwcompound_as_lwgeom(const LWCOMPOUND *obj)
Definition lwgeom.c:352
LWCIRCSTRING * lwgeom_as_lwcircstring(const LWGEOM *lwgeom)
Definition lwgeom.c:216
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition lwgeom.c:207
#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:827
int ptarrayarc_raycast_intersections(const POINTARRAY *pa, const POINT2D *p, int *on_boundary)
Definition ptarray.c:944
#define LW_OUTSIDE
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
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:199
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 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: