Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
use anyhow::{Context, Result};
use clap::Parser;
use las::{Builder, Read, Reader, Write, Writer};
use std::path::PathBuf;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Args {
#[arg(short, long)]
path: String,
path: PathBuf,

#[arg(short, long, default_value_t = String::from("./"))]
output: String,
/// Output file path. Defaults to the input path with a
/// `.cleaned.las` extension (e.g. `/data/scan.las` -> `/data/scan.cleaned.las`).
#[arg(short, long)]
output: Option<PathBuf>,
}

fn main() -> Result<()> {
let args = Args::parse();

let mut reader = Reader::from_path(args.path).context("Failed to open las file")?;
let output = args
.output
.clone()
.unwrap_or_else(|| args.path.with_extension("cleaned.las"));

let mut reader = Reader::from_path(&args.path).context("Failed to open las file")?;

let original_header = reader.header().clone();

Expand All @@ -35,7 +43,7 @@ fn main() -> Result<()> {
}
}

let mut writer = Writer::from_path(args.output, header).context("Failed to get las writer")?;
let mut writer = Writer::from_path(&output, header).context("Failed to get las writer")?;

for point in las_points {
writer.write(point).context("Unable to write:")?;
Expand Down
Loading