PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lw_dist2d_line_curvepoly()

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

Definition at line 800 of file measures.c.

801 {
802  const POINT2D *pt = getPoint2d_cp(line->points, 0);
803  uint32_t i;
804 
805  if ( lwgeom_contains_point(poly->rings[0], pt) == LW_OUTSIDE )
806  {
807  return lw_dist2d_recursive((LWGEOM*)line, poly->rings[0], dl);
808  }
809 
810  for ( i = 1; i < poly->nrings; i++ )
811  {
812  if ( ! lw_dist2d_recursive((LWGEOM*)line, poly->rings[i], dl) )
813  return LW_FALSE;
814 
815  if ( dl->distance<=dl->tolerance && dl->mode == DIST_MIN )
816  return LW_TRUE;
817  }
818 
819  for ( i=1; i < poly->nrings; i++ )
820  {
821  if ( lwgeom_contains_point(poly->rings[i],pt) != LW_OUTSIDE )
822  {
823  /* Its inside a hole, then the actual */
824  return LW_TRUE;
825  }
826  }
827 
828  if (dl->mode == DIST_MIN)
829  {
830  dl->distance = 0.0;
831  dl->p1.x = dl->p2.x = pt->x;
832  dl->p1.y = dl->p2.y = pt->y;
833  }
834 
835  return LW_TRUE; /* Not in hole, so inside polygon */
836 }
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwgeom_api.c:374
#define LW_OUTSIDE
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:129
int lw_dist2d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl)
This is a recursive function delivering every possible combination of subgeometries.
Definition: measures.c:277
#define DIST_MIN
Definition: measures.h:44
POINT2D p1
Definition: measures.h:52
POINT2D p2
Definition: measures.h:53
double tolerance
Definition: measures.h:56
int mode
Definition: measures.h:54
double distance
Definition: measures.h:51
LWGEOM ** rings
Definition: liblwgeom.h:538
uint32_t nrings
Definition: liblwgeom.h:536
POINTARRAY * points
Definition: liblwgeom.h:425
double y
Definition: liblwgeom.h:331
double x
Definition: liblwgeom.h:331
unsigned int uint32_t
Definition: uthash.h:78

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().

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