PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lw_dist3d_ptarray_ptarray ( POINTARRAY l1,
POINTARRAY l2,
DISTPTS3D dl 
)

Finds all combinationes of segments between two pointarrays.

Definition at line 630 of file measures3d.c.

References DIST_MAX, DIST_MIN, DISTPTS3D::distance, getPoint3dz_p(), lw_dist3d_pt_pt(), lw_dist3d_seg_seg(), LW_TRUE, LWDEBUGF, DISTPTS3D::mode, POINTARRAY::npoints, DISTPTS3D::tolerance, and DISTPTS3D::twisted.

Referenced by lw_dist3d_line_line(), lw_dist3d_line_poly(), lw_dist3d_poly_poly(), and lw_dist3d_ptarray_poly().

631 {
632  int t,u;
633  POINT3DZ start, end;
634  POINT3DZ start2, end2;
635  int twist = dl->twisted;
636  LWDEBUGF(2, "lw_dist3d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints);
637 
638 
639 
640  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*/
641  {
642  for (t=0; t<l1->npoints; t++) /*for each segment in L1 */
643  {
644  getPoint3dz_p(l1, t, &start);
645  for (u=0; u<l2->npoints; u++) /*for each segment in L2 */
646  {
647  getPoint3dz_p(l2, u, &start2);
648  lw_dist3d_pt_pt(&start,&start2,dl);
649  LWDEBUGF(4, "maxdist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
650  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
651  t, u, dl->distance, dl->tolerance);
652  }
653  }
654  }
655  else
656  {
657  getPoint3dz_p(l1, 0, &start);
658  for (t=1; t<l1->npoints; t++) /*for each segment in L1 */
659  {
660  getPoint3dz_p(l1, t, &end);
661  getPoint3dz_p(l2, 0, &start2);
662  for (u=1; u<l2->npoints; u++) /*for each segment in L2 */
663  {
664  getPoint3dz_p(l2, u, &end2);
665  dl->twisted=twist;
666  lw_dist3d_seg_seg(&start, &end, &start2, &end2,dl);
667  LWDEBUGF(4, "mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
668  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
669  t, u, dl->distance, dl->tolerance);
670  if (dl->distance<=dl->tolerance && dl->mode == DIST_MIN) return LW_TRUE; /*just a check if the answer is already given*/
671  start2 = end2;
672  }
673  start = end;
674  }
675  }
676  return LW_TRUE;
677 }
double distance
Definition: measures3d.h:26
int npoints
Definition: liblwgeom.h:327
#define DIST_MAX
#define DIST_MIN
int lw_dist3d_seg_seg(POINT3DZ *s1p1, POINT3DZ *s1p2, POINT3DZ *s2p1, POINT3DZ *s2p2, DISTPTS3D *dl)
Finds the two closest points on two linesegments.
Definition: measures3d.c:684
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:305
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
int lw_dist3d_pt_pt(POINT3DZ *thep1, POINT3DZ *thep2, DISTPTS3D *dl)
Compares incomming points and stores the points closest to each other or most far away from each othe...
Definition: measures3d.c:598
int twisted
Definition: measures3d.h:30
int mode
Definition: measures3d.h:29
double tolerance
Definition: measures3d.h:31
#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: