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

Search all the arcs of pointarray to see which one is closest to p1 Returns minimum distance between point and arc pointarray.

Definition at line 1039 of file measures.c.

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

Referenced by lw_dist2d_point_circstring(), and test_lw_dist2d_pt_ptarrayarc().

1040 {
1041  int t;
1042  const POINT2D *A1;
1043  const POINT2D *A2;
1044  const POINT2D *A3;
1045  int twist = dl->twisted;
1046 
1047  LWDEBUG(2, "lw_dist2d_pt_ptarrayarc is called");
1048 
1049  if ( pa->npoints % 2 == 0 || pa->npoints < 3 )
1050  {
1051  lwerror("lw_dist2d_pt_ptarrayarc called with non-arc input");
1052  return LW_FALSE;
1053  }
1054 
1055  if (dl->mode == DIST_MAX)
1056  {
1057  lwerror("lw_dist2d_pt_ptarrayarc does not currently support DIST_MAX mode");
1058  return LW_FALSE;
1059  }
1060 
1061  A1 = getPoint2d_cp(pa, 0);
1062 
1063  if ( ! lw_dist2d_pt_pt(p, A1, dl) )
1064  return LW_FALSE;
1065 
1066  for ( t=1; t<pa->npoints; t += 2 )
1067  {
1068  dl->twisted = twist;
1069  A2 = getPoint2d_cp(pa, t);
1070  A3 = getPoint2d_cp(pa, t+1);
1071 
1072  if ( lw_dist2d_pt_arc(p, A1, A2, A3, dl) == LW_FALSE )
1073  return LW_FALSE;
1074 
1075  if ( dl->distance <= dl->tolerance && dl->mode == DIST_MIN )
1076  return LW_TRUE; /*just a check if the answer is already given*/
1077 
1078  A1 = A3;
1079  }
1080 
1081  return LW_TRUE;
1082 }
int npoints
Definition: liblwgeom.h:327
#define DIST_MAX
int mode
Definition: measures.h:26
#define DIST_MIN
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
double tolerance
Definition: measures.h:28
#define LW_FALSE
Definition: liblwgeom.h:52
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:458
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
Definition: measures.c:1395
int twisted
Definition: measures.h:27
double distance
Definition: measures.h:23
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: