[GRASS-SVN] r52747 - grass/branches/develbranch_6/raster/r.cost

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 20 00:54:56 PDT 2012


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

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

Modified: grass/branches/develbranch_6/raster/r.cost/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.cost/main.c	2012-08-20 07:51:43 UTC (rev 52746)
+++ grass/branches/develbranch_6/raster/r.cost/main.c	2012-08-20 07:54:55 UTC (rev 52747)
@@ -456,12 +456,13 @@
 			p = null_cost;
 		    }
 		    else {
-			if ( *(int *)ptr2 < 0 ) {
-			   G_warning(_("Negative cell value found at row %d. Setting negative value to null_cost value"), row);
-			} else {
-			   p = null_cost;
+			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;
 			}
-			p = *(int *)ptr2;
 		    }
 		    segment_put(&in_seg, &p, row, i);
 		    ptr2 = G_incr_void_ptr(ptr2, dsize);
@@ -473,12 +474,13 @@
 			p = null_cost;
 		    }
 		    else {
-			if ( *(float *)ptr2 < 0 ) {
-			   G_warning(_("Negative cell value found at row %d. Setting negative value to null_cost value"), row);
-			} else {
-			   p = null_cost;
+			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;
 			}
-			p = *(float *)ptr2;
 		    }
 		    segment_put(&in_seg, &p, row, i);
 		    ptr2 = G_incr_void_ptr(ptr2, dsize);
@@ -491,12 +493,13 @@
 			p = null_cost;
 		    }
 		    else {
-			if ( *(double *)ptr2 < 0 ) {
-			   G_warning(_("Negative cell value found at row %d. Setting negative value to null_cost value"), row);
-			} else {
-			   p = null_cost;
+			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;
 			}
-			p = *(double *)ptr2;
 		    }
 		    segment_put(&in_seg, &p, row, i);
 		    ptr2 = G_incr_void_ptr(ptr2, dsize);



More information about the grass-commit mailing list