[GRASS-SVN] r71259 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 12 13:01:50 PDT 2017


Author: mmetz
Date: 2017-07-12 13:01:50 -0700 (Wed, 12 Jul 2017)
New Revision: 71259

Modified:
   grass/trunk/lib/gis/area_poly1.c
Log:
libgis: stabilize G_ellipsoid_polygon_area()

Modified: grass/trunk/lib/gis/area_poly1.c
===================================================================
--- grass/trunk/lib/gis/area_poly1.c	2017-07-12 03:33:57 UTC (rev 71258)
+++ grass/trunk/lib/gis/area_poly1.c	2017-07-12 20:01:50 UTC (rev 71259)
@@ -156,8 +156,8 @@
 		x1 += TWOPI;
 
 	dx = x2 - x1;
+	dy = y2 - y1;
 
-	dy = y2 - y1;
 	if (fabs(dy) > thresh) {
 	    /* account for different latitudes y1, y2 */
 	    area += dx * (st->Qp - (Qbar2 - Qbar1) / dy);
@@ -173,7 +173,7 @@
 	     * (Qbar2 - Qbar1) / dy should approach Q((y1 + y2) / 2)
 	     * Metz 2017
 	     */
-	    area += dx * (st->Qp - Q(y2));
+	    area += dx * (st->Qp - Q((y1 + y2) / 2));
 	}
     }
     if ((area *= st->AE) < 0.0)



More information about the grass-commit mailing list