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

Find the area of the outer ring.

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

174 {
175  double area=0.0;
176  int i;
177  POINT2D p1;
178  POINT2D p2;
179 
180  if (! triangle->points->npoints) return area; /* empty triangle */
181 
182  for (i=0; i < triangle->points->npoints-1; i++)
183  {
184  getPoint2d_p(triangle->points, i, &p1);
185  getPoint2d_p(triangle->points, i+1, &p2);
186  area += ( p1.x * p2.y ) - ( p1.y * p2.x );
187  }
188 
189  area /= 2.0;
190 
191  return fabs(area);
192 }
POINTARRAY * points
Definition: liblwgeom.h:417
int npoints
Definition: liblwgeom.h:355
Datum area(PG_FUNCTION_ARGS)
double x
Definition: liblwgeom.h:312
double y
Definition: liblwgeom.h:312
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:448

Here is the call graph for this function:

Here is the caller graph for this function: