Browse Source

r.cost/r.walk: fix bug introduced in https://trac.osgeo.org/grass/changeset/54538

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54541 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 years ago
parent
commit
d5f38827ad
2 changed files with 11 additions and 1 deletions
  1. 6 1
      raster/r.cost/main.c
  2. 5 0
      raster/r.walk/main.c

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

@@ -674,13 +674,15 @@ int main(int argc, char *argv[])
 
 		    cellval = Rast_get_d_value(ptr2, data_type2);
 		    if (start_with_raster_vals == 1) {
+                        insert(cellval, row, col);
 			costs.cost_out = cellval;
 			costs.nearest = cellval;
 			segment_put(&cost_seg, &costs, row, col);
 		    }
 		    else {
 			value = &zero;
-                        costs.cost_out = *value;
+			insert(zero, row, col);
+			costs.cost_out = *value;
 			costs.nearest = cellval;
 			segment_put(&cost_seg, &costs, row, col);
 		    }
@@ -710,6 +712,7 @@ int main(int argc, char *argv[])
 	    if (top_start_pt->row < 0 || top_start_pt->row >= nrows
 		|| top_start_pt->col < 0 || top_start_pt->col >= ncols)
 		G_fatal_error(_("Specified starting location outside database window"));
+	    insert(zero, top_start_pt->row, top_start_pt->col);
 	    segment_get(&cost_seg, &costs, top_start_pt->row,
 			top_start_pt->col);
 
@@ -979,6 +982,7 @@ int main(int argc, char *argv[])
 		costs.cost_out = min_cost;
 		costs.nearest = nearest;
 		segment_put(&cost_seg, &costs, row, col);
+		insert(min_cost, row, col);
 		if (dir == TRUE) {
 		    segment_put(&dir_seg, &cur_dir, row, col);
 		}
@@ -988,6 +992,7 @@ int main(int argc, char *argv[])
 		costs.cost_out = min_cost;
 		costs.nearest = nearest;
 		segment_put(&cost_seg, &costs, row, col);
+		insert(min_cost, row, col);
 		if (dir == TRUE) {
 		    segment_put(&dir_seg, &cur_dir, row, col);
 		}

+ 5 - 0
raster/r.walk/main.c

@@ -870,11 +870,13 @@ int main(int argc, char *argv[])
 
 		    if (start_with_raster_vals == 1) {
 			cellval = Rast_get_d_value(ptr2, data_type2);
+			insert(cellval, row, col);
 			costs.cost_out = cellval;
 			segment_put(&cost_seg, &costs, row, col);
 		    }
 		    else {
 			value = &zero;
+			insert(zero, row, col);
 			costs.cost_out = *value;
 			segment_put(&cost_seg, &costs, row, col);
 		    }
@@ -905,6 +907,7 @@ int main(int argc, char *argv[])
 	    if (top_start_pt->row < 0 || top_start_pt->row >= nrows
 		|| top_start_pt->col < 0 || top_start_pt->col >= ncols)
 		G_fatal_error(_("Specified starting location outside database window"));
+	    insert(zero, top_start_pt->row, top_start_pt->col);
 	    segment_get(&cost_seg, &costs, top_start_pt->row,
 			top_start_pt->col);
 	    costs.cost_out = *value;
@@ -1372,12 +1375,14 @@ int main(int argc, char *argv[])
 	    if (Rast_is_d_null_value(&old_min_cost)) {
 		costs.cost_out = min_cost;
 		segment_put(&cost_seg, &costs, row, col);
+		insert(min_cost, row, col);
 		if (dir == 1)
 		    segment_put(&dir_seg, &cur_dir, row, col);
 	    }
 	    else if (old_min_cost > min_cost) {
 		costs.cost_out = min_cost;
 		segment_put(&cost_seg, &costs, row, col);
+		insert(min_cost, row, col);
 		if (dir == 1)
 		    segment_put(&dir_seg, &cur_dir, row, col);
 	    }