[GRASS-SVN] r69092 - grass-addons/grass7/raster/r.stream.segment

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 5 06:02:45 PDT 2016


Author: mmetz
Date: 2016-08-05 06:02:45 -0700 (Fri, 05 Aug 2016)
New Revision: 69092

Modified:
   grass-addons/grass7/raster/r.stream.segment/stream_vector.c
Log:
r.stream.segment: catch division by zero

Modified: grass-addons/grass7/raster/r.stream.segment/stream_vector.c
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/stream_vector.c	2016-08-05 12:51:10 UTC (rev 69091)
+++ grass-addons/grass7/raster/r.stream.segment/stream_vector.c	2016-08-05 13:02:45 UTC (rev 69092)
@@ -162,7 +162,8 @@
 		sprintf(buf2, "%g, ", stright);
 	    strcat(buf, buf2);
 
-	    if (Rast_is_d_null_value(&sinusoid))
+	    if (Rast_is_d_null_value(&sinusoid) || 
+	        Rast_is_d_null_value(&stright) || stright == 0)
 		sprintf(buf2, "null, ");
 	    else
 		sprintf(buf2, "%g, ", sinusoid);
@@ -186,7 +187,8 @@
 		sprintf(buf2, "%g, ", drop);
 	    strcat(buf, buf2);
 
-	    if (Rast_is_d_null_value(&gradient))
+	    if (Rast_is_d_null_value(&gradient) || 
+	        Rast_is_d_null_value(&length) || length <= 0)
 		sprintf(buf2, "null )");
 	    else
 		sprintf(buf2, "%g )", gradient);
@@ -400,7 +402,8 @@
 	    sprintf(buf2, "%g, ", stright);
 	strcat(buf, buf2);
 
-	if (Rast_is_d_null_value(&sinusoid))
+	if (Rast_is_d_null_value(&sinusoid) || 
+	    Rast_is_d_null_value(&stright) || stright == 0)
 	    sprintf(buf2, "null, ");
 	else
 	    sprintf(buf2, "%g, ", sinusoid);
@@ -424,7 +427,8 @@
 	    sprintf(buf2, "%g, ", drop);
 	strcat(buf, buf2);
 
-	if (Rast_is_d_null_value(&gradient))
+	if (Rast_is_d_null_value(&gradient) ||
+	    Rast_is_d_null_value(&length) || length <= 0)
 	    sprintf(buf2, "null, ");
 	else
 	    sprintf(buf2, "%g, ", gradient);
@@ -454,7 +458,8 @@
 	    sprintf(buf2, "%g, ", out_drop);
 	strcat(buf, buf2);
 
-	if (Rast_is_d_null_value(&out_gradient))
+	if (Rast_is_d_null_value(&out_gradient) ||
+	    Rast_is_d_null_value(&out_length) || out_length == 0)
 	    sprintf(buf2, "null, ");
 	else
 	    sprintf(buf2, "%g, ", out_gradient);



More information about the grass-commit mailing list