PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwgeom_length()

double lwgeom_length ( const LWGEOM geom)

Definition at line 1930 of file lwgeom.c.

1931 {
1932  int type = geom->type;
1933  if ( type == LINETYPE )
1934  return lwline_length((LWLINE*)geom);
1935  else if ( type == CIRCSTRINGTYPE )
1936  return lwcircstring_length((LWCIRCSTRING*)geom);
1937  else if ( type == COMPOUNDTYPE )
1938  return lwcompound_length((LWCOMPOUND*)geom);
1939  else if ( lwgeom_is_collection(geom) )
1940  {
1941  double length = 0.0;
1942  uint32_t i;
1943  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1944  for ( i = 0; i < col->ngeoms; i++ )
1945  length += lwgeom_length(col->geoms[i]);
1946  return length;
1947  }
1948  else
1949  return 0.0;
1950 }
#define COMPOUNDTYPE
Definition: liblwgeom.h:124
#define LINETYPE
Definition: liblwgeom.h:117
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:123
double lwcompound_length(const LWCOMPOUND *comp)
Definition: lwcompound.c:69
double lwline_length(const LWLINE *line)
Definition: lwline.c:510
double lwcircstring_length(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:269
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1079
double lwgeom_length(const LWGEOM *geom)
Definition: lwgeom.c:1930
type
Definition: ovdump.py:42
uint32_t ngeoms
Definition: liblwgeom.h:566
LWGEOM ** geoms
Definition: liblwgeom.h:561
uint8_t type
Definition: liblwgeom.h:448

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

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

Here is the call graph for this function:
Here is the caller graph for this function: