PostGIS  2.1.10dev-r@@SVN_REVISION@@
double lwgeom_length_2d ( const LWGEOM geom)

Definition at line 1588 of file lwgeom.c.

References CIRCSTRINGTYPE, COMPOUNDTYPE, LWCOLLECTION::geoms, LINETYPE, lwcircstring_length_2d(), lwcompound_length_2d(), lwgeom_is_collection(), lwline_length_2d(), LWCOLLECTION::ngeoms, and LWGEOM::type.

Referenced by lwcompound_length_2d(), lwcurvepoly_perimeter_2d(), and LWGEOM_length2d_linestring().

1589 {
1590  int type = geom->type;
1591  if ( type == LINETYPE )
1592  return lwline_length_2d((LWLINE*)geom);
1593  else if ( type == CIRCSTRINGTYPE )
1594  return lwcircstring_length_2d((LWCIRCSTRING*)geom);
1595  else if ( type == COMPOUNDTYPE )
1596  return lwcompound_length_2d((LWCOMPOUND*)geom);
1597  else if ( lwgeom_is_collection(geom) )
1598  {
1599  double length = 0.0;
1600  int i;
1601  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1602  for ( i = 0; i < col->ngeoms; i++ )
1603  length += lwgeom_length_2d(col->geoms[i]);
1604  return length;
1605  }
1606  else
1607  return 0.0;
1608 }
#define LINETYPE
Definition: liblwgeom.h:61
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
double lwcircstring_length_2d(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:275
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:503
double lwcompound_length_2d(const LWCOMPOUND *comp)
Definition: lwcompound.c:61
LWGEOM ** geoms
Definition: liblwgeom.h:465
double lwgeom_length_2d(const LWGEOM *geom)
Definition: lwgeom.c:1588
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:947
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67

Here is the call graph for this function:

Here is the caller graph for this function: