[GRASS-SVN] r52748 - grass/branches/releasebranch_6_4/raster/r.cost

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 20 00:55:11 PDT 2012


Author: mmetz
Date: 2012-08-20 00:55:10 -0700 (Mon, 20 Aug 2012)
New Revision: 52748

Modified:
   grass/branches/releasebranch_6_4/raster/r.cost/main.c
Log:
r.cost fix for #545

Modified: grass/branches/releasebranch_6_4/raster/r.cost/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.cost/main.c	2012-08-20 07:54:55 UTC (rev 52747)
+++ grass/branches/releasebranch_6_4/raster/r.cost/main.c	2012-08-20 07:55:10 UTC (rev 52748)
@@ -415,6 +415,12 @@
 		    }
 		    else {
 			p = *(int *)ptr2;
+			if (p < 0) {
+			    G_warning(_("Negative cell value found at row %d, col %d. "
+			                "Setting negative value to null_cost value"),
+				      row, i);
+			    p = null_cost;
+			}
 		    }
 		    segment_put(&in_seg, &p, row, i);
 		    ptr2 = G_incr_void_ptr(ptr2, dsize);
@@ -427,6 +433,12 @@
 		    }
 		    else {
 			p = *(float *)ptr2;
+			if (p < 0) {
+			    G_warning(_("Negative cell value found at row %d, col %d. "
+			                "Setting negative value to null_cost value"),
+				      row, i);
+			    p = null_cost;
+			}
 		    }
 		    segment_put(&in_seg, &p, row, i);
 		    ptr2 = G_incr_void_ptr(ptr2, dsize);
@@ -440,6 +452,12 @@
 		    }
 		    else {
 			p = *(double *)ptr2;
+			if (p < 0) {
+			    G_warning(_("Negative cell value found at row %d, col %d. "
+			                "Setting negative value to null_cost value"),
+				      row, i);
+			    p = null_cost;
+			}
 		    }
 		    segment_put(&in_seg, &p, row, i);
 		    ptr2 = G_incr_void_ptr(ptr2, dsize);



More information about the grass-commit mailing list