PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_length()

double lwgeom_length ( const LWGEOM geom)

Definition at line 1646 of file lwgeom.c.

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

Referenced by gserialized_distance_nd(), lwcurvepoly_perimeter(), and LWGEOM_length_linestring().

1647 {
1648  int type = geom->type;
1649  if ( type == LINETYPE )
1650  return lwline_length((LWLINE*)geom);
1651  else if ( type == CIRCSTRINGTYPE )
1652  return lwcircstring_length((LWCIRCSTRING*)geom);
1653  else if ( type == COMPOUNDTYPE )
1654  return lwcompound_length((LWCOMPOUND*)geom);
1655  else if ( lwgeom_is_collection(geom) )
1656  {
1657  double length = 0.0;
1658  int i;
1659  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1660  for ( i = 0; i < col->ngeoms; i++ )
1661  length += lwgeom_length(col->geoms[i]);
1662  return length;
1663  }
1664  else
1665  return 0.0;
1666 }
#define LINETYPE
Definition: liblwgeom.h:71
double lwcircstring_length(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:270
double lwgeom_length(const LWGEOM *geom)
Definition: lwgeom.c:1646
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:493
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:991
double lwline_length(const LWLINE *line)
Definition: lwline.c:550
uint8_t type
Definition: liblwgeom.h:380
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
Here is the call graph for this function:
Here is the caller graph for this function: