[GRASS-SVN] r60412 - grass/trunk/raster/r.surf.area

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 22 07:41:24 PDT 2014


Author: hcho
Date: 2014-05-22 07:41:24 -0700 (Thu, 22 May 2014)
New Revision: 60412

Modified:
   grass/trunk/raster/r.surf.area/main.c
Log:
r.surf.area: Fix segmentation fault and nan report with a single row map

Modified: grass/trunk/raster/r.surf.area/main.c
===================================================================
--- grass/trunk/raster/r.surf.area/main.c	2014-05-22 13:44:29 UTC (rev 60411)
+++ grass/trunk/raster/r.surf.area/main.c	2014-05-22 14:41:24 UTC (rev 60412)
@@ -131,8 +131,10 @@
 	    top = bottom;
 	    G_percent(row, w.rows, 10);
 	}
+
 	/* Get last null row area */
-	add_null_area(top, &w, &nullarea);
+	if (w.rows > 1)
+	    add_null_area(top, &w, &nullarea);
     }
 
 
@@ -161,7 +163,9 @@
 	fprintf(stdout, "%s %f\n", _("Current region plan area:"),
 		conv_value(reg_area, units));
 	fprintf(stdout, "%s %f\n", _("Estimated region Surface Area:"),
-		conv_value(reg_area * estavg / flat_area, units));
+		flat_area > 0 ?
+			conv_value(reg_area * estavg / flat_area, units) :
+			0);
     }
 
     exit(EXIT_SUCCESS);



More information about the grass-commit mailing list