PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lw_dist3d_pt_poly()

int lw_dist3d_pt_poly ( const POINT3DZ p,
const LWPOLY poly,
PLANE3D plane,
POINT3DZ projp,
DISTPTS3D dl 
)

Checking if the point projected on the plane of the polygon actually is inside that polygon.

If so the mindistance is between that projected point and our original point. If not we check from original point to the boundary. If the projected point is inside a hole of the polygon we check the distance to the boundary of that hole.

Definition at line 1291 of file measures3d.c.

1292 {
1293  uint32_t i;
1294 
1295  if (pt_in_ring_3d(projp, poly->rings[0], plane))
1296  {
1297  for (i = 1; i < poly->nrings; i++)
1298  {
1299  /* Inside a hole. Distance = pt -> ring */
1300  if (pt_in_ring_3d(projp, poly->rings[i], plane))
1301  return lw_dist3d_pt_ptarray(p, poly->rings[i], dl);
1302  }
1303 
1304  /* if the projected point is inside the polygon the shortest distance is between that point and the
1305  * input point */
1306  return lw_dist3d_pt_pt(p, projp, dl);
1307  }
1308  else
1309  /* if the projected point is outside the polygon we search for the closest distance against the boundary
1310  * instead */
1311  return lw_dist3d_pt_ptarray(p, poly->rings[0], dl);
1312 
1313  return LW_TRUE;
1314 }
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
int pt_in_ring_3d(const POINT3DZ *p, const POINTARRAY *ring, PLANE3D *plane)
pt_in_ring_3d(): crossing number test for a point in a polygon input: p = a point,...
Definition: measures3d.c:1573
int lw_dist3d_pt_pt(const POINT3DZ *thep1, const POINT3DZ *thep2, DISTPTS3D *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...
Definition: measures3d.c:1082
int lw_dist3d_pt_ptarray(const POINT3DZ *p, const POINTARRAY *pa, DISTPTS3D *dl)
search all the segments of pointarray to see which one is closest to p Returns distance between point...
Definition: measures3d.c:996
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint32_t nrings
Definition: liblwgeom.h:524

References lw_dist3d_pt_pt(), lw_dist3d_pt_ptarray(), LW_TRUE, LWPOLY::nrings, pt_in_ring_3d(), and LWPOLY::rings.

Referenced by lw_dist3d_point_poly(), and lw_dist3d_ptarray_poly().

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