PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_length_2d()

double lwgeom_length_2d ( const LWGEOM geom)

Definition at line 1712 of file lwgeom.c.

References CIRCSTRINGTYPE, COMPOUNDTYPE, LWCOLLECTION::geoms, LINETYPE, lwcircstring_length_2d(), lwcompound_length_2d(), lwgeom_is_collection(), lwline_length_2d(), LWCOLLECTION::ngeoms, ovdump::type, and LWGEOM::type.

Referenced by gserialized_distance_nd(), lwcompound_length_2d(), lwcurvepoly_perimeter_2d(), and LWGEOM_length2d_linestring().

1713 {
1714  int type = geom->type;
1715  if ( type == LINETYPE )
1716  return lwline_length_2d((LWLINE*)geom);
1717  else if ( type == CIRCSTRINGTYPE )
1718  return lwcircstring_length_2d((LWCIRCSTRING*)geom);
1719  else if ( type == COMPOUNDTYPE )
1720  return lwcompound_length_2d((LWCOMPOUND*)geom);
1721  else if ( lwgeom_is_collection(geom) )
1722  {
1723  double length = 0.0;
1724  int i;
1725  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1726  for ( i = 0; i < col->ngeoms; i++ )
1727  length += lwgeom_length_2d(col->geoms[i]);
1728  return length;
1729  }
1730  else
1731  return 0.0;
1732 }
#define LINETYPE
Definition: liblwgeom.h:86
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
double lwcircstring_length_2d(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:288
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:586
double lwcompound_length_2d(const LWCOMPOUND *comp)
Definition: lwcompound.c:74
LWGEOM ** geoms
Definition: liblwgeom.h:509
double lwgeom_length_2d(const LWGEOM *geom)
Definition: lwgeom.c:1712
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1040
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: