PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 other depending on dl->mode (max or min)

Definition at line 2276 of file measures.c.

References DISTPTS::distance, LW_TRUE, DISTPTS::mode, DISTPTS::p1, DISTPTS::p2, DISTPTS::twisted, POINT2D::x, and POINT2D::y.

Referenced by lw_dist2d_arc_arc(), lw_dist2d_point_point(), lw_dist2d_pre_seg_seg(), lw_dist2d_pt_arc(), lw_dist2d_pt_ptarray(), lw_dist2d_pt_ptarrayarc(), lw_dist2d_pt_seg(), lw_dist2d_ptarray_ptarray(), and lw_dist2d_seg_arc().

2277 {
2278  double hside = thep2->x - thep1->x;
2279  double vside = thep2->y - thep1->y;
2280  double dist = sqrt ( hside*hside + vside*vside );
2281 
2282  if (((dl->distance - dist)*(dl->mode))>0) /*multiplication with mode to handle mindistance (mode=1) and maxdistance (mode = (-1)*/
2283  {
2284  dl->distance = dist;
2285 
2286  if (dl->twisted>0) /*To get the points in right order. twisted is updated between 1 and (-1) every time the order is changed earlier in the chain*/
2287  {
2288  dl->p1 = *thep1;
2289  dl->p2 = *thep2;
2290  }
2291  else
2292  {
2293  dl->p1 = *thep2;
2294  dl->p2 = *thep1;
2295  }
2296  }
2297  return LW_TRUE;
2298 }
int mode
Definition: measures.h:51
POINT2D p1
Definition: measures.h:49
double x
Definition: liblwgeom.h:327
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
POINT2D p2
Definition: measures.h:50
double y
Definition: liblwgeom.h:327
int twisted
Definition: measures.h:52
double distance
Definition: measures.h:48

Here is the caller graph for this function: