PostGIS  2.1.10dev-r@@SVN_REVISION@@
double lwpoly_area ( const LWPOLY poly)

Find the area of the outer ring - sum (area of inner rings).

Definition at line 390 of file lwpoly.c.

References lwerror(), POINTARRAY::npoints, LWPOLY::nrings, ptarray_signed_area(), and LWPOLY::rings.

Referenced by lwcurvepoly_area(), and lwgeom_area().

391 {
392  double poly_area = 0.0;
393  int i;
394 
395  if ( ! poly )
396  lwerror("lwpoly_area called with null polygon pointer!");
397 
398  for ( i=0; i < poly->nrings; i++ )
399  {
400  POINTARRAY *ring = poly->rings[i];
401  double ringarea = 0.0;
402 
403  /* Empty or messed-up ring. */
404  if ( ring->npoints < 3 )
405  continue;
406 
407  ringarea = fabs(ptarray_signed_area(ring));
408  if ( i == 0 ) /* Outer ring, positive area! */
409  poly_area += ringarea;
410  else /* Inner ring, negative area! */
411  poly_area -= ringarea;
412  }
413 
414  return poly_area;
415 }
int npoints
Definition: liblwgeom.h:327
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
Definition: ptarray.c:959
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
POINTARRAY ** rings
Definition: liblwgeom.h:413
int nrings
Definition: liblwgeom.h:411

Here is the call graph for this function:

Here is the caller graph for this function: