PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_length()

double lwgeom_length ( const LWGEOM geom)

Definition at line 1690 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().

1691 {
1692  int type = geom->type;
1693  if ( type == LINETYPE )
1694  return lwline_length((LWLINE*)geom);
1695  else if ( type == CIRCSTRINGTYPE )
1696  return lwcircstring_length((LWCIRCSTRING*)geom);
1697  else if ( type == COMPOUNDTYPE )
1698  return lwcompound_length((LWCOMPOUND*)geom);
1699  else if ( lwgeom_is_collection(geom) )
1700  {
1701  double length = 0.0;
1702  int i;
1703  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1704  for ( i = 0; i < col->ngeoms; i++ )
1705  length += lwgeom_length(col->geoms[i]);
1706  return length;
1707  }
1708  else
1709  return 0.0;
1710 }
#define LINETYPE
Definition: liblwgeom.h:86
double lwcircstring_length(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:283
double lwgeom_length(const LWGEOM *geom)
Definition: lwgeom.c:1690
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
LWGEOM ** geoms
Definition: liblwgeom.h:509
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:1040
double lwline_length(const LWLINE *line)
Definition: lwline.c:579
uint8_t type
Definition: liblwgeom.h:396
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
Here is the call graph for this function:
Here is the caller graph for this function: