17 #include <grass/gis.h>
20 #define TWOPI M_PI + M_PI
22 static double QA, QB, QC;
23 static double QbarA, QbarB, QbarC, QbarD;
32 static double Q(
double x)
39 return sinx * (1 + sinx2 * (QA + sinx2 * (QB + sinx2 * QC)));
42 static double Qbar(
double x)
49 return cosx * (QbarA + cosx2 * (QbarB + cosx2 * (QbarC + cosx2 * QbarD)));
72 AE = a * a * (1 - e2);
74 QA = (2.0 / 3.0) * e2;
75 QB = (3.0 / 5.0) * e4;
76 QC = (4.0 / 7.0) * e6;
78 QbarA = -1.0 - (2.0 / 3.0) * e2 - (3.0 / 5.0) * e4 - (4.0 / 7.0) * e6;
79 QbarB = (2.0 / 9.0) * e2 + (2.0 / 5.0) * e4 + (4.0 / 7.0) * e6;
80 QbarC = -(3.0 / 25.0) * e4 - (12.0 / 35.0) * e6;
81 QbarD = (4.0 / 49.0) * e6;
84 E = 4 * M_PI * Qp * AE;
139 double x1, y1, x2, y2, dx, dy;
159 while (x1 - x2 > M_PI)
162 while (x2 - x1 > M_PI)
166 area += dx * (Qp - Q(y2));
168 if ((dy = y2 - y1) != 0.0)
169 area += dx * Q(y2) - (dx / dy) * (Qbar2 - Qbar1);
171 if ((area *= AE) < 0.0)
int G_begin_ellipsoid_polygon_area(double a, double e2)
Begin area calculations.
double G_ellipsoid_polygon_area(const double *lon, const double *lat, int n)
Area of lat-long polygon.