Skip to content

Commit

Permalink
Make the CLI take a specific input file
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Jun 13, 2024
1 parent 0a08bff commit 3728f68
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 7 deletions.
141 changes: 141 additions & 0 deletions cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
anyhow = "1.0.86"
env_logger = "0.11.3"
gdal = "0.16.0"
geo = "0.28.0"
geojson = { git = "https://github.com/georust/geojson", features = ["geo-types"] }
Expand Down
24 changes: 17 additions & 7 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@ use widths::{
};

fn main() -> Result<()> {
env_logger::init();
let args: Vec<String> = std::env::args().collect();
if args.len() != 2 {
println!("Call with a .geojson or .gpkg file in WGS84");
std::process::exit(1);
}

let cfg = Config::default();
let (pavements, mercator) = read_gj_input(
std::fs::read_to_string("../test_input/small_pavements.geojson")?,
&cfg,
)?;
//let (pavements, mercator) = read_gj_input(std::fs::read_to_string("../test_input/small_road_polygons.geojson")?)?;
//let (pavements, mercator) = read_gpkg_input("../test_input/large.gpkg", "Roadside")?;
//let pavements = read_gpkg_input("../test_input/large.gpkg", "Road Or Track")?;
let (pavements, mercator) = if args[1].ends_with(".geojson") {
read_gj_input(std::fs::read_to_string(&args[1])?, &cfg)?
} else if args[1].ends_with(".gpkg") {
// TODO Take a flag to decide which one, or do the filtering elsewhere?
read_gpkg_input("../test_input/large.gpkg", "Roadside", &cfg)?
//read_gpkg_input("../test_input/large.gpkg", "Road Or Track", &cfg)?
} else {
println!("Call with a .geojson or .gpkg file in WGS84");
std::process::exit(1);
};

let mut input_polygons = Vec::new();
let mut skeletons = Vec::new();
Expand Down

0 comments on commit 3728f68

Please sign in to comment.