PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ lw_dist3d_ptarray_ptarray()

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

Finds all combinations of segments between two pointarrays.

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

865 {
866  uint32_t t,u;
867  POINT3DZ start, end;
868  POINT3DZ start2, end2;
869  int twist = dl->twisted;
870  LWDEBUGF(2, "lw_dist3d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints);
871 
872 
873 
874  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*/
875  {
876  for (t=0; t<l1->npoints; t++) /*for each segment in L1 */
877  {
878  getPoint3dz_p(l1, t, &start);
879  for (u=0; u<l2->npoints; u++) /*for each segment in L2 */
880  {
881  getPoint3dz_p(l2, u, &start2);
882  lw_dist3d_pt_pt(&start,&start2,dl);
883  LWDEBUGF(4, "maxdist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
884  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
885  t, u, dl->distance, dl->tolerance);
886  }
887  }
888  }
889  else
890  {
891  getPoint3dz_p(l1, 0, &start);
892  for (t=1; t<l1->npoints; t++) /*for each segment in L1 */
893  {
894  getPoint3dz_p(l1, t, &end);
895  getPoint3dz_p(l2, 0, &start2);
896  for (u=1; u<l2->npoints; u++) /*for each segment in L2 */
897  {
898  getPoint3dz_p(l2, u, &end2);
899  dl->twisted=twist;
900  lw_dist3d_seg_seg(&start, &end, &start2, &end2,dl);
901  LWDEBUGF(4, "mindist_ptarray_ptarray; seg %i * seg %i, dist = %g\n",t,u,dl->distance);
902  LWDEBUGF(3, " seg%d-seg%d dist: %f, mindist: %f",
903  t, u, dl->distance, dl->tolerance);
904  if (dl->distance<=dl->tolerance && dl->mode == DIST_MIN) return LW_TRUE; /*just a check if the answer is already given*/
905  start2 = end2;
906  }
907  start = end;
908  }
909  }
910  return LW_TRUE;
911 }
double distance
Definition: measures3d.h:41
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:918
unsigned int uint32_t
Definition: uthash.h:78
#define DIST_MIN
Definition: measures.h:44
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
int lw_dist3d_pt_pt(POINT3DZ *thep1, POINT3DZ *thep2, DISTPTS3D *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...
Definition: measures3d.c:832
int twisted
Definition: measures3d.h:45
int mode
Definition: measures3d.h:44
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:215
double tolerance
Definition: measures3d.h:46
#define DIST_MAX
Definition: measures.h:43
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
uint32_t npoints
Definition: liblwgeom.h:374
Here is the call graph for this function:
Here is the caller graph for this function: