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

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

1874 {
1875  int type = geom->type;
1876  if ( type == POLYGONTYPE )
1877  return lwpoly_perimeter((LWPOLY*)geom);
1878  else if ( type == CURVEPOLYTYPE )
1879  return lwcurvepoly_perimeter((LWCURVEPOLY*)geom);
1880  else if ( type == TRIANGLETYPE )
1881  return lwtriangle_perimeter((LWTRIANGLE*)geom);
1882  else if ( lwgeom_is_collection(geom) )
1883  {
1884  double perimeter = 0.0;
1885  uint32_t i;
1886  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1887  for ( i = 0; i < col->ngeoms; i++ )
1888  perimeter += lwgeom_perimeter(col->geoms[i]);
1889  return perimeter;
1890  }
1891  else
1892  return 0.0;
1893 }
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define TRIANGLETYPE
Definition: liblwgeom.h:97
uint32_t ngeoms
Definition: liblwgeom.h:506
double lwtriangle_perimeter(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:208
unsigned int uint32_t
Definition: uthash.h:78
double lwgeom_perimeter(const LWGEOM *geom)
Definition: lwgeom.c:1873
LWGEOM ** geoms
Definition: liblwgeom.h:508
double lwpoly_perimeter(const LWPOLY *poly)
Compute the sum of polygon rings length.
Definition: lwpoly.c:472
double lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:147
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1078
uint8_t type
Definition: liblwgeom.h:395

Here is the call graph for this function:

Here is the caller graph for this function: