PostGIS  2.5.7dev-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 2757 of file lwgeodetic.c.

2758 {
2759  uint32_t i;
2760  GEOGRAPHIC_POINT p;
2761  GEOGRAPHIC_EDGE e;
2762 
2763  for ( i = 0; i < lwline->points->npoints - 1; i++)
2764  {
2765  const POINT2D* a1 = getPoint2d_cp(lwline->points, i);
2766  const POINT2D* a2 = getPoint2d_cp(lwline->points, i+1);
2767 
2768  geographic_point_init(a1->x, a1->y, &(e.start));
2769  geographic_point_init(a2->x, a2->y, &(e.end));
2770 
2771  geographic_point_init(lwpoint_get_x(lwpoint), lwpoint_get_y(lwpoint), &p);
2772 
2773  if ( edge_contains_point(&e, &p) ) {
2774  return LW_TRUE;
2775  }
2776  }
2777 
2778  return LW_FALSE;
2779 }
#define LW_FALSE
Definition: liblwgeom.h:77
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:76
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwgeom_api.c:374
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:1034
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:63
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:64
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:62
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:53
POINTARRAY * points
Definition: liblwgeom.h:425
double y
Definition: liblwgeom.h:331
double x
Definition: liblwgeom.h:331
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

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: