PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwtriangle_area()

double lwtriangle_area ( const LWTRIANGLE triangle)

Find the area of the outer ring.

Definition at line 178 of file lwtriangle.c.

179{
180 double area=0.0;
181 uint32_t i;
182 POINT2D p1;
183 POINT2D p2;
184
185 if (! triangle->points->npoints) return area; /* empty triangle */
186
187 for (i=0; i < triangle->points->npoints-1; i++)
188 {
189 getPoint2d_p(triangle->points, i, &p1);
190 getPoint2d_p(triangle->points, i+1, &p2);
191 area += ( p1.x * p2.y ) - ( p1.y * p2.x );
192 }
193
194 area /= 2.0;
195
196 return fabs(area);
197}
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition lwgeom_api.c:342
POINTARRAY * points
Definition liblwgeom.h:495
double y
Definition liblwgeom.h:390
double x
Definition liblwgeom.h:390
uint32_t npoints
Definition liblwgeom.h:427

References getPoint2d_p(), POINTARRAY::npoints, LWTRIANGLE::points, POINT2D::x, and POINT2D::y.

Referenced by lwgeom_area().

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