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

◆ lw_dist3d_point_poly()

int lw_dist3d_point_poly ( const LWPOINT point,
const 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 778 of file measures3d.c.

779{
780 POINT3DZ p, projp; /*projp is "point projected on plane"*/
781 PLANE3D plane;
782 LWDEBUG(2, "lw_dist3d_point_poly is called");
783 getPoint3dz_p(point->point, 0, &p);
784
785 /* If we are looking for max distance, longestline or dfullywithin */
786 if (dl->mode == DIST_MAX)
787 return lw_dist3d_pt_ptarray(&p, poly->rings[0], dl);
788
789 /* Find the plane of the polygon, the "holes" have to be on the same plane. so we only care about the boundary */
790 if (!define_plane(poly->rings[0], &plane))
791 {
792 /* Polygon does not define a plane: Return distance point -> line */
793 return lw_dist3d_pt_ptarray(&p, poly->rings[0], dl);
794 }
795
796 /* Get our point projected on the plane of the polygon */
797 project_point_on_plane(&p, &plane, &projp);
798
799 return lw_dist3d_pt_poly(&p, poly, &plane, &projp, dl);
800}
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition lwgeom_api.c:215
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
static double project_point_on_plane(const 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:57
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
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.
int define_plane(const POINTARRAY *pa, PLANE3D *pl)
#define DIST_MAX
Definition measures.h:43
POINTARRAY * point
Definition liblwgeom.h:471
POINTARRAY ** rings
Definition liblwgeom.h:519

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

Referenced by lw_dist3d_distribute_bruteforce().

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