PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ lwgeom_length_2d()

double lwgeom_length_2d ( const LWGEOM geom)

Definition at line 1997 of file lwgeom.c.

1998 {
1999  int type = geom->type;
2000  if ( type == LINETYPE )
2001  return lwline_length_2d((LWLINE*)geom);
2002  else if ( type == CIRCSTRINGTYPE )
2003  return lwcircstring_length_2d((LWCIRCSTRING*)geom);
2004  else if ( type == COMPOUNDTYPE )
2005  return lwcompound_length_2d((LWCOMPOUND*)geom);
2006  else if ( lwgeom_is_collection(geom) )
2007  {
2008  double length = 0.0;
2009  uint32_t i;
2010  LWCOLLECTION *col = (LWCOLLECTION*)geom;
2011  for ( i = 0; i < col->ngeoms; i++ )
2012  length += lwgeom_length_2d(col->geoms[i]);
2013  return length;
2014  }
2015  else
2016  return 0.0;
2017 }
#define COMPOUNDTYPE
Definition: liblwgeom.h:125
#define LINETYPE
Definition: liblwgeom.h:118
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:124
double lwline_length_2d(const LWLINE *line)
Definition: lwline.c:520
double lwcircstring_length_2d(const LWCIRCSTRING *circ)
Definition: lwcircstring.c:274
double lwcompound_length_2d(const LWCOMPOUND *comp)
Definition: lwcompound.c:74
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1097
double lwgeom_length_2d(const LWGEOM *geom)
Definition: lwgeom.c:1997
type
Definition: ovdump.py:42
uint32_t ngeoms
Definition: liblwgeom.h:595
LWGEOM ** geoms
Definition: liblwgeom.h:590
uint8_t type
Definition: liblwgeom.h:477

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

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

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