PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lw_dist2d_pt_ptarray()

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 1130 of file measures.c.

1131 {
1132  const POINT2D *start, *end;
1133  int twist = dl->twisted;
1134 
1135  start = getPoint2d_cp(pa, 0);
1136 
1137  if (!lw_dist2d_pt_pt(p, start, dl))
1138  return LW_FALSE;
1139 
1140  for (uint32_t t = 1; t < pa->npoints; t++)
1141  {
1142  dl->twisted = twist;
1143  end = getPoint2d_cp(pa, t);
1144  if (!lw_dist2d_pt_seg(p, start, end, dl))
1145  return LW_FALSE;
1146 
1147  if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
1148  return LW_TRUE; /*just a check if the answer is already given*/
1149  start = end;
1150  }
1151 
1152  return LW_TRUE;
1153 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwinline.h:101
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 occasion to lw_dist2d_pt_pt Before i...
Definition: measures.c:2306
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...
Definition: measures.c:2366
#define DIST_MIN
Definition: measures.h:44
int twisted
Definition: measures.h:55
double tolerance
Definition: measures.h:56
int mode
Definition: measures.h:54
double distance
Definition: measures.h:51
uint32_t npoints
Definition: liblwgeom.h:427

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

Referenced by lw_dist2d_point_line(), lw_dist2d_point_poly(), and lw_dist2d_point_tri().

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