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

Find the 2d length of the given POINTARRAY, using circular arc interpolation between each coordinate triple.

Length(A1, A2, A3, A4, A5) = Length(A1, A2, A3)+Length(A3, A4, A5)

Definition at line 1559 of file ptarray.c.

References getPoint2d_cp(), lw_arc_length(), lwerror(), and POINTARRAY::npoints.

Referenced by lwcircstring_length_2d().

1560 {
1561  double dist = 0.0;
1562  int i;
1563  const POINT2D *a1;
1564  const POINT2D *a2;
1565  const POINT2D *a3;
1566 
1567  if ( pts->npoints % 2 != 1 )
1568  lwerror("arc point array with even number of points");
1569 
1570  a1 = getPoint2d_cp(pts, 0);
1571 
1572  for ( i=2; i < pts->npoints; i += 2 )
1573  {
1574  a2 = getPoint2d_cp(pts, i-1);
1575  a3 = getPoint2d_cp(pts, i);
1576  dist += lw_arc_length(a1, a2, a3);
1577  a1 = a3;
1578  }
1579  return dist;
1580 }
int npoints
Definition: liblwgeom.h:327
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
Definition: lwalgorithm.c:119
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

Here is the call graph for this function:

Here is the caller graph for this function: