PostGIS  2.2.7dev-r@@SVN_REVISION@@
double lwgeom_perimeter ( const LWGEOM geom)

Definition at line 1602 of file lwgeom.c.

References CURVEPOLYTYPE, LWCOLLECTION::geoms, lwcurvepoly_perimeter(), lwgeom_is_collection(), lwpoly_perimeter(), lwtriangle_perimeter(), LWCOLLECTION::ngeoms, POLYGONTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by LWGEOM_perimeter_poly().

1603 {
1604  int type = geom->type;
1605  if ( type == POLYGONTYPE )
1606  return lwpoly_perimeter((LWPOLY*)geom);
1607  else if ( type == CURVEPOLYTYPE )
1608  return lwcurvepoly_perimeter((LWCURVEPOLY*)geom);
1609  else if ( type == TRIANGLETYPE )
1610  return lwtriangle_perimeter((LWTRIANGLE*)geom);
1611  else if ( lwgeom_is_collection(geom) )
1612  {
1613  double perimeter = 0.0;
1614  int i;
1615  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1616  for ( i = 0; i < col->ngeoms; i++ )
1617  perimeter += lwgeom_perimeter(col->geoms[i]);
1618  return perimeter;
1619  }
1620  else
1621  return 0.0;
1622 }
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define TRIANGLETYPE
Definition: liblwgeom.h:83
double lwtriangle_perimeter(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:196
double lwgeom_perimeter(const LWGEOM *geom)
Definition: lwgeom.c:1602
LWGEOM ** geoms
Definition: liblwgeom.h:493
double lwpoly_perimeter(const LWPOLY *poly)
Compute the sum of polygon rings length.
Definition: lwpoly.c:444
double lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:134
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:991
uint8_t type
Definition: liblwgeom.h:380

Here is the call graph for this function:

Here is the caller graph for this function: