PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ lw_dist2d_line_curvepoly()

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

Definition at line 776 of file measures.c.

777 {
778  const POINT2D *pt = getPoint2d_cp(line->points, 0);
779 
780  /* Line has a pount outside curvepoly. Check distance to outer ring only. */
781  if (lwgeom_contains_point(poly->rings[0], pt) == LW_OUTSIDE)
782  return lw_dist2d_recursive((LWGEOM *)line, poly->rings[0], dl);
783 
784  for (uint32_t i = 1; i < poly->nrings; i++)
785  {
786  if (!lw_dist2d_recursive((LWGEOM *)line, poly->rings[i], dl))
787  return LW_FALSE;
788 
789  /* just a check if the answer is already given */
790  if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
791  return LW_TRUE;
792  }
793 
794  /* It's inside a hole, then distance is actual min distance */
795  for (uint32_t i = 1; i < poly->nrings; i++)
796  if (lwgeom_contains_point(poly->rings[i], pt) != LW_OUTSIDE)
797  return LW_TRUE;
798 
799  /* Not in hole, so inside polygon */
800  if (dl->mode == DIST_MIN)
801  {
802  lw_dist2d_distpts_set(dl, 0.0, pt, pt);
803  }
804  return LW_TRUE;
805 }
#define LW_FALSE
Definition: liblwgeom.h:108
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:107
#define LW_OUTSIDE
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:129
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:101
static void lw_dist2d_distpts_set(DISTPTS *dl, double distance, const POINT2D *p1, const POINT2D *p2)
Definition: measures.c:78
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:296
#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:617
uint32_t nrings
Definition: liblwgeom.h:622
POINTARRAY * points
Definition: liblwgeom.h:497

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: