PostGIS  2.5.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 2670 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().

2671 {
2672  uint32_t i;
2673  GEOGRAPHIC_POINT p;
2674  GEOGRAPHIC_EDGE e;
2675 
2676  for ( i = 0; i < lwline->points->npoints - 1; i++)
2677  {
2678  const POINT2D* a1 = getPoint2d_cp(lwline->points, i);
2679  const POINT2D* a2 = getPoint2d_cp(lwline->points, i+1);
2680 
2681  geographic_point_init(a1->x, a1->y, &(e.start));
2682  geographic_point_init(a2->x, a2->y, &(e.end));
2683 
2684  geographic_point_init(lwpoint_get_x(lwpoint), lwpoint_get_y(lwpoint), &p);
2685 
2686  if ( edge_contains_point(&e, &p) ) {
2687  return LW_TRUE;
2688  }
2689  }
2690 
2691  return LW_FALSE;
2692 }
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:56
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:1003
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:47
unsigned int uint32_t
Definition: uthash.h:78
double x
Definition: liblwgeom.h:330
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
#define LW_FALSE
Definition: liblwgeom.h:76
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:58
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:59
double y
Definition: liblwgeom.h:330
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition: lwgeodetic.c:171
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:364
POINTARRAY * points
Definition: liblwgeom.h:424
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: