PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ ptarray_arc_length_2d()

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 1936 of file ptarray.c.

1937 {
1938  double dist = 0.0;
1939  uint32_t i;
1940  const POINT2D *a1;
1941  const POINT2D *a2;
1942  const POINT2D *a3;
1943 
1944  if ( pts->npoints % 2 != 1 )
1945  lwerror("arc point array with even number of points");
1946 
1947  a1 = getPoint2d_cp(pts, 0);
1948 
1949  for ( i=2; i < pts->npoints; i += 2 )
1950  {
1951  a2 = getPoint2d_cp(pts, i-1);
1952  a3 = getPoint2d_cp(pts, i);
1953  dist += lw_arc_length(a1, a2, a3);
1954  a1 = a3;
1955  }
1956  return dist;
1957 }
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
Definition: lwalgorithm.c:134
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
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
uint32_t npoints
Definition: liblwgeom.h:427

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

Referenced by lwcircstring_length_2d().

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