PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwtriangle_area()

double lwtriangle_area ( const LWTRIANGLE triangle)

Find the area of the outer ring.

Definition at line 192 of file lwtriangle.c.

References area(), getPoint2d_p(), POINTARRAY::npoints, rect_node::p1, rect_node::p2, LWTRIANGLE::points, POINT2D::x, and POINT2D::y.

Referenced by lwgeom_area().

193 {
194  double area=0.0;
195  int i;
196  POINT2D p1;
197  POINT2D p2;
198 
199  if (! triangle->points->npoints) return area; /* empty triangle */
200 
201  for (i=0; i < triangle->points->npoints-1; i++)
202  {
203  getPoint2d_p(triangle->points, i, &p1);
204  getPoint2d_p(triangle->points, i+1, &p2);
205  area += ( p1.x * p2.y ) - ( p1.y * p2.x );
206  }
207 
208  area /= 2.0;
209 
210  return fabs(area);
211 }
POINTARRAY * points
Definition: liblwgeom.h:433
int npoints
Definition: liblwgeom.h:371
Datum area(PG_FUNCTION_ARGS)
double x
Definition: liblwgeom.h:328
double y
Definition: liblwgeom.h:328
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:347
Here is the call graph for this function:
Here is the caller graph for this function: