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

◆ itree_pip_contains()

bool itree_pip_contains ( const IntervalTree itree,
const LWGEOM lwpoints 
)

Definition at line 140 of file lwgeom_itree.c.

141{
142 if (lwgeom_get_type(lwpoints) == POINTTYPE)
143 {
145 }
146 else if (lwgeom_get_type(lwpoints) == MULTIPOINTTYPE)
147 {
148 bool found_completely_inside = false;
149 LWMPOINT *mpoint = lwgeom_as_lwmpoint(lwpoints);
150 for (uint32_t i = 0; i < mpoint->ngeoms; i++)
151 {
152 IntervalTreeResult pip_result;
153 const LWPOINT* pt = mpoint->geoms[i];
154
155 if (lwpoint_is_empty(pt))
156 continue;
157 /*
158 * We need to find at least one point that's completely inside the
159 * polygons (pip_result == 1). As long as we have one point that's
160 * completely inside, we can have as many as we want on the boundary
161 * itself. (pip_result == 0)
162 */
163 pip_result = itree_point_in_multipolygon(itree, pt);
164
165 if (pip_result == ITREE_INSIDE)
166 found_completely_inside = true;
167
168 if (pip_result == ITREE_OUTSIDE)
169 return false;
170 }
171 return found_completely_inside;
172 }
173 else
174 {
175 elog(ERROR, "%s got a non-point input", __func__);
176 return false;
177 }
178}
IntervalTreeResult itree_point_in_multipolygon(const IntervalTree *itree, const LWPOINT *point)
IntervalTreeResult
@ ITREE_INSIDE
@ ITREE_OUTSIDE
#define MULTIPOINTTYPE
Definition liblwgeom.h:105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
Definition lwgeom.c:270
int lwpoint_is_empty(const LWPOINT *point)
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition lwinline.h:141
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition lwinline.h:127
uint32_t ngeoms
Definition liblwgeom.h:538
LWPOINT ** geoms
Definition liblwgeom.h:533

References LWMPOINT::geoms, ITREE_INSIDE, ITREE_OUTSIDE, itree_point_in_multipolygon(), lwgeom_as_lwmpoint(), lwgeom_as_lwpoint(), lwgeom_get_type(), lwpoint_is_empty(), MULTIPOINTTYPE, LWMPOINT::ngeoms, and POINTTYPE.

Referenced by contains(), and within().

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