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

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

Definition at line 482 of file lwpoly.c.

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

Referenced by lwcurvepoly_area(), lwgeom_area(), lwmpoly_to_points(), and lwpoly_to_points().

483 {
484  double poly_area = 0.0;
485  int i;
486 
487  if ( ! poly )
488  lwerror("lwpoly_area called with null polygon pointer!");
489 
490  for ( i=0; i < poly->nrings; i++ )
491  {
492  POINTARRAY *ring = poly->rings[i];
493  double ringarea = 0.0;
494 
495  /* Empty or messed-up ring. */
496  if ( ring->npoints < 3 )
497  continue;
498 
499  ringarea = fabs(ptarray_signed_area(ring));
500  if ( i == 0 ) /* Outer ring, positive area! */
501  poly_area += ringarea;
502  else /* Inner ring, negative area! */
503  poly_area -= ringarea;
504  }
505 
506  return poly_area;
507 }
int npoints
Definition: liblwgeom.h:370
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
Definition: ptarray.c:995
POINTARRAY ** rings
Definition: liblwgeom.h:456
int nrings
Definition: liblwgeom.h:454
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102

Here is the call graph for this function:

Here is the caller graph for this function: