PostGIS  2.1.10dev-r@@SVN_REVISION@@
int lw_dist2d_line_curvepoly ( LWLINE line,
LWCURVEPOLY poly,
DISTPTS dl 
)

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

757 {
758  const POINT2D *pt = getPoint2d_cp(line->points, 0);
759  int i;
760 
761  if ( lwgeom_contains_point(poly->rings[0], pt) == LW_OUTSIDE )
762  {
763  return lw_dist2d_recursive((LWGEOM*)line, poly->rings[0], dl);
764  }
765 
766  for ( i = 1; i < poly->nrings; i++ )
767  {
768  if ( ! lw_dist2d_recursive((LWGEOM*)line, poly->rings[i], dl) )
769  return LW_FALSE;
770 
771  if ( dl->distance<=dl->tolerance && dl->mode == DIST_MIN )
772  return LW_TRUE;
773  }
774 
775  for ( i=1; i < poly->nrings; i++ )
776  {
777  if ( lwgeom_contains_point(poly->rings[i],pt) != LW_OUTSIDE )
778  {
779  /* Its inside a hole, then the actual */
780  return LW_TRUE;
781  }
782  }
783 
784  if (dl->mode == DIST_MIN)
785  {
786  dl->distance = 0.0;
787  dl->p1.x = dl->p2.x = pt->x;
788  dl->p1.y = dl->p2.y = pt->y;
789  }
790 
791  return LW_TRUE; /* Not in hole, so inside polygon */
792 }
LWGEOM ** rings
Definition: liblwgeom.h:491
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:237
int mode
Definition: measures.h:26
#define DIST_MIN
POINT2D p1
Definition: measures.h:24
double tolerance
Definition: measures.h:28
double x
Definition: liblwgeom.h:284
#define LW_FALSE
Definition: liblwgeom.h:52
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:458
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
POINT2D p2
Definition: measures.h:25
double y
Definition: liblwgeom.h:284
double distance
Definition: measures.h:23
#define LW_OUTSIDE
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:116
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: