Skip to content

Commit

Permalink
Updates for v0.16
Browse files Browse the repository at this point in the history
Updates for v0.16
  • Loading branch information
jblindsay committed May 24, 2019
1 parent fc7a54f commit c5e2abb
Show file tree
Hide file tree
Showing 10 changed files with 1,098 additions and 187 deletions.
5 changes: 3 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ for more details.
* Release Notes: *
******************

Version 0.1X.X (XX-XX-2019)
- Added the MergeLineSegments tool.
Version 0.16.0 (24-05-2019)
- Added the MergeLineSegments and SphericalStdDevOfNormals tools.
- Fixed a bug with reading LAS files with point records with extra bytes. Previously, the LAS decoder
assumed the Point Record Length matched that of the LAS specifications (with the variable of the
optional intensity and user data). Some LAS files in the wild (particularly those created using
Expand All @@ -73,6 +73,7 @@ Version 0.1X.X (XX-XX-2019)
- SelectTilesByPolygon and LidarTileFootprint are now compatible with LAZ file inputs. Both of these
tools only rely on information in the input LiDAR file's header, which is the same for a LAZ file
as a LAS file.
- Fixed a bug with writing Saga GIS files (*.sdat) that inverted rasters.

Version 0.15.0 (03-03-2019)
- The following tools were added to the project:
Expand Down
16 changes: 8 additions & 8 deletions src/raster/saga_raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {

writer.write_all(format!("NODATA_VALUE\t= {}\n", r.configs.nodata).as_bytes())?;

writer.write_all("TOPTOBOTTOM\t= TRUE\n".as_bytes())?;
writer.write_all("TOPTOBOTTOM\t= FALSE\n".as_bytes())?;

let _ = writer.flush();

Expand All @@ -497,7 +497,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {
let mut i: usize;
match r.configs.data_type {
DataType::F64 => {
for row in 0..r.configs.rows {
for row in (0..r.configs.rows).rev() {
//(0..r.configs.rows).rev() {
for col in 0..r.configs.columns {
i = row * r.configs.columns + col;
Expand All @@ -507,7 +507,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {
}
}
DataType::F32 => {
for row in 0..r.configs.rows {
for row in (0..r.configs.rows).rev() {
//(0..r.configs.rows).rev() {
for col in 0..r.configs.columns {
i = row * r.configs.columns + col;
Expand All @@ -517,7 +517,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {
}
}
DataType::I32 => {
for row in 0..r.configs.rows {
for row in (0..r.configs.rows).rev() {
//(0..r.configs.rows).rev() {
for col in 0..r.configs.columns {
i = row * r.configs.columns + col;
Expand All @@ -527,7 +527,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {
}
}
DataType::U32 => {
for row in 0..r.configs.rows {
for row in (0..r.configs.rows).rev() {
//(0..r.configs.rows).rev() {
for col in 0..r.configs.columns {
i = row * r.configs.columns + col;
Expand All @@ -537,7 +537,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {
}
}
DataType::I16 => {
for row in 0..r.configs.rows {
for row in (0..r.configs.rows).rev() {
//(0..r.configs.rows).rev() {
for col in 0..r.configs.columns {
i = row * r.configs.columns + col;
Expand All @@ -547,7 +547,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {
}
}
DataType::U16 => {
for row in 0..r.configs.rows {
for row in (0..r.configs.rows).rev() {
//(0..r.configs.rows).rev() {
for col in 0..r.configs.columns {
i = row * r.configs.columns + col;
Expand All @@ -557,7 +557,7 @@ pub fn write_saga<'a>(r: &'a mut Raster) -> Result<(), Error> {
}
}
DataType::U8 | DataType::I8 => {
for row in 0..r.configs.rows {
for row in (0..r.configs.rows).rev() {
//(0..r.configs.rows).rev() {
for col in 0..r.configs.columns {
i = row * r.configs.columns + col;
Expand Down
12 changes: 12 additions & 0 deletions src/raster/whitebox_raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::io::Error;
use std::io::ErrorKind;
use std::io::{BufReader, BufWriter};
use std::mem;
use std::path::Path;

pub fn read_whitebox(
file_name: &String,
Expand Down Expand Up @@ -243,6 +244,17 @@ pub fn write_whitebox<'a>(r: &'a mut Raster) -> Result<(), Error> {
r.configs.display_max = r.configs.maximum;
}

// Delete the wstat file if it exists
let wstat_string = r.file_name.replace(".tas", ".wstat").replace(".dep", ".wstat");
let wstat_path = Path::new(&wstat_string);
if wstat_path.exists() {
match std::fs::remove_file(&wstat_path) {
Ok(_) => {}, // do nothing
Err(_) => {}, // do nothing
}
}


// Save the header file
let header_file = r.file_name.replace(".tas", ".dep");
let f = File::create(header_file)?;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ impl ToolManager {
tool_names.push("SedimentTransportIndex".to_string());
tool_names.push("Slope".to_string());
tool_names.push("SlopeVsElevationPlot".to_string());
tool_names.push("SphericalStdDevOfNormals".to_string());
tool_names.push("StandardDeviationOfSlope".to_string());
tool_names.push("SurfaceAreaRatio".to_string());
tool_names.push("TangentialCurvature".to_string());
Expand Down Expand Up @@ -1038,6 +1039,7 @@ impl ToolManager {
}
"slope" => Some(Box::new(terrain_analysis::Slope::new())),
"slopevselevationplot" => Some(Box::new(terrain_analysis::SlopeVsElevationPlot::new())),
"sphericalstddevofnormals" => Some(Box::new(terrain_analysis::SphericalStdDevOfNormals::new())),
"standarddeviationofslope" => {
Some(Box::new(terrain_analysis::StandardDeviationOfSlope::new()))
}
Expand Down
Loading

0 comments on commit c5e2abb

Please sign in to comment.