Skip to content

Commit

Permalink
Far-reaching change to how Boolean parameters are handled
Browse files Browse the repository at this point in the history
This is a far-reaching change to how Boolean parameters are handled. Boolean type tool parameters previously worked simply by the presence of the parameter flag. This was causing problems with some WBT front-ends, particularly QGIS, where the parameters
  were being provided to WBT as --flag=False. In this case, because the flag was present, it was assumed to be True. All tools that have boolean parameters have been updated to handle the case of --flag=False. This is a widespread modification that should fix the unexpected behaviour of many tools in certain front-ends.
  • Loading branch information
jblindsay committed Oct 18, 2019
1 parent 62d99f0 commit d9eb35e
Show file tree
Hide file tree
Showing 97 changed files with 530 additions and 266 deletions.
Binary file modified .DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ for more details.

Version 1.0.1 (XX-XX-2019)
- Fixed a minor bug with the VectorPolygonToRaster tool.
- Fixed a bug in the DownstreamDistanceToStream tool.
- Boolean type tool parameters previously worked simply by the presence of the parameter flag.
This was causing problems with some WBT front-ends, particularly QGIS, where the parameters
were being provided to WBT as --flag=False. In this case, because the flag was present, it
was assumed to be True. All tools that have boolean parameters have been updated to handle
the case of --flag=False. This is a widespread modification that should fix the unexpected
behaviour of many tools in certain front-ends.

Version 1.0.0 (29-09-2019)
- Added support for reading and writing the BigTIFF format. This has resulted in numerous changes
Expand Down
6 changes: 4 additions & 2 deletions src/tools/data_tools/export_table_to_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 24/04/2018
Last Modified: 12/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -163,7 +163,9 @@ impl WhiteboxTool for ExportTableToCsv {
args[i + 1].to_string()
};
} else if flag_val == "-headers" {
headers = true;
if !vec[1].to_string().to_lowercase().contains("false") {
headers = true;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/data_tools/multipart_to_singlepart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 27/09/2018
Last Modified: 12/10/2018
Last Modified: 17/10/2019
License: MIT
*/

Expand Down Expand Up @@ -172,7 +172,9 @@ impl WhiteboxTool for MultiPartToSinglePart {
args[i + 1].to_string()
};
} else if flag_val.contains("-exc") || flag_val.contains("hole") {
exclude_holes = true;
if !vec[1].to_string().to_lowercase().contains("false") {
exclude_holes = true;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/data_tools/vector_lines_to_raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 18/04/2018
Last Modified: 12/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -229,7 +229,9 @@ impl WhiteboxTool for VectorLinesToRaster {
args[i + 1].to_string()
};
} else if flag_val == "-nodata" {
background_val = nodata;
if !vec[1].to_string().to_lowercase().contains("false") {
background_val = nodata;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/data_tools/vector_points_to_raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 19/04/2018
Last Modified: 12/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -234,7 +234,9 @@ impl WhiteboxTool for VectorPointsToRaster {
args[i + 1].to_string()
};
} else if flag_val == "-nodata" {
background_val = nodata;
if !vec[1].to_string().to_lowercase().contains("false") {
background_val = nodata;
}
} else if flag_val == "-assign" {
assign_op = if keyval {
vec[1].to_lowercase()
Expand Down
6 changes: 4 additions & 2 deletions src/tools/data_tools/vector_polygons_to_raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 17/04/2018
Last Modified: 17/07/2019
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -207,7 +207,9 @@ impl WhiteboxTool for VectorPolygonsToRaster {
args[i + 1].to_string()
};
} else if flag_val == "-nodata" {
background_val = nodata;
if !vec[1].to_string().to_lowercase().contains("false") {
background_val = nodata;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/block_maximum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 09/10/2018
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -184,7 +184,9 @@ impl WhiteboxTool for BlockMaximumGridding {
args[i + 1].to_string()
};
} else if flag_val == "-use_z" {
use_z = true;
if !vec[1].to_string().to_lowercase().contains("false") {
use_z = true;
}
} else if flag_val == "-o" || flag_val == "-output" {
output_file = if keyval {
vec[1].to_string()
Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/block_minimum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 09/10/2018
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -184,7 +184,9 @@ impl WhiteboxTool for BlockMinimumGridding {
args[i + 1].to_string()
};
} else if flag_val == "-use_z" {
use_z = true;
if !vec[1].to_string().to_lowercase().contains("false") {
use_z = true;
}
} else if flag_val == "-o" || flag_val == "-output" {
output_file = if keyval {
vec[1].to_string()
Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/buffer_raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 22/06/2017
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -193,7 +193,9 @@ impl WhiteboxTool for BufferRaster {
} else if vec[0].to_lowercase() == "-gridcells"
|| vec[0].to_lowercase() == "--gridcells"
{
grid_cell_units = true;
if !vec[1].to_string().to_lowercase().contains("false") {
grid_cell_units = true;
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/tools/gis_analysis/centroid.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: July 22 2017
Last Modified: December 14, 2017
Created: 22/07/2017
Last Modified: 18/10/2019
License: MIT
NOTES: Will need to add support for vector polygons eventually.
Expand Down Expand Up @@ -160,7 +160,9 @@ impl WhiteboxTool for Centroid {
} else if vec[0].to_lowercase() == "-text_output"
|| vec[0].to_lowercase() == "--text_output"
{
text_output = true;
if !vec[1].to_string().to_lowercase().contains("false") {
text_output = true;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/clip_raster_to_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 25/04/2018
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
NOTES: This tool differs from the Whitebox GAT tool in that it only takes a single raster input.
Expand Down Expand Up @@ -180,7 +180,9 @@ impl WhiteboxTool for ClipRasterToPolygon {
args[i + 1].to_string()
};
} else if flag_val == "-maintain_dimensions" {
maintain_dimensions = true;
if !vec[1].to_string().to_lowercase().contains("false") {
maintain_dimensions = true;
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/tools/gis_analysis/clump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 22/06/2017
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -178,9 +178,13 @@ impl WhiteboxTool for Clump {
args[i + 1].to_string()
};
} else if flag_val == "-diag" {
diag = true;
if !vec[1].to_string().to_lowercase().contains("false") {
diag = true;
}
} else if flag_val == "-zero_back" {
zero_back = true;
if !vec[1].to_string().to_lowercase().contains("false") {
zero_back = true;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/construct_vector_tin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 21/09/2018
Last Modified: 05/12/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -195,7 +195,9 @@ impl WhiteboxTool for ConstructVectorTIN {
};
use_field = true;
} else if flag_val.contains("use_z") {
use_z = true;
if !vec[1].to_string().to_lowercase().contains("false") {
use_z = true;
}
} else if flag_val == "-o" || flag_val == "-output" {
output_file = if keyval {
vec[1].to_string()
Expand Down
8 changes: 5 additions & 3 deletions src/tools/gis_analysis/cost_pathway.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: July 4, 2017
Last Modified: 13/10/2018
Created: 04/07/2017
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -182,7 +182,9 @@ impl WhiteboxTool for CostPathway {
|| vec[0].to_lowercase() == "--zero_background"
|| vec[0].to_lowercase() == "--esri_style"
{
background_val = 0f64;
if !vec[1].to_string().to_lowercase().contains("false") {
background_val = 0f64;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/edge_proportion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 13/07/2017
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -168,7 +168,9 @@ impl WhiteboxTool for EdgeProportion {
} else if vec[0].to_lowercase() == "-output_text"
|| vec[0].to_lowercase() == "--output_text"
{
output_text = true;
if !vec[1].to_string().to_lowercase().contains("false") {
output_text = true;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/extract_raster_values_at_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 17/06/2018
Last Modified: 30/01/2019
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -169,7 +169,9 @@ impl WhiteboxTool for ExtractRasterValuesAtPoints {
args[i + 1].to_string()
};
} else if flag_val.contains("-out_text") {
output_text = true;
if !vec[1].to_string().to_lowercase().contains("false") {
output_text = true;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/idw_interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 10/05/2018
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
Most IDW tool have the option to work either based on a fixed number of neighbouring
Expand Down Expand Up @@ -231,7 +231,9 @@ impl WhiteboxTool for IdwInterpolation {
args[i + 1].to_string()
};
} else if flag_val == "-use_z" {
use_z = true;
if !vec[1].to_string().to_lowercase().contains("false") {
use_z = true;
}
} else if flag_val == "-o" || flag_val == "-output" {
output_file = if keyval {
vec[1].to_string()
Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/minimum_bounding_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 14/09/2018
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -200,7 +200,9 @@ impl WhiteboxTool for MinimumBoundingBox {
MinimizationCriterion::Area
};
} else if flag_val == "-features" || flag_val == "-feature" {
individual_feature_hulls = true;
if !vec[1].to_string().to_lowercase().contains("false") {
individual_feature_hulls = true;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/tools/gis_analysis/minimum_bounding_circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 14/09/2018
Last Modified: 13/10/2018
Last Modified: 18/10/2019
License: MIT
*/

Expand Down Expand Up @@ -172,7 +172,9 @@ impl WhiteboxTool for MinimumBoundingCircle {
args[i + 1].to_string()
};
} else if flag_val == "-features" || flag_val == "-feature" {
individual_feature_hulls = true;
if !vec[1].to_string().to_lowercase().contains("false") {
individual_feature_hulls = true;
}
}
}

Expand Down
Loading

2 comments on commit d9eb35e

@alexbruy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you should not do it just because my plugin handles boolean parameters in a wrong way. If I have noticed this earlier, I'd fix it on the plugin side.

@jblindsay
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexbruy It's fine, I think that this makes the program more robust anyhow. I was happy to make the change.

Please sign in to comment.