From b47fed5d82f555504c0fc71ca3b3bcf7c5abc6cc Mon Sep 17 00:00:00 2001 From: jfbourdon Date: Mon, 9 Jan 2023 23:27:40 -0500 Subject: [PATCH 1/2] check if dir fall in nodata --- .../tools/hydro_analysis/downslope_flowpath_length.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs b/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs index c70f6f90..cf26141f 100755 --- a/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs +++ b/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs @@ -360,15 +360,16 @@ impl WhiteboxTool for DownslopeFlowpathLength { // find its downslope neighbour dir = pntr.get_value(y, x); if dir > 0f64 && dir != nodata { - if dir > 128f64 || pntr_matches[dir as usize] == 999 { - return Err(Error::new(ErrorKind::InvalidInput, - "An unexpected value has been identified in the pointer image. This tool requires a pointer grid that has been created using either the D8 or Rho8 tools.")); - } - // move x and y accordingly + // move x and y accordingly c = pntr_matches[dir as usize]; x += dx[c]; y += dy[c]; + if dir > 128f64 || c == 999 || pntr.get_value(y, x) == nodata { + return Err(Error::new(ErrorKind::InvalidInput, + "An unexpected value has been identified in the pointer image. This tool requires a pointer grid that has been created using either the D8 or Rho8 tools.")); + } + dist += grid_lengths[c] * weights.get_value(y, x) as f64; if output.get_value(y, x) != -999f64 { From 4932efe8f3c1a7fc3a93841263c4f6f59308dbac Mon Sep 17 00:00:00 2001 From: jfbourdon Date: Tue, 10 Jan 2023 09:44:36 -0500 Subject: [PATCH 2/2] remove extra space --- .../src/tools/hydro_analysis/downslope_flowpath_length.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs b/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs index cf26141f..5a28a8c3 100755 --- a/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs +++ b/whitebox-tools-app/src/tools/hydro_analysis/downslope_flowpath_length.rs @@ -360,7 +360,7 @@ impl WhiteboxTool for DownslopeFlowpathLength { // find its downslope neighbour dir = pntr.get_value(y, x); if dir > 0f64 && dir != nodata { - // move x and y accordingly + // move x and y accordingly c = pntr_matches[dir as usize]; x += dx[c]; y += dy[c];