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

Definition at line 1624 of file lwgeom.c.

References CURVEPOLYTYPE, LWCOLLECTION::geoms, lwcurvepoly_perimeter_2d(), lwgeom_is_collection(), lwpoly_perimeter_2d(), lwtriangle_perimeter_2d(), LWCOLLECTION::ngeoms, POLYGONTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by LWGEOM_perimeter2d_poly().

1625 {
1626  int type = geom->type;
1627  if ( type == POLYGONTYPE )
1628  return lwpoly_perimeter_2d((LWPOLY*)geom);
1629  else if ( type == CURVEPOLYTYPE )
1630  return lwcurvepoly_perimeter_2d((LWCURVEPOLY*)geom);
1631  else if ( type == TRIANGLETYPE )
1632  return lwtriangle_perimeter_2d((LWTRIANGLE*)geom);
1633  else if ( lwgeom_is_collection(geom) )
1634  {
1635  double perimeter = 0.0;
1636  int i;
1637  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1638  for ( i = 0; i < col->ngeoms; i++ )
1639  perimeter += lwgeom_perimeter_2d(col->geoms[i]);
1640  return perimeter;
1641  }
1642  else
1643  return 0.0;
1644 }
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
double lwtriangle_perimeter_2d(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:205
#define TRIANGLETYPE
Definition: liblwgeom.h:83
double lwgeom_perimeter_2d(const LWGEOM *geom)
Definition: lwgeom.c:1624
LWGEOM ** geoms
Definition: liblwgeom.h:493
double lwcurvepoly_perimeter_2d(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:146
double lwpoly_perimeter_2d(const LWPOLY *poly)
Compute the sum of polygon rings length (forcing 2d computation).
Definition: lwpoly.c:462
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: