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

Definition at line 1850 of file lwgeom.c.

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

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

1851 {
1852  int type = geom->type;
1853 
1854  if ( type == POLYGONTYPE )
1855  return lwpoly_area((LWPOLY*)geom);
1856  else if ( type == CURVEPOLYTYPE )
1857  return lwcurvepoly_area((LWCURVEPOLY*)geom);
1858  else if (type == TRIANGLETYPE )
1859  return lwtriangle_area((LWTRIANGLE*)geom);
1860  else if ( lwgeom_is_collection(geom) )
1861  {
1862  double area = 0.0;
1863  uint32_t i;
1864  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1865  for ( i = 0; i < col->ngeoms; i++ )
1866  area += lwgeom_area(col->geoms[i]);
1867  return area;
1868  }
1869  else
1870  return 0.0;
1871 }
#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:185
uint32_t ngeoms
Definition: liblwgeom.h:506
unsigned int uint32_t
Definition: uthash.h:78
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1850
LWGEOM ** geoms
Definition: liblwgeom.h:508
double lwpoly_area(const LWPOLY *poly)
Find the area of the outer ring - sum (area of inner rings).
Definition: lwpoly.c:439
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
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: