PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_perimeter()

double lwgeom_perimeter ( const LWGEOM geom)

Definition at line 1895 of file lwgeom.c.

1896 {
1897  int type = geom->type;
1898  if ( type == POLYGONTYPE )
1899  return lwpoly_perimeter((LWPOLY*)geom);
1900  else if ( type == CURVEPOLYTYPE )
1901  return lwcurvepoly_perimeter((LWCURVEPOLY*)geom);
1902  else if ( type == TRIANGLETYPE )
1903  return lwtriangle_perimeter((LWTRIANGLE*)geom);
1904  else if ( lwgeom_is_collection(geom) )
1905  {
1906  double perimeter = 0.0;
1907  uint32_t i;
1908  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1909  for ( i = 0; i < col->ngeoms; i++ )
1910  perimeter += lwgeom_perimeter(col->geoms[i]);
1911  return perimeter;
1912  }
1913  else
1914  return 0.0;
1915 }
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define TRIANGLETYPE
Definition: liblwgeom.h:98
double lwtriangle_perimeter(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:208
double lwcurvepoly_perimeter(const LWCURVEPOLY *poly)
Definition: lwcurvepoly.c:148
double lwpoly_perimeter(const LWPOLY *poly)
Compute the sum of polygon rings length.
Definition: lwpoly.c:474
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1085
double lwgeom_perimeter(const LWGEOM *geom)
Definition: lwgeom.c:1895
type
Definition: ovdump.py:41
uint32_t ngeoms
Definition: liblwgeom.h:510
LWGEOM ** geoms
Definition: liblwgeom.h:512
uint8_t type
Definition: liblwgeom.h:399
unsigned int uint32_t
Definition: uthash.h:78

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

Referenced by lwgeom_perimeter(), and LWGEOM_perimeter_poly().

Here is the call graph for this function:
Here is the caller graph for this function: