PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lw_dist2d_ptarray_ptarray()

int lw_dist2d_ptarray_ptarray ( POINTARRAY l1,
POINTARRAY l2,
DISTPTS dl 
)

test each segment of l1 against each segment of l2.

Definition at line 1209 of file measures.c.

1210 {
1211  uint32_t t, u;
1212  const POINT2D *start, *end;
1213  const POINT2D *start2, *end2;
1214  int twist = dl->twisted;
1215 
1216  LWDEBUGF(2, "lw_dist2d_ptarray_ptarray called (points: %d-%d)", l1->npoints, l2->npoints);
1217 
1218  /* If we are searching for maxdistance we go straight to point-point calculation since the maxdistance have
1219  * to be between two vertexes*/
1220  if (dl->mode == DIST_MAX)
1221  {
1222  for (t = 0; t < l1->npoints; t++) /*for each segment in L1 */
1223  {
1224  start = getPoint2d_cp(l1, t);
1225  for (u = 0; u < l2->npoints; u++) /*for each segment in L2 */
1226  {
1227  start2 = getPoint2d_cp(l2, u);
1228  lw_dist2d_pt_pt(start, start2, dl);
1229  }
1230  }
1231  }
1232  else
1233  {
1234  start = getPoint2d_cp(l1, 0);
1235  for (t = 1; t < l1->npoints; t++) /*for each segment in L1 */
1236  {
1237  end = getPoint2d_cp(l1, t);
1238  start2 = getPoint2d_cp(l2, 0);
1239  for (u = 1; u < l2->npoints; u++) /*for each segment in L2 */
1240  {
1241  end2 = getPoint2d_cp(l2, u);
1242  dl->twisted = twist;
1243  lw_dist2d_seg_seg(start, end, start2, end2, dl);
1244  if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
1245  return LW_TRUE; /*just a check if the answer is already given*/
1246  start2 = end2;
1247  }
1248  start = end;
1249  }
1250  }
1251  return LW_TRUE;
1252 }
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
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_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl)
Finds the shortest distance between two segments.
Definition: measures.c:1917
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...
Definition: measures.c:2366
#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:427

References DIST_MAX, DIST_MIN, DISTPTS::distance, getPoint2d_cp(), lw_dist2d_pt_pt(), lw_dist2d_seg_seg(), LW_TRUE, LWDEBUGF, DISTPTS::mode, POINTARRAY::npoints, DISTPTS::tolerance, and DISTPTS::twisted.

Referenced by lw_dist2d_line_line(), lw_dist2d_line_poly(), lw_dist2d_line_tri(), lw_dist2d_poly_poly(), lw_dist2d_tri_poly(), and lw_dist2d_tri_tri().

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