[GRASS-SVN] r52740 - grass/branches/develbranch_6/raster/r.cost
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Aug 19 15:57:54 PDT 2012
Author: neteler
Date: 2012-08-19 15:57:53 -0700 (Sun, 19 Aug 2012)
New Revision: 52740
Modified:
grass/branches/develbranch_6/raster/r.cost/main.c
Log:
Attempt to trap negative costs (fix for #545)
Modified: grass/branches/develbranch_6/raster/r.cost/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.cost/main.c 2012-08-19 22:42:18 UTC (rev 52739)
+++ grass/branches/develbranch_6/raster/r.cost/main.c 2012-08-19 22:57:53 UTC (rev 52740)
@@ -456,6 +456,11 @@
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;
}
segment_put(&in_seg, &p, row, i);
@@ -468,6 +473,11 @@
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;
}
segment_put(&in_seg, &p, row, i);
@@ -481,6 +491,11 @@
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;
}
segment_put(&in_seg, &p, row, i);
More information about the grass-commit
mailing list