PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ lw_dist2d_line_curvepoly()

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

Definition at line 781 of file measures.c.

782 {
783  const POINT2D *pt = getPoint2d_cp(line->points, 0);
784 
785  /* Line has a point outside curvepoly. Check distance to outer ring only. */
786  if (lwgeom_contains_point(poly->rings[0], pt) == LW_OUTSIDE)
787  return lw_dist2d_recursive((LWGEOM *)line, poly->rings[0], dl);
788 
789  for (uint32_t i = 1; i < poly->nrings; i++)
790  {
791  if (!lw_dist2d_recursive((LWGEOM *)line, poly->rings[i], dl))
792  return LW_FALSE;
793 
794  /* just a check if the answer is already given */
795  if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
796  return LW_TRUE;
797  }
798 
799  /* It's inside a hole, then distance is actual min distance */
800  for (uint32_t i = 1; i < poly->nrings; i++)
801  if (lwgeom_contains_point(poly->rings[i], pt) != LW_OUTSIDE)
802  return LW_TRUE;
803 
804  /* Not in hole, so inside polygon */
805  if (dl->mode == DIST_MIN)
806  {
807  lw_dist2d_distpts_set(dl, 0.0, pt, pt);
808  }
809  return LW_TRUE;
810 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
#define LW_OUTSIDE
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:172
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwinline.h:97
static void lw_dist2d_distpts_set(DISTPTS *dl, double distance, const POINT2D *p1, const POINT2D *p2)
Definition: measures.c:81
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:299
#define DIST_MIN
Definition: measures.h:44
double tolerance
Definition: measures.h:56
int mode
Definition: measures.h:54
double distance
Definition: measures.h:51
LWGEOM ** rings
Definition: liblwgeom.h:603
uint32_t nrings
Definition: liblwgeom.h:608
POINTARRAY * points
Definition: liblwgeom.h:483

References DIST_MIN, DISTPTS::distance, getPoint2d_cp(), lw_dist2d_distpts_set(), lw_dist2d_recursive(), LW_FALSE, LW_OUTSIDE, LW_TRUE, lwgeom_contains_point(), DISTPTS::mode, LWCURVEPOLY::nrings, LWLINE::points, LWCURVEPOLY::rings, and DISTPTS::tolerance.

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: