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

◆ point_in_multipolygon_rtree()

int point_in_multipolygon_rtree ( RTREE_NODE **  root,
int  polyCount,
int *  ringCounts,
LWPOINT point 
)

Definition at line 931 of file lwgeom_functions_analytic.c.

932{
933 int i, p, r, in_ring;
934 POINT2D pt;
935 int result = -1;
936
937 POSTGIS_DEBUGF(2, "point_in_multipolygon_rtree called for %p %d %p.", root, polyCount, point);
938
939 /* empty is not within anything */
940 if (lwpoint_is_empty(point)) return -1;
941
942 getPoint2d_p(point->point, 0, &pt);
943 /* assume bbox short-circuit has already been attempted */
944
945 i = 0; /* the current index into the root array */
946
947 /* is the point inside any of the sub-polygons? */
948 for ( p = 0; p < polyCount; p++ )
949 {
950 /* Skip empty polygons */
951 if( ringCounts[p] == 0 ) continue;
952
953 in_ring = point_in_ring_rtree(root[i], &pt);
954 POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: exterior ring (%d), point_in_ring returned %d", p, in_ring);
955 if ( in_ring == -1 ) /* outside the exterior ring */
956 {
957 POSTGIS_DEBUG(3, "point_in_multipolygon_rtree: outside exterior ring.");
958 }
959 else if ( in_ring == 0 ) /* on the boundary */
960 {
961 POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of exterior ring %d", p);
962 return 0;
963 } else {
964 result = in_ring;
965
966 for(r=1; r<ringCounts[p]; r++)
967 {
968 in_ring = point_in_ring_rtree(root[i+r], &pt);
969 POSTGIS_DEBUGF(4, "point_in_multipolygon_rtree: interior ring (%d), point_in_ring returned %d", r, in_ring);
970 if (in_ring == 1) /* inside a hole => outside the polygon */
971 {
972 POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: within hole %d of exterior ring %d", r, p);
973 result = -1;
974 break;
975 }
976 if (in_ring == 0) /* on the edge of a hole */
977 {
978 POSTGIS_DEBUGF(3, "point_in_multipolygon_rtree: on edge of hole %d of exterior ring %d", r, p);
979 return 0;
980 }
981 }
982 /* if we have a positive result, we can short-circuit and return it */
983 if ( result != -1)
984 {
985 return result;
986 }
987 }
988 /* increment the index by the total number of rings in the sub-poly */
989 /* we do this here in case we short-cutted out of the poly before looking at all the rings */
990 i += ringCounts[p];
991 }
992
993 return result; /* -1 = outside, 0 = boundary, 1 = inside */
994
995}
char * r
Definition cu_in_wkt.c:24
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition lwgeom_api.c:349
int lwpoint_is_empty(const LWPOINT *point)
static int point_in_ring_rtree(RTREE_NODE *root, const POINT2D *point)
POINTARRAY * point
Definition liblwgeom.h:457

References getPoint2d_p(), lwpoint_is_empty(), LWPOINT::point, point_in_ring_rtree(), and r.

Referenced by pip_short_circuit().

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