Skip to content

Commit

Permalink
fix issue when assigning max
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbourdon committed Jan 12, 2023
1 parent 28a724f commit 96d61af
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions whitebox-tools-app/src/tools/gis_analysis/reclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,29 @@ impl WhiteboxTool for Reclass {
}
}
}

let reclass_vals: Vec<f64> = v
.iter()
.map(|s| {
.enumerate()
.map(|(idx, s)| {
if s.to_lowercase().contains("min") {
min_val
} else if s.to_lowercase().contains("max") {
max_val + 0.1f64
// Trick in order to consider the max value as included
// in the last class instead of excluded like with the other classes
if !assign_mode && idx % 3 != 0 {
max_val + 1f64
} else {
max_val
}
} else if s.to_lowercase().contains("nodata") {
nodata
} else {
s.trim().parse().unwrap()
}
})
.collect();

if reclass_vals.len() % 3 != 0 && !assign_mode {
return Err(Error::new(ErrorKind::InvalidInput,
"The reclass values string must include triplet values (new value; from value; to less than), e.g. '0.0;0.0;1.0;1.0;1.0;2.0'"));
Expand Down

0 comments on commit 96d61af

Please sign in to comment.