PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lw_dist2d_ptarray_ptarrayarc ( const POINTARRAY pa,
const POINTARRAY pb,
DISTPTS dl 
)

Test each segment of pa against each arc of pb for distance.

Definition at line 1143 of file measures.c.

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

Referenced by lw_dist2d_line_circstring(), and test_lw_dist2d_ptarray_ptarrayarc().

1144 {
1145  int t, u;
1146  const POINT2D *A1;
1147  const POINT2D *A2;
1148  const POINT2D *B1;
1149  const POINT2D *B2;
1150  const POINT2D *B3;
1151  int twist = dl->twisted;
1152 
1153  LWDEBUGF(2, "lw_dist2d_ptarray_ptarrayarc called (points: %d-%d)",pa->npoints, pb->npoints);
1154 
1155  if ( pb->npoints % 2 == 0 || pb->npoints < 3 )
1156  {
1157  lwerror("lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1158  return LW_FALSE;
1159  }
1160 
1161  if ( dl->mode == DIST_MAX )
1162  {
1163  lwerror("lw_dist2d_ptarray_ptarrayarc does not currently support DIST_MAX mode");
1164  return LW_FALSE;
1165  }
1166  else
1167  {
1168  A1 = getPoint2d_cp(pa, 0);
1169  for ( t=1; t < pa->npoints; t++ ) /* For each segment in pa */
1170  {
1171  A2 = getPoint2d_cp(pa, t);
1172  B1 = getPoint2d_cp(pb, 0);
1173  for ( u=1; u < pb->npoints; u += 2 ) /* For each arc in pb */
1174  {
1175  B2 = getPoint2d_cp(pb, u);
1176  B3 = getPoint2d_cp(pb, u+1);
1177  dl->twisted = twist;
1178 
1179  lw_dist2d_seg_arc(A1, A2, B1, B2, B3, dl);
1180 
1181  /* If we've found a distance within tolerance, we're done */
1182  if ( dl->distance <= dl->tolerance && dl->mode == DIST_MIN )
1183  return LW_TRUE;
1184 
1185  B1 = B3;
1186  }
1187  A1 = A2;
1188  }
1189  }
1190  return LW_TRUE;
1191 }
int npoints
Definition: liblwgeom.h:327
#define DIST_MAX
int mode
Definition: measures.h:26
#define DIST_MIN
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 twisted
Definition: measures.h:27
double distance
Definition: measures.h:23
int lw_dist2d_seg_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Calculate the shortest distance between an arc and an edge.
Definition: measures.c:1248
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55

Here is the call graph for this function:

Here is the caller graph for this function: