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

Definition at line 1917 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 gserialized_distance_nd(), lwcurvepoly_perimeter(), and LWGEOM_length_linestring().

1918 {
1919  int type = geom->type;
1920  if ( type == LINETYPE )
1921  return lwline_length((LWLINE*)geom);
1922  else if ( type == CIRCSTRINGTYPE )
1923  return lwcircstring_length((LWCIRCSTRING*)geom);
1924  else if ( type == COMPOUNDTYPE )
1925  return lwcompound_length((LWCOMPOUND*)geom);
1926  else if ( lwgeom_is_collection(geom) )
1927  {
1928  double length = 0.0;
1929  uint32_t i;
1930  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1931  for ( i = 0; i < col->ngeoms; i++ )
1932  length += lwgeom_length(col->geoms[i]);
1933  return length;
1934  }
1935  else
1936  return 0.0;
1937 }
#define LINETYPE
Definition: liblwgeom.h:85
double lwcircstring_length(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:276
double lwgeom_length(const LWGEOM *geom)
Definition: lwgeom.c:1917
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
uint32_t ngeoms
Definition: liblwgeom.h:506
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:508
double lwcompound_length(const LWCOMPOUND *comp)
Definition: lwcompound.c:69
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1078
double lwline_length(const LWLINE *line)
Definition: lwline.c:527
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91

Here is the call graph for this function:

Here is the caller graph for this function: