PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ lw_dist2d_point_curvepoly()

int lw_dist2d_point_curvepoly ( LWPOINT point,
LWCURVEPOLY poly,
DISTPTS dl 
)

Definition at line 679 of file measures.c.

680 {
681  const POINT2D *p = getPoint2d_cp(point->point, 0);
682 
683  if (dl->mode == DIST_MAX)
684  lwerror("lw_dist2d_point_curvepoly cannot calculate max distance");
685 
686  /* Return distance to outer ring if not inside it */
687  if (lwgeom_contains_point(poly->rings[0], p) == LW_OUTSIDE)
688  return lw_dist2d_recursive((LWGEOM *)point, poly->rings[0], dl);
689 
690  /* Inside the outer ring.
691  * Scan though each of the inner rings looking to see if its inside. If not, distance==0.
692  * Otherwise, distance = pt to ring distance.
693  */
694  for (uint32_t i = 1; i < poly->nrings; i++)
695  if (lwgeom_contains_point(poly->rings[i], p) == LW_INSIDE)
696  return lw_dist2d_recursive((LWGEOM *)point, poly->rings[i], dl);
697 
698  /* Is inside the polygon */
699  lw_dist2d_distpts_set(dl, 0.0, p, p);
700  return LW_TRUE;
701 }
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:107
#define LW_INSIDE
Constants for point-in-polygon return values.
#define LW_OUTSIDE
int lwgeom_contains_point(const LWGEOM *geom, const POINT2D *pt)
Definition: lwcompound.c:129
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
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:280
#define DIST_MAX
Definition: measures.h:43
int mode
Definition: measures.h:54
LWGEOM ** rings
Definition: liblwgeom.h:617
uint32_t nrings
Definition: liblwgeom.h:622
POINTARRAY * point
Definition: liblwgeom.h:485

References DIST_MAX, getPoint2d_cp(), lw_dist2d_distpts_set(), lw_dist2d_recursive(), LW_INSIDE, LW_OUTSIDE, LW_TRUE, lwerror(), lwgeom_contains_point(), DISTPTS::mode, LWCURVEPOLY::nrings, LWPOINT::point, and LWCURVEPOLY::rings.

Referenced by lw_dist2d_distribute_bruteforce().

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