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

Definition at line 1668 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 gserialized_distance_nd(), lwcompound_length_2d(), lwcurvepoly_perimeter_2d(), and LWGEOM_length2d_linestring().

1669 {
1670  int type = geom->type;
1671  if ( type == LINETYPE )
1672  return lwline_length_2d((LWLINE*)geom);
1673  else if ( type == CIRCSTRINGTYPE )
1674  return lwcircstring_length_2d((LWCIRCSTRING*)geom);
1675  else if ( type == COMPOUNDTYPE )
1676  return lwcompound_length_2d((LWCOMPOUND*)geom);
1677  else if ( lwgeom_is_collection(geom) )
1678  {
1679  double length = 0.0;
1680  int i;
1681  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1682  for ( i = 0; i < col->ngeoms; i++ )
1683  length += lwgeom_length_2d(col->geoms[i]);
1684  return length;
1685  }
1686  else
1687  return 0.0;
1688 }
#define LINETYPE
Definition: liblwgeom.h:71
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
double lwcircstring_length_2d(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:275
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:557
double lwcompound_length_2d(const LWCOMPOUND *comp)
Definition: lwcompound.c:61
LWGEOM ** geoms
Definition: liblwgeom.h:493
double lwgeom_length_2d(const LWGEOM *geom)
Definition: lwgeom.c:1668
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:991
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77

Here is the call graph for this function:

Here is the caller graph for this function: