PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lw_dist3d_poly_poly()

int lw_dist3d_poly_poly ( LWPOLY poly1,
LWPOLY poly2,
DISTPTS3D dl 
)

polygon to polygon calculation

Definition at line 688 of file measures3d.c.

689 {
690  PLANE3D plane1, plane2;
691  int planedef1, planedef2;
692  LWDEBUG(2, "lw_dist3d_poly_poly is called");
693  if (dl->mode == DIST_MAX)
694  {
695  return lw_dist3d_ptarray_ptarray(poly1->rings[0], poly2->rings[0], dl);
696  }
697 
698  planedef1 = define_plane(poly1->rings[0], &plane1);
699  planedef2 = define_plane(poly2->rings[0], &plane2);
700 
701  if (!planedef1 || !planedef2)
702  {
703  if (!planedef1 && !planedef2)
704  {
705  /* Neither polygon define a plane: Return distance line to line */
706  return lw_dist3d_ptarray_ptarray(poly1->rings[0], poly2->rings[0], dl);
707  }
708 
709  if (!planedef1)
710  {
711  /* Only poly2 defines a plane: Return distance from line (poly1) to poly2 */
712  return lw_dist3d_ptarray_poly(poly1->rings[0], poly2, &plane2, dl);
713  }
714 
715  /* Only poly1 defines a plane: Return distance from line (poly2) to poly1 */
716  return lw_dist3d_ptarray_poly(poly2->rings[0], poly1, &plane1, dl);
717  }
718 
719  /*What we do here is to compare the boundary of one polygon with the other polygon
720  and then take the second boundary comparing with the first polygon*/
721  dl->twisted=1;
722  if (!lw_dist3d_ptarray_poly(poly1->rings[0], poly2, &plane2, dl))
723  return LW_FALSE;
724  if (dl->distance < dl->tolerance) /*Just check if the answer already is given*/
725  return LW_TRUE;
726 
727  dl->twisted=-1; /*because we switch the order of geometries we switch "twisted" to -1 which will give the right order of points in shortest line.*/
728  return lw_dist3d_ptarray_poly(poly2->rings[0], poly1, &plane1, dl);
729 }
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
int define_plane(POINTARRAY *pa, PLANE3D *pl)
Definition: measures3d.c:1167
int lw_dist3d_ptarray_poly(POINTARRAY *pa, LWPOLY *poly, PLANE3D *plane, DISTPTS3D *dl)
Computes pointarray to polygon distance.
Definition: measures3d.c:1074
int lw_dist3d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2, DISTPTS3D *dl)
Finds all combinations of segments between two pointarrays.
Definition: measures3d.c:864
#define DIST_MAX
Definition: measures.h:43
int twisted
Definition: measures3d.h:45
double distance
Definition: measures3d.h:41
int mode
Definition: measures3d.h:44
double tolerance
Definition: measures3d.h:46
POINTARRAY ** rings
Definition: liblwgeom.h:460

References define_plane(), DIST_MAX, DISTPTS3D::distance, lw_dist3d_ptarray_poly(), lw_dist3d_ptarray_ptarray(), LW_FALSE, LW_TRUE, LWDEBUG, DISTPTS3D::mode, LWPOLY::rings, DISTPTS3D::tolerance, and DISTPTS3D::twisted.

Referenced by lw_dist3d_distribute_bruteforce().

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