PostGIS  2.1.10dev-r@@SVN_REVISION@@
double ptarray_length_2d ( const POINTARRAY pts)

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

Definition at line 1586 of file ptarray.c.

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

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

1587 {
1588  double dist = 0.0;
1589  int i;
1590  const POINT2D *frm;
1591  const POINT2D *to;
1592 
1593  if ( pts->npoints < 2 ) return 0.0;
1594 
1595  frm = getPoint2d_cp(pts, 0);
1596 
1597  for ( i=1; i < pts->npoints; i++ )
1598  {
1599  to = getPoint2d_cp(pts, i);
1600 
1601  dist += sqrt( ((frm->x - to->x)*(frm->x - to->x)) +
1602  ((frm->y - to->y)*(frm->y - to->y)) );
1603 
1604  frm = to;
1605  }
1606  return dist;
1607 }
int npoints
Definition: liblwgeom.h:327
double x
Definition: liblwgeom.h:284
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:458
double y
Definition: liblwgeom.h:284

Here is the call graph for this function:

Here is the caller graph for this function: