diff --git a/src/cli.rs b/src/cli.rs index d4c9010..f6f4da7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -29,13 +29,9 @@ pub struct Cli { /// Directory for the output. #[arg(short, long)] pub output: PathBuf, - /// Output format. - #[arg(long, value_enum)] - pub format: crate::Formats, - /// Create implicit tiling when the output format is 3D Tiles (https://docs.ogc.org/cs/22-025r4/22-025r4.html#toc31). - /// By default, explicit tiling is created for the 3D Tiles output. - #[arg(long = "3dtiles-implicit")] - pub cesium3dtiles_implicit: bool, + // /// Output format. + // #[arg(long, value_enum)] + // pub format: crate::Formats, /// The CityObject type to use for the 3D Tiles /// (https://www.cityjson.org/specs/1.1.3/#the-different-city-objects). /// You can specify it multiple times. @@ -52,6 +48,39 @@ pub struct Cli { /// 3D Tiles (https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata#class). #[arg(long = "3dtiles-metadata-class")] pub cesium3dtiles_metadata_class: Option, + /// Create implicit tiling when the output format is 3D Tiles (https://docs.ogc.org/cs/22-025r4/22-025r4.html#toc31). + /// By default, explicit tiling is created for the 3D Tiles output. + #[arg(long = "3dtiles-implicit")] + pub cesium3dtiles_implicit: bool, + /// Set the geometric error on the parent nodes of leafs. This controls at what + /// camera distance leaf nodes become visible, recommended values in between + /// 10 and 15. Higher values make content visible earlier when zooming in. + #[arg(long, short = 'e', default_value = "12")] + pub geometric_error_above_leaf: Option, + /// Set the 2D cell size for the grid that is used for constructing the quadtree. + #[arg(long, default_value = "250")] + pub grid_cellsize: Option, + /// Limit the minimum z coordinate for the bounding box that is computed from the + /// features. Useful if the features contain errors with extremely small z + /// coordinates. + #[arg(long)] + pub grid_minz: Option, + /// Limit the maximum z coordinate for the bounding box that is computed from the + /// features. Useful if the features contain errors with extremely large z + /// coordinates. + #[arg(long)] + pub grid_maxz: Option, + /// Export the grid and the feature centroids in to .tsv files in the working + /// directory. Used for debugging. + #[arg(long)] + pub grid_export: bool, + /// The capacity of a leaf of the quadtree. If a quadrant has less than or equal + /// the capacity, its subtiles are merged. + #[arg(long, default_value = "42000")] + pub qtree_capacity: Option, + /// Path to the geoflow executable for clipping and exporting the gltf files. + #[arg(long, value_parser = existing_path)] + pub exe_geof: Option, /// LoD to use in output for Building features #[arg(long)] pub lod_building: Option, @@ -172,47 +201,18 @@ pub struct Cli { /// Color for GenericCityObject features specified as a hex rgb-color value, eg. #FF0000 is red. #[arg(long, value_parser = hex_color)] pub color_generic_city_object: Option, - /// Export the grid and the feature centroids in to .tsv files in the working - /// directory. Used for debugging. - #[arg(long)] - pub grid_export: bool, - /// Set the geometric error on the parent nodes of leafs. This controls at what - /// camera distance leaf nodes become visible, recommended values in between - /// 10 and 15. Higher values make content visible earlier when zooming in. - #[arg(long, short = 'e', default_value = "12")] - pub geometric_error_above_leaf: Option, - /// Set the cell size for the grid that is used for constructing the quadtree. - #[arg(long, default_value = "250")] - pub grid_cellsize: Option, - /// Limit the minimum z coordinate for the bounding box that is computed from the - /// features. Useful if the features contain errors with extremely small z - /// coordinates. - #[arg(long)] - pub grid_minz: Option, - /// Limit the maximum z coordinate for the bounding box that is computed from the - /// features. Useful if the features contain errors with extremely large z - /// coordinates. - #[arg(long)] - pub grid_maxz: Option, - /// The criteria to check for the quadtree leaf capacity. - #[arg(long, value_enum, default_value = "vertices")] - pub qtree_criteria: Option, - /// Path to the geoflow executable for clipping and exporting the gltf files. - #[arg(long, value_parser = existing_path)] - pub exe_geof: Option, - /// Path to the python interpreter (>=3.8) to use for generating CityJSON tiles. - /// The interpreter must have a recent cjio (https://github.com/cityjson/cjio) - /// installed. - #[arg(long, value_parser = existing_path)] - pub exe_python: Option, - /// The capacity of a leaf of the quadtree. If a quadrant has less than or equal - /// the capacity, its subtiles are merged. - #[arg(long, default_value = "42000")] - pub qtree_capacity: Option, // The number of levels to export as content from the quadtree. // Counted from the leaves. // #[arg(long, default_value = "0")] // pub qtree_export_levels: Option, + // /// The criteria to check for the quadtree leaf capacity. + // #[arg(long, value_enum, default_value = "vertices")] + // pub qtree_criteria: Option, + // /// Path to the python interpreter (>=3.8) to use for generating CityJSON tiles. + // /// The interpreter must have a recent cjio (https://github.com/cityjson/cjio) + // /// installed. + // #[arg(long, value_parser = existing_path)] + // pub exe_python: Option, } fn existing_canonical_path(s: &str) -> Result { diff --git a/src/main.rs b/src/main.rs index adcf039..69d9638 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,7 +63,8 @@ fn main() -> Result<(), Box> { // Since we have a default value, we can safely unwrap. let grid_cellsize = cli.grid_cellsize.unwrap(); let geometric_error_above_leaf = cli.geometric_error_above_leaf.unwrap(); - let subprocess_config = match cli.format { + let format = crate::Formats::_3DTiles; // override --format + let subprocess_config = match format { Formats::_3DTiles => { let mut exe = PathBuf::new(); if let Some(exe_g) = cli.exe_geof { @@ -118,7 +119,8 @@ fn main() -> Result<(), Box> { debug!("{:?}", &subprocess_config); // Since we have a default value, it is safe to unwrap // let qtree_capacity = 0; // override cli.qtree_capacity - let quadtree_capacity = match &cli.qtree_criteria.unwrap() { + let qtree_criteria = spatial_structs::QuadTreeCriteria::Vertices; // override --qtree-criteria + let quadtree_capacity = match qtree_criteria { spatial_structs::QuadTreeCriteria::Objects => { spatial_structs::QuadTreeCapacity::Objects(cli.qtree_capacity.unwrap()) } @@ -126,7 +128,7 @@ fn main() -> Result<(), Box> { spatial_structs::QuadTreeCapacity::Vertices(cli.qtree_capacity.unwrap()) } }; - let metadata_class: String = match cli.format { + let metadata_class: String = match format { Formats::_3DTiles => { if cli.cesium3dtiles_metadata_class.is_none() { panic!("metadata_class must be set for writing 3D Tiles") @@ -312,7 +314,7 @@ fn main() -> Result<(), Box> { .arg(&subprocess_config.script) .arg(format!( "--output_format={}", - &cli.format.to_string().to_lowercase() + &format.to_string().to_lowercase() )) .arg(format!("--output_file={}", &output_file.to_str().unwrap())) .arg(format!( @@ -566,7 +568,7 @@ fn main() -> Result<(), Box> { )); } - if cli.format == Formats::_3DTiles { + if format == Formats::_3DTiles { // geof specific args if let Some(ref cotypes) = world.cityobject_types { if cotypes.contains(&parser::CityObjectType::Building)