PostGIS  2.4.9dev-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 2740 of file lwgeodetic.c.

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().

2741 {
2742  int i;
2743  GEOGRAPHIC_POINT p;
2744  GEOGRAPHIC_EDGE e;
2745 
2746  for ( i = 0; i < lwline->points->npoints - 1; i++)
2747  {
2748  const POINT2D* a1 = getPoint2d_cp(lwline->points, i);
2749  const POINT2D* a2 = getPoint2d_cp(lwline->points, i+1);
2750 
2751  geographic_point_init(a1->x, a1->y, &(e.start));
2752  geographic_point_init(a2->x, a2->y, &(e.end));
2753 
2754  geographic_point_init(lwpoint_get_x(lwpoint), lwpoint_get_y(lwpoint), &p);
2755 
2756  if ( edge_contains_point(&e, &p) ) {
2757  return LW_TRUE;
2758  }
2759  }
2760 
2761  return LW_FALSE;
2762 }
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:61
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:1030
int npoints
Definition: liblwgeom.h:371
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:52
double x
Definition: liblwgeom.h:328
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
#define LW_FALSE
Definition: liblwgeom.h:77
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:373
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:63
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:64
double y
Definition: liblwgeom.h:328
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition: lwgeodetic.c:180
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:76
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: