PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ lwgeom_perimeter_2d()

double lwgeom_perimeter_2d ( const LWGEOM geom)

Definition at line 1902 of file lwgeom.c.

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

Referenced by LWGEOM_perimeter2d_poly().

1903 {
1904  int type = geom->type;
1905  if ( type == POLYGONTYPE )
1906  return lwpoly_perimeter_2d((LWPOLY*)geom);
1907  else if ( type == CURVEPOLYTYPE )
1908  return lwcurvepoly_perimeter_2d((LWCURVEPOLY*)geom);
1909  else if ( type == TRIANGLETYPE )
1910  return lwtriangle_perimeter_2d((LWTRIANGLE*)geom);
1911  else if ( lwgeom_is_collection(geom) )
1912  {
1913  double perimeter = 0.0;
1914  uint32_t i;
1915  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1916  for ( i = 0; i < col->ngeoms; i++ )
1917  perimeter += lwgeom_perimeter_2d(col->geoms[i]);
1918  return perimeter;
1919  }
1920  else
1921  return 0.0;
1922 }
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
double lwtriangle_perimeter_2d(const LWTRIANGLE *triangle)
Definition: lwtriangle.c:217
#define TRIANGLETYPE
Definition: liblwgeom.h:97
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
double lwgeom_perimeter_2d(const LWGEOM *geom)
Definition: lwgeom.c:1902
LWGEOM ** geoms
Definition: liblwgeom.h:511
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:492
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1085
uint8_t type
Definition: liblwgeom.h:398
type
Definition: ovdump.py:41
Here is the call graph for this function:
Here is the caller graph for this function: