PostGIS  2.1.10dev-r@@SVN_REVISION@@
 int lw_dist2d_pt_arc ( const POINT2D * P, const POINT2D * A1, const POINT2D * A2, const POINT2D * A3, DISTPTS * dl )

Definition at line 1395 of file measures.c.

1396 {
1398  POINT2D C; /* center of circle defined by arc A */
1399  POINT2D X; /* point circle(A) where line from C to P crosses */
1400
1401  if ( dl->mode < 0 )
1402  lwerror("lw_dist2d_pt_arc does not support maxdistance mode");
1403
1404  /* What if the arc is a point? */
1405  if ( lw_arc_is_pt(A1, A2, A3) )
1406  return lw_dist2d_pt_pt(P, A1, dl);
1407
1408  /* Calculate centers and radii of circles. */
1409  radius_A = lw_arc_center(A1, A2, A3, &C);
1410
1411  /* This "arc" is actually a line (A2 is colinear with A1,A3) */
1412  if ( radius_A < 0.0 )
1413  return lw_dist2d_pt_seg(P, A1, A3, dl);
1414
1415  /* Distance from point to center */
1416  d = distance2d_pt_pt(&C, P);
1417
1418  /* X is the point on the circle where the line from P to C crosses */
1419  X.x = C.x + (P->x - C.x) * radius_A / d;
1420  X.y = C.y + (P->y - C.y) * radius_A / d;
1421
1422  /* Is crossing point inside the arc? Or arc is actually circle? */
1423  if ( p2d_same(A1, A3) || lw_pt_in_arc(&X, A1, A2, A3) )
1424  {
1425  lw_dist2d_pt_pt(P, &X, dl);
1426  }
1427  else
1428  {
1429  /* Distance is the minimum of the distances to the arc end points */
1430  lw_dist2d_pt_pt(A1, P, dl);
1431  lw_dist2d_pt_pt(A3, P, dl);
1432  }
1433  return LW_TRUE;
1434 }
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
Definition: lwalgorithm.c:228
int lw_arc_is_pt(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if arc A is actually a point (all vertices are the same) .
Definition: lwalgorithm.c:106
int mode
Definition: measures.h:26
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
double x
Definition: liblwgeom.h:284
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Definition: lwalgorithm.c:47
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
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:2011
double y
Definition: liblwgeom.h:284
int lw_pt_in_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if P is on the same side of the plane partition defined by A1/A3 as A2 is...
Definition: lwalgorithm.c:86
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
Definition: measures.c:2123
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:2087

Here is the call graph for this function:

Here is the caller graph for this function: