PostGIS  2.2.7dev-r@@SVN_REVISION@@

◆ lw_dist3d_pt_poly()

int lw_dist3d_pt_poly ( POINT3DZ p,
LWPOLY poly,
PLANE3D plane,
POINT3DZ projp,

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 bounadary. If the projected point is inside a hole of the polygon we check the distance to the boudary of that hole.

Definition at line 996 of file measures3d.c.

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

Referenced by lw_dist3d_point_poly(), and lw_dist3d_ptarray_poly().

997 {
998  int i;
1000  LWDEBUG(2, "lw_dist3d_point_poly called");
1003  if(pt_in_ring_3d(projp, poly->rings[0], plane))
1004  {
1005  for (i=1; i<poly->nrings; i++)
1006  {
1007  /* Inside a hole. Distance = pt -> ring */
1008  if ( pt_in_ring_3d(projp, poly->rings[i], plane ))
1009  {
1010  LWDEBUG(3, " inside an hole");
1011  return lw_dist3d_pt_ptarray(p, poly->rings[i], dl);
1012  }
1013  }
1015  return lw_dist3d_pt_pt(p,projp,dl);/* If the projected point is inside the polygon the shortest distance is between that point and the inputed point*/
1016  }
1017  else
1018  {
1019  return lw_dist3d_pt_ptarray(p, poly->rings[0], dl); /*If the projected point is outside the polygon we search for the closest distance against the boundarry instead*/
1020  }
1022  return LW_TRUE;
1024 }
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
int lw_dist3d_pt_pt(POINT3DZ *thep1, POINT3DZ *thep2, DISTPTS3D *dl)
Compares incomming points and stores the points closest to each other or most far away from each othe...
Definition: measures3d.c:788
Definition: liblwgeom.h:441
int nrings
Definition: liblwgeom.h:439
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, pa = vertex points of a ring V[n+1] with V[n]=V[0] plane=the plane that the vertex points are lying on returns: 0 = outside, 1 = inside
Definition: measures3d.c:1217
int lw_dist3d_pt_ptarray(POINT3DZ *p, 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:693
Here is the call graph for this function:
Here is the caller graph for this function: