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

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

1638 {
1639  int type = geom->type;
1640  if ( type == POLYGONTYPE )
1641  return lwpoly_perimeter_2d((LWPOLY*)geom);
1642  else if ( type == CURVEPOLYTYPE )
1643  return lwcurvepoly_perimeter_2d((LWCURVEPOLY*)geom);
1644  else if ( type == TRIANGLETYPE )
1645  return lwtriangle_perimeter_2d((LWTRIANGLE*)geom);
1646  else if ( lwgeom_is_collection(geom) )
1647  {
1648  double perimeter = 0.0;
1649  int i;
1650  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1651  for ( i = 0; i < col->ngeoms; i++ )
1652  perimeter += lwgeom_perimeter_2d(col->geoms[i]);
1653  return perimeter;
1654  }
1655  else
1656  return 0.0;
1657 }
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
double lwtriangle_perimeter_2d(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:218
#define TRIANGLETYPE
Definition: liblwgeom.h:97
double lwgeom_perimeter_2d(const LWGEOM *geom)
Definition: lwgeom.c:1637
LWGEOM ** geoms
Definition: liblwgeom.h:508
double lwcurvepoly_perimeter_2d(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:159
double lwpoly_perimeter_2d(const LWPOLY *poly)
Compute the sum of polygon rings length (forcing 2d computation).
Definition: lwpoly.c:533
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1004
uint8_t type
Definition: liblwgeom.h:395

Here is the call graph for this function:

Here is the caller graph for this function: