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

◆ point_in_multipolygon()

int point_in_multipolygon ( LWMPOLY mpolygon,
LWPOINT point 
)

Definition at line 1046 of file lwgeom_functions_analytic.c.

1047{
1048 uint32_t i, j;
1049 int result, in_ring;
1050 POINT2D pt;
1051
1052 POSTGIS_DEBUG(2, "point_in_polygon called.");
1053
1054 /* empty is not within anything */
1055 if (lwpoint_is_empty(point)) return -1;
1056
1057 getPoint2d_p(point->point, 0, &pt);
1058 /* assume bbox short-circuit has already been attempted */
1059
1060 result = -1;
1061
1062 for (j = 0; j < mpolygon->ngeoms; j++ )
1063 {
1064
1065 LWPOLY *polygon = mpolygon->geoms[j];
1066
1067 /* everything is outside of an empty polygon */
1068 if ( polygon->nrings == 0 ) continue;
1069
1070 in_ring = point_in_ring(polygon->rings[0], &pt);
1071 if ( in_ring == -1) /* outside the exterior ring */
1072 {
1073 POSTGIS_DEBUG(3, "point_in_polygon: outside exterior ring.");
1074 continue;
1075 }
1076 if ( in_ring == 0 )
1077 {
1078 return 0;
1079 }
1080
1081 result = in_ring;
1082
1083 for (i=1; i<polygon->nrings; i++)
1084 {
1085 in_ring = point_in_ring(polygon->rings[i], &pt);
1086 if (in_ring == 1) /* inside a hole => outside the polygon */
1087 {
1088 POSTGIS_DEBUGF(3, "point_in_polygon: within hole %d.", i);
1089 result = -1;
1090 break;
1091 }
1092 if (in_ring == 0) /* on the edge of a hole */
1093 {
1094 POSTGIS_DEBUGF(3, "point_in_polygon: on edge of hole %d.", i);
1095 return 0;
1096 }
1097 }
1098 if ( result != -1)
1099 {
1100 return result;
1101 }
1102 }
1103 return result;
1104}
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(POINTARRAY *pts, const POINT2D *point)
uint32_t ngeoms
Definition liblwgeom.h:552
LWPOLY ** geoms
Definition liblwgeom.h:547
POINTARRAY * point
Definition liblwgeom.h:457
POINTARRAY ** rings
Definition liblwgeom.h:505
uint32_t nrings
Definition liblwgeom.h:510

References LWMPOLY::geoms, getPoint2d_p(), lwpoint_is_empty(), LWMPOLY::ngeoms, LWPOLY::nrings, LWPOINT::point, point_in_ring(), and LWPOLY::rings.

Referenced by pip_short_circuit().

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