PostGIS  2.5.0dev-r@@SVN_REVISION@@
int lw_dist2d_pt_ptarray ( const POINT2D p,
POINTARRAY pa,
DISTPTS dl 
)

search all the segments of pointarray to see which one is closest to p1 Returns minimum distance between point and pointarray

Definition at line 1049 of file measures.c.

References DIST_MIN, DISTPTS::distance, getPoint2d_cp(), lw_dist2d_pt_pt(), lw_dist2d_pt_seg(), LW_FALSE, LW_TRUE, LWDEBUG, DISTPTS::mode, POINTARRAY::npoints, DISTPTS::tolerance, and DISTPTS::twisted.

Referenced by lw_dist2d_point_line(), and lw_dist2d_point_poly().

1050 {
1051  uint32_t t;
1052  const POINT2D *start, *end;
1053  int twist = dl->twisted;
1054 
1055  LWDEBUG(2, "lw_dist2d_pt_ptarray is called");
1056 
1057  start = getPoint2d_cp(pa, 0);
1058 
1059  if ( !lw_dist2d_pt_pt(p, start, dl) ) return LW_FALSE;
1060 
1061  for (t=1; t<pa->npoints; t++)
1062  {
1063  dl->twisted=twist;
1064  end = getPoint2d_cp(pa, t);
1065  if (!lw_dist2d_pt_seg(p, start, end, dl)) return LW_FALSE;
1066 
1067  if (dl->distance<=dl->tolerance && dl->mode == DIST_MIN) return LW_TRUE; /*just a check if the answer is already given*/
1068  start = end;
1069  }
1070 
1071  return LW_TRUE;
1072 }
int mode
Definition: measures.h:51
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
unsigned int uint32_t
Definition: uthash.h:78
double tolerance
Definition: measures.h:53
#define DIST_MIN
Definition: measures.h:41
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
int lw_dist2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B, DISTPTS *dl)
lw_dist2d_comp from p to line A->B This one is now sending every occation to lw_dist2d_pt_pt Before i...
Definition: measures.c:2200
int twisted
Definition: measures.h:52
double distance
Definition: measures.h:48
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incomming points and stores the points closest to each other or most far away from each othe...
Definition: measures.c:2276
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:364
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: