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

Definition at line 1566 of file lwgeom.c.

References CIRCSTRINGTYPE, COMPOUNDTYPE, LWCOLLECTION::geoms, LINETYPE, lwcircstring_length(), lwcompound_length(), lwgeom_is_collection(), lwline_length(), LWCOLLECTION::ngeoms, and LWGEOM::type.

Referenced by lwcurvepoly_perimeter(), and LWGEOM_length_linestring().

1567 {
1568  int type = geom->type;
1569  if ( type == LINETYPE )
1570  return lwline_length((LWLINE*)geom);
1571  else if ( type == CIRCSTRINGTYPE )
1572  return lwcircstring_length((LWCIRCSTRING*)geom);
1573  else if ( type == COMPOUNDTYPE )
1574  return lwcompound_length((LWCOMPOUND*)geom);
1575  else if ( lwgeom_is_collection(geom) )
1576  {
1577  double length = 0.0;
1578  int i;
1579  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1580  for ( i = 0; i < col->ngeoms; i++ )
1581  length += lwgeom_length(col->geoms[i]);
1582  return length;
1583  }
1584  else
1585  return 0.0;
1586 }
#define LINETYPE
Definition: liblwgeom.h:61
double lwcircstring_length(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:270
double lwgeom_length(const LWGEOM *geom)
Definition: lwgeom.c:1566
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
LWGEOM ** geoms
Definition: liblwgeom.h:465
double lwcompound_length(const LWCOMPOUND *comp)
Definition: lwcompound.c:56
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:947
double lwline_length(const LWLINE *line)
Definition: lwline.c:496
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: