PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lw_dist3d_point_poly ( LWPOINT point,
LWPOLY poly,
DISTPTS3D dl 
)

Computes point to polygon distance For mindistance that means: 1)find the plane of the polygon 2)projecting the point to the plane of the polygon 3)finding if that projected point is inside the polygon, if so the distance is measured to that projected point 4) if not in polygon above, check the distance against the boundary of the polygon for max distance it is always point against boundary.

Definition at line 417 of file measures3d.c.

References define_plane(), DIST_MAX, getPoint3dz_p(), lw_dist3d_pt_poly(), lw_dist3d_pt_ptarray(), LW_FALSE, LWDEBUG, DISTPTS3D::mode, LWPOINT::point, project_point_on_plane(), and LWPOLY::rings.

Referenced by lw_dist3d_distribute_bruteforce().

418 {
419  POINT3DZ p, projp;/*projp is "point projected on plane"*/
420  PLANE3D plane;
421  LWDEBUG(2, "lw_dist3d_point_poly is called");
422  getPoint3dz_p(point->point, 0, &p);
423 
424  /*If we are lookig for max distance, longestline or dfullywithin*/
425  if (dl->mode == DIST_MAX)
426  {
427  LWDEBUG(3, "looking for maxdistance");
428  return lw_dist3d_pt_ptarray(&p, poly->rings[0], dl);
429  }
430 
431  /*Find the plane of the polygon, the "holes" have to be on the same plane. so we only care about the boudary*/
432  if(!define_plane(poly->rings[0], &plane))
433  return LW_FALSE;
434 
435  /*get our point projected on the plane of the polygon*/
436  project_point_on_plane(&p, &plane, &projp);
437 
438  return lw_dist3d_pt_poly(&p, poly,&plane, &projp, dl);
439 }
#define DIST_MAX
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
POINTARRAY * point
Definition: liblwgeom.h:367
double project_point_on_plane(POINT3DZ *p, PLANE3D *pl, POINT3DZ *p0)
Finds a point on a plane from where the original point is perpendicular to the plane.
Definition: measures3d.c:989
int lw_dist3d_pt_poly(POINT3DZ *p, LWPOLY *poly, PLANE3D *plane, POINT3DZ *projp, DISTPTS3D *dl)
Checking if the point projected on the plane of the polygon actually is inside that polygon...
Definition: measures3d.c:806
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:305
#define LW_FALSE
Definition: liblwgeom.h:52
POINTARRAY ** rings
Definition: liblwgeom.h:413
int mode
Definition: measures3d.h:29
int define_plane(POINTARRAY *pa, PLANE3D *pl)
Here we define the plane of a polygon (boundary pointarray of a polygon) the plane is stored as a pon...
Definition: measures3d.c:923
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:512

Here is the call graph for this function:

Here is the caller graph for this function: