PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_area()

double lwgeom_area ( const LWGEOM geom)

Definition at line 1623 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().

1624 {
1625  int type = geom->type;
1626 
1627  if ( type == POLYGONTYPE )
1628  return lwpoly_area((LWPOLY*)geom);
1629  else if ( type == CURVEPOLYTYPE )
1630  return lwcurvepoly_area((LWCURVEPOLY*)geom);
1631  else if (type == TRIANGLETYPE )
1632  return lwtriangle_area((LWTRIANGLE*)geom);
1633  else if ( lwgeom_is_collection(geom) )
1634  {
1635  double area = 0.0;
1636  int i;
1637  LWCOLLECTION *col = (LWCOLLECTION*)geom;
1638  for ( i = 0; i < col->ngeoms; i++ )
1639  area += lwgeom_area(col->geoms[i]);
1640  return area;
1641  }
1642  else
1643  return 0.0;
1644 }
#define POLYGONTYPE
Definition: liblwgeom.h:87
Datum area(PG_FUNCTION_ARGS)
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define TRIANGLETYPE
Definition: liblwgeom.h:98
double lwtriangle_area(const LWTRIANGLE *triangle)
Find the area of the outer ring.
Definition: lwtriangle.c:192
double lwgeom_area(const LWGEOM *geom)
Definition: lwgeom.c:1623
LWGEOM ** geoms
Definition: liblwgeom.h:509
double lwpoly_area(const LWPOLY *poly)
Find the area of the outer ring - sum (area of inner rings).
Definition: lwpoly.c:524
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1040
uint8_t type
Definition: liblwgeom.h:396
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:134
Here is the call graph for this function:
Here is the caller graph for this function: