PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_perimeter()

double lwgeom_perimeter ( const LWGEOM geom)

Definition at line 1646 of file lwgeom.c.

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

Referenced by LWGEOM_perimeter_poly().

1647 {
1648  int type = geom->type;
1649  if ( type == POLYGONTYPE )
1650  return lwpoly_perimeter((LWPOLY*)geom);
1651  else if ( type == CURVEPOLYTYPE )
1652  return lwcurvepoly_perimeter((LWCURVEPOLY*)geom);
1653  else if ( type == TRIANGLETYPE )
1654  return lwtriangle_perimeter((LWTRIANGLE*)geom);
1655  else if ( lwgeom_is_collection(geom) )
1656  {
1657  double perimeter = 0.0;
1658  int i;
1659  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1660  for ( i = 0; i < col->ngeoms; i++ )
1661  perimeter += lwgeom_perimeter(col->geoms[i]);
1662  return perimeter;
1663  }
1664  else
1665  return 0.0;
1666 }
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define TRIANGLETYPE
Definition: liblwgeom.h:98
double lwtriangle_perimeter(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:215
double lwgeom_perimeter(const LWGEOM *geom)
Definition: lwgeom.c:1646
LWGEOM ** geoms
Definition: liblwgeom.h:509
double lwpoly_perimeter(const LWPOLY *poly)
Compute the sum of polygon rings length.
Definition: lwpoly.c:557
double lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:148
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
Here is the call graph for this function:
Here is the caller graph for this function: