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

Definition at line 1544 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().

1545 {
1546  int type = geom->type;
1547  if ( type == POLYGONTYPE )
1548  return lwpoly_perimeter_2d((LWPOLY*)geom);
1549  else if ( type == CURVEPOLYTYPE )
1550  return lwcurvepoly_perimeter_2d((LWCURVEPOLY*)geom);
1551  else if ( type == TRIANGLETYPE )
1552  return lwtriangle_perimeter_2d((LWTRIANGLE*)geom);
1553  else if ( lwgeom_is_collection(geom) )
1554  {
1555  double perimeter = 0.0;
1556  int i;
1557  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1558  for ( i = 0; i < col->ngeoms; i++ )
1559  perimeter += lwgeom_perimeter_2d(col->geoms[i]);
1560  return perimeter;
1561  }
1562  else
1563  return 0.0;
1564 }
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
double lwtriangle_perimeter_2d(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:205
#define TRIANGLETYPE
Definition: liblwgeom.h:73
double lwgeom_perimeter_2d(const LWGEOM *geom)
Definition: lwgeom.c:1544
LWGEOM ** geoms
Definition: liblwgeom.h:465
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:441
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:947
uint8_t type
Definition: liblwgeom.h:352

Here is the call graph for this function:

Here is the caller graph for this function: