PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lw_dist2d_line_curvepoly()

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

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

783 {
784  const POINT2D *pt = getPoint2d_cp(line->points, 0);
785  int i;
786 
787  if ( lwgeom_contains_point(poly->rings[0], pt) == LW_OUTSIDE )
788  {
789  return lw_dist2d_recursive((LWGEOM*)line, poly->rings[0], dl);
790  }
791 
792  for ( i = 1; i < poly->nrings; i++ )
793  {
794  if ( ! lw_dist2d_recursive((LWGEOM*)line, poly->rings[i], dl) )
795  return LW_FALSE;
796 
797  if ( dl->distance<=dl->tolerance && dl->mode == DIST_MIN )
798  return LW_TRUE;
799  }
800 
801  for ( i=1; i < poly->nrings; i++ )
802  {
803  if ( lwgeom_contains_point(poly->rings[i],pt) != LW_OUTSIDE )
804  {
805  /* Its inside a hole, then the actual */
806  return LW_TRUE;
807  }
808  }
809 
810  if (dl->mode == DIST_MIN)
811  {
812  dl->distance = 0.0;
813  dl->p1.x = dl->p2.x = pt->x;
814  dl->p1.y = dl->p2.y = pt->y;
815  }
816 
817  return LW_TRUE; /* Not in hole, so inside polygon */
818 }
LWGEOM ** rings
Definition: liblwgeom.h:519
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:263
int mode
Definition: measures.h:27
POINT2D p1
Definition: measures.h:25
double tolerance
Definition: measures.h:29
double x
Definition: liblwgeom.h:312
#define DIST_MIN
Definition: measures.h:17
#define LW_FALSE
Definition: liblwgeom.h:62
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:472
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
POINT2D p2
Definition: measures.h:26
double y
Definition: liblwgeom.h:312
double distance
Definition: measures.h:24
#define LW_OUTSIDE
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:116
POINTARRAY * points
Definition: liblwgeom.h:406
Here is the call graph for this function:
Here is the caller graph for this function: