PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lw_dist2d_ptarray_ptarray ( POINTARRAY l1,
POINTARRAY l2,
DISTPTS dl 
)

test each segment of l1 against each segment of l2.

Definition at line 1091 of file measures.c.

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

1092 {
1093  int t,u;
1094  const POINT2D *start, *end;
1095  const POINT2D *start2, *end2;
1096  int twist = dl->twisted;
1097 
1098  LWDEBUGF(2, "lw_dist2d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints);
1099 
1100  if (dl->mode == DIST_MAX)/*If we are searching for maxdistance we go straight to point-point calculation since the maxdistance have to be between two vertexes*/
1101  {
1102  for (t=0; t<l1->npoints; t++) /*for each segment in L1 */
1103  {
1104  start = getPoint2d_cp(l1, t);
1105  for (u=0; u<l2->npoints; u++) /*for each segment in L2 */
1106  {
1107  start2 = getPoint2d_cp(l2, u);
1108  lw_dist2d_pt_pt(start, start2, dl);
1109  LWDEBUGF(4, "maxdist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
1110  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
1111  t, u, dl->distance, dl->tolerance);
1112  }
1113  }
1114  }
1115  else
1116  {
1117  start = getPoint2d_cp(l1, 0);
1118  for (t=1; t<l1->npoints; t++) /*for each segment in L1 */
1119  {
1120  end = getPoint2d_cp(l1, t);
1121  start2 = getPoint2d_cp(l2, 0);
1122  for (u=1; u<l2->npoints; u++) /*for each segment in L2 */
1123  {
1124  end2 = getPoint2d_cp(l2, u);
1125  dl->twisted=twist;
1126  lw_dist2d_seg_seg(start, end, start2, end2, dl);
1127  LWDEBUGF(4, "mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
1128  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
1129  t, u, dl->distance, dl->tolerance);
1130  if (dl->distance<=dl->tolerance && dl->mode == DIST_MIN) return LW_TRUE; /*just a check if the answer is already given*/
1131  start2 = end2;
1132  }
1133  start = end;
1134  }
1135  }
1136  return LW_TRUE;
1137 }
int npoints
Definition: liblwgeom.h:327
#define DIST_MAX
int mode
Definition: measures.h:26
#define DIST_MIN
double tolerance
Definition: measures.h:28
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_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:1624
int twisted
Definition: measures.h:27
double distance
Definition: measures.h:23
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
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: