PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lw_dist2d_line_curvepoly()

int lw_dist2d_line_curvepoly ( LWLINE line,
LWCURVEPOLY poly,
DISTPTS dl 
)

Definition at line 796 of file measures.c.

References DIST_MIN, DISTPTS::distance, getPoint2d_cp(), lw_dist2d_recursive(), LW_FALSE, LW_OUTSIDE, LW_TRUE, lwgeom_contains_point(), DISTPTS::mode, LWCURVEPOLY::nrings, DISTPTS::p1, DISTPTS::p2, LWLINE::points, LWCURVEPOLY::rings, DISTPTS::tolerance, POINT2D::x, and POINT2D::y.

Referenced by lw_dist2d_circstring_curvepoly(), lw_dist2d_circstring_poly(), and lw_dist2d_distribute_bruteforce().

797 {
798  const POINT2D *pt = getPoint2d_cp(line->points, 0);
799  int i;
800 
801  if ( lwgeom_contains_point(poly->rings[0], pt) == LW_OUTSIDE )
802  {
803  return lw_dist2d_recursive((LWGEOM*)line, poly->rings[0], dl);
804  }
805 
806  for ( i = 1; i < poly->nrings; i++ )
807  {
808  if ( ! lw_dist2d_recursive((LWGEOM*)line, poly->rings[i], dl) )
809  return LW_FALSE;
810 
811  if ( dl->distance<=dl->tolerance && dl->mode == DIST_MIN )
812  return LW_TRUE;
813  }
814 
815  for ( i=1; i < poly->nrings; i++ )
816  {
817  if ( lwgeom_contains_point(poly->rings[i],pt) != LW_OUTSIDE )
818  {
819  /* Its inside a hole, then the actual */
820  return LW_TRUE;
821  }
822  }
823 
824  if (dl->mode == DIST_MIN)
825  {
826  dl->distance = 0.0;
827  dl->p1.x = dl->p2.x = pt->x;
828  dl->p1.y = dl->p2.y = pt->y;
829  }
830 
831  return LW_TRUE; /* Not in hole, so inside polygon */
832 }
LWGEOM ** rings
Definition: liblwgeom.h:535
int lw_dist2d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl)
This is a recursive function delivering every possible combinatin of subgeometries.
Definition: measures.c:277
int mode
Definition: measures.h:54
POINT2D p1
Definition: measures.h:52
double tolerance
Definition: measures.h:56
double x
Definition: liblwgeom.h:328
#define DIST_MIN
Definition: measures.h:44
#define LW_FALSE
Definition: liblwgeom.h:77
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:373
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
POINT2D p2
Definition: measures.h:53
double y
Definition: liblwgeom.h:328
double distance
Definition: measures.h:51
#define LW_OUTSIDE
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:129
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: