PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ lwgeom_area()

double lwgeom_area ( const LWGEOM geom)

Definition at line 1798 of file lwgeom.c.

References area(), CURVEPOLYTYPE, LWCOLLECTION::geoms, lwcurvepoly_area(), lwgeom_is_collection(), lwpoly_area(), lwtriangle_area(), LWCOLLECTION::ngeoms, POLYGONTYPE, TRIANGLETYPE, ovdump::type, and LWGEOM::type.

Referenced by LWGEOM_area_polygon(), lwmpoly_to_points(), test_lwpoly_construct_circle(), and test_misc_area().

1799 {
1800  int type = geom->type;
1801 
1802  if ( type == POLYGONTYPE )
1803  return lwpoly_area((LWPOLY*)geom);
1804  else if ( type == CURVEPOLYTYPE )
1805  return lwcurvepoly_area((LWCURVEPOLY*)geom);
1806  else if (type == TRIANGLETYPE )
1807  return lwtriangle_area((LWTRIANGLE*)geom);
1808  else if ( lwgeom_is_collection(geom) )
1809  {
1810  double area = 0.0;
1811  uint32_t i;
1812  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1813  for ( i = 0; i < col->ngeoms; i++ )
1814  area += lwgeom_area(col->geoms[i]);
1815  return area;
1816  }
1817  else
1818  return 0.0;
1819 }
#define POLYGONTYPE
Definition: liblwgeom.h:86
Datum area(PG_FUNCTION_ARGS)
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define TRIANGLETYPE
Definition: liblwgeom.h:97
double lwtriangle_area(const LWTRIANGLE *triangle)
Find the area of the outer ring.
Definition: lwtriangle.c:178
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1798
LWGEOM ** geoms
Definition: liblwgeom.h:511
double lwpoly_area(const LWPOLY *poly)
Find the area of the outer ring - sum (area of inner rings).
Definition: lwpoly.c:434
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1069
uint8_t type
Definition: liblwgeom.h:398
type
Definition: ovdump.py:41
double lwcurvepoly_area(const LWCURVEPOLY *curvepoly)
This should be rewritten to make use of the curve itself.
Definition: lwcurvepoly.c:133
Here is the call graph for this function:
Here is the caller graph for this function: