浏览代码

r.cost fix for https://trac.osgeo.org/grass/ticket/545

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52746 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 年之前
父节点
当前提交
3e75f69d56
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      raster/r.cost/main.c

+ 7 - 1
raster/r.cost/main.c

@@ -474,6 +474,12 @@ int main(int argc, char *argv[])
 			break;
 			break;
 		    }
 		    }
 		}
 		}
+		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;
+		}
 		costs.cost_in = p;
 		costs.cost_in = p;
 		segment_put(&cost_seg, &costs, row, i);
 		segment_put(&cost_seg, &costs, row, i);
 		ptr2 = G_incr_void_ptr(ptr2, dsize);
 		ptr2 = G_incr_void_ptr(ptr2, dsize);
@@ -632,7 +638,7 @@ int main(int argc, char *argv[])
 	Vect_close(&In);
 	Vect_close(&In);
 
 
 	if (!have_stop_points)
 	if (!have_stop_points)
-	    G_warning(_("No stop points found in vector <%s>"), opt7->answer);
+	    G_warning(_("No stop points found in vector <%s>"), opt8->answer);
     }
     }
 
 
     /* read raster with start points */
     /* read raster with start points */