PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lwpoly_area()

double lwpoly_area ( const LWPOLY poly)

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

Definition at line 433 of file lwpoly.c.

434 {
435  double poly_area = 0.0;
436  uint32_t i;
437 
438  if ( ! poly )
439  lwerror("lwpoly_area called with null polygon pointer!");
440 
441  for ( i=0; i < poly->nrings; i++ )
442  {
443  POINTARRAY *ring = poly->rings[i];
444  double ringarea = 0.0;
445 
446  /* Empty or messed-up ring. */
447  if ( ring->npoints < 3 )
448  continue;
449 
450  ringarea = fabs(ptarray_signed_area(ring));
451  if ( i == 0 ) /* Outer ring, positive area! */
452  poly_area += ringarea;
453  else /* Inner ring, negative area! */
454  poly_area -= ringarea;
455  }
456 
457  return poly_area;
458 }
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
Definition: ptarray.c:1143
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint32_t nrings
Definition: liblwgeom.h:524
uint32_t npoints
Definition: liblwgeom.h:427

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().

Here is the call graph for this function:
Here is the caller graph for this function: