PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lwline_covers_lwpoint()

int lwline_covers_lwpoint ( const LWLINE lwline,
const LWPOINT lwpoint 
)

return LW_TRUE if any of the line segments covers the point

Definition at line 2774 of file lwgeodetic.c.

2775 {
2776  uint32_t i;
2777  GEOGRAPHIC_POINT p;
2778  GEOGRAPHIC_EDGE e;
2779 
2780  for ( i = 0; i < lwline->points->npoints - 1; i++)
2781  {
2782  const POINT2D* a1 = getPoint2d_cp(lwline->points, i);
2783  const POINT2D* a2 = getPoint2d_cp(lwline->points, i+1);
2784 
2785  geographic_point_init(a1->x, a1->y, &(e.start));
2786  geographic_point_init(a2->x, a2->y, &(e.end));
2787 
2788  geographic_point_init(lwpoint_get_x(lwpoint), lwpoint_get_y(lwpoint), &p);
2789 
2790  if ( edge_contains_point(&e, &p) ) {
2791  return LW_TRUE;
2792  }
2793  }
2794 
2795  return LW_FALSE;
2796 }
#define LW_FALSE
Definition: liblwgeom.h:94
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:76
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition: lwgeodetic.c:180
int edge_contains_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
Returns true if the point p is on the minor edge defined by the end points of e.
Definition: lwgeodetic.c:1038
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
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:64
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:65
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:63
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:54
POINTARRAY * points
Definition: liblwgeom.h:483
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390
uint32_t npoints
Definition: liblwgeom.h:427

References edge_contains_point(), GEOGRAPHIC_EDGE::end, geographic_point_init(), getPoint2d_cp(), LW_FALSE, LW_TRUE, lwpoint_get_x(), lwpoint_get_y(), POINTARRAY::npoints, LWLINE::points, GEOGRAPHIC_EDGE::start, POINT2D::x, and POINT2D::y.

Referenced by lwgeom_covers_lwgeom_sphere(), and lwline_covers_lwline().

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