PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ lw_dist2d_point_curvepoly()

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

Definition at line 684 of file measures.c.

685 {
686  const POINT2D *p = getPoint2d_cp(point->point, 0);
687 
688  if (dl->mode == DIST_MAX)
689  lwerror("lw_dist2d_point_curvepoly cannot calculate max distance");
690 
691  /* Return distance to outer ring if not inside it */
692  if (lwgeom_contains_point(poly->rings[0], p) == LW_OUTSIDE)
693  return lw_dist2d_recursive((LWGEOM *)point, poly->rings[0], dl);
694 
695  /* Inside the outer ring.
696  * Scan though each of the inner rings looking to see if its inside. If not, distance==0.
697  * Otherwise, distance = pt to ring distance.
698  */
699  for (uint32_t i = 1; i < poly->nrings; i++)
700  if (lwgeom_contains_point(poly->rings[i], p) == LW_INSIDE)
701  return lw_dist2d_recursive((LWGEOM *)point, poly->rings[i], dl);
702 
703  /* Is inside the polygon */
704  lw_dist2d_distpts_set(dl, 0.0, p, p);
705  return LW_TRUE;
706 }
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
#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:172
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
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_MAX
Definition: measures.h:43
int mode
Definition: measures.h:54
LWGEOM ** rings
Definition: liblwgeom.h:603
uint32_t nrings
Definition: liblwgeom.h:608
POINTARRAY * point
Definition: liblwgeom.h:471

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: