PostGIS  2.3.7dev-r@@SVN_REVISION@@
double lwtriangle_area ( const LWTRIANGLE triangle)

Find the area of the outer ring.

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

187 {
188  double area=0.0;
189  int i;
190  POINT2D p1;
191  POINT2D p2;
192 
193  if (! triangle->points->npoints) return area; /* empty triangle */
194 
195  for (i=0; i < triangle->points->npoints-1; i++)
196  {
197  getPoint2d_p(triangle->points, i, &p1);
198  getPoint2d_p(triangle->points, i+1, &p2);
199  area += ( p1.x * p2.y ) - ( p1.y * p2.x );
200  }
201 
202  area /= 2.0;
203 
204  return fabs(area);
205 }
POINTARRAY * points
Definition: liblwgeom.h:432
int npoints
Definition: liblwgeom.h:370
Datum area(PG_FUNCTION_ARGS)
double x
Definition: liblwgeom.h:327
double y
Definition: liblwgeom.h:327
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:461

Here is the call graph for this function:

Here is the caller graph for this function: