PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ lw_dist2d_ptarray_ptarrayarc()

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

1236 {
1237  uint32_t t, u;
1238  const POINT2D *A1;
1239  const POINT2D *A2;
1240  const POINT2D *B1;
1241  const POINT2D *B2;
1242  const POINT2D *B3;
1243  int twist = dl->twisted;
1244 
1245  LWDEBUGF(2, "lw_dist2d_ptarray_ptarrayarc called (points: %d-%d)", pa->npoints, pb->npoints);
1246 
1247  if (pb->npoints % 2 == 0 || pb->npoints < 3)
1248  {
1249  lwerror("lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1250  return LW_FALSE;
1251  }
1252 
1253  if (dl->mode == DIST_MAX)
1254  {
1255  lwerror("lw_dist2d_ptarray_ptarrayarc does not currently support DIST_MAX mode");
1256  return LW_FALSE;
1257  }
1258  else
1259  {
1260  A1 = getPoint2d_cp(pa, 0);
1261  for (t = 1; t < pa->npoints; t++) /* For each segment in pa */
1262  {
1263  A2 = getPoint2d_cp(pa, t);
1264  B1 = getPoint2d_cp(pb, 0);
1265  for (u = 1; u < pb->npoints; u += 2) /* For each arc in pb */
1266  {
1267  B2 = getPoint2d_cp(pb, u);
1268  B3 = getPoint2d_cp(pb, u + 1);
1269  dl->twisted = twist;
1270 
1271  lw_dist2d_seg_arc(A1, A2, B1, B2, B3, dl);
1272 
1273  /* If we've found a distance within tolerance, we're done */
1274  if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
1275  return LW_TRUE;
1276 
1277  B1 = B3;
1278  }
1279  A1 = A2;
1280  }
1281  }
1282  return LW_TRUE;
1283 }
#define LW_FALSE
Definition: liblwgeom.h:108
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:107
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
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_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:1340
#define DIST_MIN
Definition: measures.h:44
#define DIST_MAX
Definition: measures.h:43
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:441

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(), lw_dist2d_tri_circstring(), and test_lw_dist2d_ptarray_ptarrayarc().

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