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

Definition at line 1499 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(), and test_misc_area().

1500 {
1501  int type = geom->type;
1502 
1503  if ( type == POLYGONTYPE )
1504  return lwpoly_area((LWPOLY*)geom);
1505  else if ( type == CURVEPOLYTYPE )
1506  return lwcurvepoly_area((LWCURVEPOLY*)geom);
1507  else if (type == TRIANGLETYPE )
1508  return lwtriangle_area((LWTRIANGLE*)geom);
1509  else if ( lwgeom_is_collection(geom) )
1510  {
1511  double area = 0.0;
1512  int i;
1513  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1514  for ( i = 0; i < col->ngeoms; i++ )
1515  area += lwgeom_area(col->geoms[i]);
1516  return area;
1517  }
1518  else
1519  return 0.0;
1520 }
#define POLYGONTYPE
Definition: liblwgeom.h:62
Datum area(PG_FUNCTION_ARGS)
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define TRIANGLETYPE
Definition: liblwgeom.h:73
double lwtriangle_area(const LWTRIANGLE *triangle)
Find the area of the outer ring.
Definition: lwtriangle.c:173
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1499
LWGEOM ** geoms
Definition: liblwgeom.h:465
double lwpoly_area(const LWPOLY *poly)
Find the area of the outer ring - sum (area of inner rings).
Definition: lwpoly.c:390
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:947
uint8_t type
Definition: liblwgeom.h:352
double lwcurvepoly_area(const LWCURVEPOLY *curvepoly)
This should be rewritten to make use of the curve itself.
Definition: lwcurvepoly.c:120

Here is the call graph for this function:

Here is the caller graph for this function: