PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lw_dist3d_ptarray_ptarray()

int lw_dist3d_ptarray_ptarray ( POINTARRAY l1,
POINTARRAY l2,
DISTPTS3D dl 
)

Finds all combinationes of segments between two pointarrays.

Definition at line 820 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().

821 {
822  int t,u;
823  POINT3DZ start, end;
824  POINT3DZ start2, end2;
825  int twist = dl->twisted;
826  LWDEBUGF(2, "lw_dist3d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints);
827 
828 
829 
830  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*/
831  {
832  for (t=0; t<l1->npoints; t++) /*for each segment in L1 */
833  {
834  getPoint3dz_p(l1, t, &start);
835  for (u=0; u<l2->npoints; u++) /*for each segment in L2 */
836  {
837  getPoint3dz_p(l2, u, &start2);
838  lw_dist3d_pt_pt(&start,&start2,dl);
839  LWDEBUGF(4, "maxdist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
840  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
841  t, u, dl->distance, dl->tolerance);
842  }
843  }
844  }
845  else
846  {
847  getPoint3dz_p(l1, 0, &start);
848  for (t=1; t<l1->npoints; t++) /*for each segment in L1 */
849  {
850  getPoint3dz_p(l1, t, &end);
851  getPoint3dz_p(l2, 0, &start2);
852  for (u=1; u<l2->npoints; u++) /*for each segment in L2 */
853  {
854  getPoint3dz_p(l2, u, &end2);
855  dl->twisted=twist;
856  lw_dist3d_seg_seg(&start, &end, &start2, &end2,dl);
857  LWDEBUGF(4, "mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
858  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
859  t, u, dl->distance, dl->tolerance);
860  if (dl->distance<=dl->tolerance && dl->mode == DIST_MIN) return LW_TRUE; /*just a check if the answer is already given*/
861  start2 = end2;
862  }
863  start = end;
864  }
865  }
866  return LW_TRUE;
867 }
double distance
Definition: measures3d.h:27
int npoints
Definition: liblwgeom.h:355
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:874
#define DIST_MIN
Definition: measures.h:17
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:319
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
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:788
int twisted
Definition: measures3d.h:31
int mode
Definition: measures3d.h:30
double tolerance
Definition: measures3d.h:32
#define DIST_MAX
Definition: measures.h:16
#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: