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

◆ lw_dist3d_pt_ptarray()

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 and pointarray

Definition at line 996 of file measures3d.c.

997{
998 uint32_t t;
999 POINT3DZ start, end;
1000 int twist = dl->twisted;
1001 if (!pa)
1002 return LW_FALSE;
1003
1004 getPoint3dz_p(pa, 0, &start);
1005
1006 for (t = 1; t < pa->npoints; t++)
1007 {
1008 dl->twisted = twist;
1009 getPoint3dz_p(pa, t, &end);
1010 if (!lw_dist3d_pt_seg(p, &start, &end, dl))
1011 return LW_FALSE;
1012
1013 if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
1014 return LW_TRUE; /*just a check if the answer is already given*/
1015 start = end;
1016 }
1017
1018 return LW_TRUE;
1019}
#define LW_FALSE
Definition liblwgeom.h:94
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition lwgeom_api.c:215
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
int lw_dist3d_pt_seg(const POINT3DZ *p, const POINT3DZ *A, const POINT3DZ *B, DISTPTS3D *dl)
If searching for min distance, this one finds the closest point on segment A-B from p.
#define DIST_MIN
Definition measures.h:44
int twisted
Definition measures3d.h:45
double distance
Definition measures3d.h:40
double tolerance
Definition measures3d.h:47
uint32_t npoints
Definition liblwgeom.h:427

References DIST_MIN, DISTPTS3D::distance, getPoint3dz_p(), lw_dist3d_pt_seg(), LW_FALSE, LW_TRUE, DISTPTS3D::mode, POINTARRAY::npoints, DISTPTS3D::tolerance, and DISTPTS3D::twisted.

Referenced by lw_dist3d_point_line(), lw_dist3d_point_poly(), lw_dist3d_point_tri(), lw_dist3d_pt_poly(), and lw_dist3d_pt_tri().

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