PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ptarray_length_2d()

double ptarray_length_2d ( const POINTARRAY pts)
extern

Find the 2d length of the given POINTARRAY (even if it's 3d)

Definition at line 1975 of file ptarray.c.

1976{
1977 double dist = 0.0;
1978 uint32_t i;
1979 const POINT2D *frm;
1980 const POINT2D *to;
1981
1982 if ( pts->npoints < 2 ) return 0.0;
1983
1984 frm = getPoint2d_cp(pts, 0);
1985
1986 for ( i=1; i < pts->npoints; i++ )
1987 {
1988 to = getPoint2d_cp(pts, i);
1989
1990 dist += sqrt( ((frm->x - to->x)*(frm->x - to->x)) +
1991 ((frm->y - to->y)*(frm->y - to->y)) );
1992
1993 frm = to;
1994 }
1995 return dist;
1996}
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
double y
Definition liblwgeom.h:390
double x
Definition liblwgeom.h:390
uint32_t npoints
Definition liblwgeom.h:427

References getPoint2d_cp(), POINTARRAY::npoints, POINT2D::x, and POINT2D::y.

Referenced by LWGEOM_line_substring(), lwline_crossing_direction(), lwline_interpolate_points(), lwline_length_2d(), lwline_measured_from_lwline(), lwmline_measured_from_lwmline(), lwpoly_perimeter_2d(), lwtriangle_perimeter_2d(), ptarray_length(), ptarray_locate_point(), and ptarray_substring().

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