diff --git a/src/cli.rs b/src/cli.rs index f6f4da7..359c4ae 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -81,6 +81,9 @@ pub struct Cli { /// Path to the geoflow executable for clipping and exporting the gltf files. #[arg(long, value_parser = existing_path)] pub exe_geof: Option, + /// Use mesh simplification to reduce the number of vertices per object by this fraction. Value should be a float between 0.0 and 1.0. Ignored for building object types. + #[arg(long, default_value = "0.95")] + pub reduce_vertices: Option, /// LoD to use in output for Building features #[arg(long)] pub lod_building: Option, diff --git a/src/main.rs b/src/main.rs index 69d9638..331bae8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -336,246 +336,255 @@ fn main() -> Result<(), Box> { .arg(format!("--attribute_spec={}", &attribute_spec)) .arg(format!("--geometric_error={}", &tile.geometric_error)); - // colors - if !cli.color_building.is_none() { - cmd = cmd.arg(format!( - "--colorBuilding={}", - cli.color_building.as_ref().unwrap() - )); - } - if !cli.color_building_part.is_none() { - cmd = cmd.arg(format!( - "--colorBuildingPart={}", - cli.color_building_part.as_ref().unwrap() - )); - } - if !cli.color_building_installation.is_none() { - cmd = cmd.arg(format!( - "--colorBuildingInstallation={}", - cli.color_building_installation.as_ref().unwrap() - )); - } - if !cli.color_tin_relief.is_none() { - cmd = cmd.arg(format!( - "--colorTINRelief={}", - cli.color_tin_relief.as_ref().unwrap() - )); - } - if !cli.color_road.is_none() { - cmd = cmd.arg(format!("--colorRoad={}", cli.color_road.as_ref().unwrap())); - } - if !cli.color_railway.is_none() { - cmd = cmd.arg(format!( - "--colorRailway={}", - cli.color_railway.as_ref().unwrap() - )); - } - if !cli.color_transport_square.is_none() { - cmd = cmd.arg(format!( - "--colorTransportSquare={}", - cli.color_transport_square.as_ref().unwrap() - )); - } - if !cli.color_water_body.is_none() { - cmd = cmd.arg(format!( - "--colorWaterBody={}", - cli.color_water_body.as_ref().unwrap() - )); - } - if !cli.color_plant_cover.is_none() { - cmd = cmd.arg(format!( - "--colorPlantCover={}", - cli.color_plant_cover.as_ref().unwrap() - )); - } - if !cli.color_solitary_vegetation_object.is_none() { - cmd = cmd.arg(format!( - "--colorSolitaryVegetationObject={}", - cli.color_solitary_vegetation_object.as_ref().unwrap() - )); - } - if !cli.color_land_use.is_none() { - cmd = cmd.arg(format!( - "--colorLandUse={}", - cli.color_land_use.as_ref().unwrap() - )); - } - if !cli.color_city_furniture.is_none() { - cmd = cmd.arg(format!( - "--colorCityFurniture={}", - cli.color_city_furniture.as_ref().unwrap() - )); - } - if !cli.color_bridge.is_none() { - cmd = cmd.arg(format!( - "--colorBridge={}", - cli.color_bridge.as_ref().unwrap() - )); - } - if !cli.color_bridge_part.is_none() { - cmd = cmd.arg(format!( - "--colorBridgePart={}", - cli.color_bridge_part.as_ref().unwrap() - )); - } - if !cli.color_bridge_installation.is_none() { - cmd = cmd.arg(format!( - "--colorBridgeInstallation={}", - cli.color_bridge_installation.as_ref().unwrap() - )); - } - if !cli.color_bridge_construction_element.is_none() { - cmd = cmd.arg(format!( - "--colorBridgeConstructionElement={}", - cli.color_bridge_construction_element.as_ref().unwrap() - )); - } - if !cli.color_tunnel.is_none() { - cmd = cmd.arg(format!( - "--colorTunnel={}", - cli.color_tunnel.as_ref().unwrap() - )); - } - if !cli.color_tunnel_part.is_none() { - cmd = cmd.arg(format!( - "--colorTunnelPart={}", - cli.color_tunnel_part.as_ref().unwrap() - )); - } - if !cli.color_tunnel_installation.is_none() { - cmd = cmd.arg(format!( - "--colorTunnelInstallation={}", - cli.color_tunnel_installation.as_ref().unwrap() - )); - } - if !cli.color_generic_city_object.is_none() { - cmd = cmd.arg(format!( - "--colorGenericCityObject={}", - cli.color_generic_city_object.as_ref().unwrap() - )); - } - - // lod filter - if !cli.lod_building.is_none() { - cmd = cmd.arg(format!( - "--lodBuilding={}", - cli.lod_building.as_ref().unwrap() - )); - } - if !cli.lod_building_part.is_none() { - cmd = cmd.arg(format!( - "--lodBuildingPart={}", - cli.lod_building_part.as_ref().unwrap() - )); - } - if !cli.lod_building_installation.is_none() { - cmd = cmd.arg(format!( - "--lodBuildingInstallation={}", - cli.lod_building_installation.as_ref().unwrap() - )); - } - if !cli.lod_tin_relief.is_none() { - cmd = cmd.arg(format!( - "--lodTINRelief={}", - cli.lod_tin_relief.as_ref().unwrap() - )); - } - if !cli.lod_road.is_none() { - cmd = cmd.arg(format!("--lodRoad={}", cli.lod_road.as_ref().unwrap())); - } - if !cli.lod_railway.is_none() { - cmd = cmd.arg(format!( - "--lodRailway={}", - cli.lod_railway.as_ref().unwrap() - )); - } - if !cli.lod_transport_square.is_none() { - cmd = cmd.arg(format!( - "--lodTransportSquare={}", - cli.lod_transport_square.as_ref().unwrap() - )); - } - if !cli.lod_water_body.is_none() { - cmd = cmd.arg(format!( - "--lodWaterBody={}", - cli.lod_water_body.as_ref().unwrap() - )); - } - if !cli.lod_plant_cover.is_none() { - cmd = cmd.arg(format!( - "--lodPlantCover={}", - cli.lod_plant_cover.as_ref().unwrap() - )); - } - if !cli.lod_solitary_vegetation_object.is_none() { - cmd = cmd.arg(format!( - "--lodSolitaryVegetationObject={}", - cli.lod_solitary_vegetation_object.as_ref().unwrap() - )); - } - if !cli.lod_land_use.is_none() { - cmd = cmd.arg(format!( - "--lodLandUse={}", - cli.lod_land_use.as_ref().unwrap() - )); - } - if !cli.lod_city_furniture.is_none() { - cmd = cmd.arg(format!( - "--lodCityFurniture={}", - cli.lod_city_furniture.as_ref().unwrap() - )); - } - if !cli.lod_bridge.is_none() { - cmd = cmd.arg(format!("--lodBridge={}", cli.lod_bridge.as_ref().unwrap())); - } - if !cli.lod_bridge_part.is_none() { - cmd = cmd.arg(format!( - "--lodBridgePart={}", - cli.lod_bridge_part.as_ref().unwrap() - )); - } - if !cli.lod_bridge_installation.is_none() { - cmd = cmd.arg(format!( - "--lodBridgeInstallation={}", - cli.lod_bridge_installation.as_ref().unwrap() - )); - } - if !cli.lod_bridge_construction_element.is_none() { - cmd = cmd.arg(format!( - "--lodBridgeConstructionElement={}", - cli.lod_bridge_construction_element.as_ref().unwrap() - )); - } - if !cli.lod_tunnel.is_none() { - cmd = cmd.arg(format!("--lodTunnel={}", cli.lod_tunnel.as_ref().unwrap())); - } - if !cli.lod_tunnel_part.is_none() { - cmd = cmd.arg(format!( - "--lodTunnelPart={}", - cli.lod_tunnel_part.as_ref().unwrap() - )); - } - if !cli.lod_tunnel_installation.is_none() { - cmd = cmd.arg(format!( - "--lodTunnelInstallation={}", - cli.lod_tunnel_installation.as_ref().unwrap() - )); - } - if !cli.lod_generic_city_object.is_none() { - cmd = cmd.arg(format!( - "--lodGenericCityObject={}", - cli.lod_generic_city_object.as_ref().unwrap() - )); - } - if format == Formats::_3DTiles { // geof specific args + // colors + if !cli.color_building.is_none() { + cmd = cmd.arg(format!( + "--colorBuilding={}", + cli.color_building.as_ref().unwrap() + )); + } + if !cli.color_building_part.is_none() { + cmd = cmd.arg(format!( + "--colorBuildingPart={}", + cli.color_building_part.as_ref().unwrap() + )); + } + if !cli.color_building_installation.is_none() { + cmd = cmd.arg(format!( + "--colorBuildingInstallation={}", + cli.color_building_installation.as_ref().unwrap() + )); + } + if !cli.color_tin_relief.is_none() { + cmd = cmd.arg(format!( + "--colorTINRelief={}", + cli.color_tin_relief.as_ref().unwrap() + )); + } + if !cli.color_road.is_none() { + cmd = cmd.arg(format!("--colorRoad={}", cli.color_road.as_ref().unwrap())); + } + if !cli.color_railway.is_none() { + cmd = cmd.arg(format!( + "--colorRailway={}", + cli.color_railway.as_ref().unwrap() + )); + } + if !cli.color_transport_square.is_none() { + cmd = cmd.arg(format!( + "--colorTransportSquare={}", + cli.color_transport_square.as_ref().unwrap() + )); + } + if !cli.color_water_body.is_none() { + cmd = cmd.arg(format!( + "--colorWaterBody={}", + cli.color_water_body.as_ref().unwrap() + )); + } + if !cli.color_plant_cover.is_none() { + cmd = cmd.arg(format!( + "--colorPlantCover={}", + cli.color_plant_cover.as_ref().unwrap() + )); + } + if !cli.color_solitary_vegetation_object.is_none() { + cmd = cmd.arg(format!( + "--colorSolitaryVegetationObject={}", + cli.color_solitary_vegetation_object.as_ref().unwrap() + )); + } + if !cli.color_land_use.is_none() { + cmd = cmd.arg(format!( + "--colorLandUse={}", + cli.color_land_use.as_ref().unwrap() + )); + } + if !cli.color_city_furniture.is_none() { + cmd = cmd.arg(format!( + "--colorCityFurniture={}", + cli.color_city_furniture.as_ref().unwrap() + )); + } + if !cli.color_bridge.is_none() { + cmd = cmd.arg(format!( + "--colorBridge={}", + cli.color_bridge.as_ref().unwrap() + )); + } + if !cli.color_bridge_part.is_none() { + cmd = cmd.arg(format!( + "--colorBridgePart={}", + cli.color_bridge_part.as_ref().unwrap() + )); + } + if !cli.color_bridge_installation.is_none() { + cmd = cmd.arg(format!( + "--colorBridgeInstallation={}", + cli.color_bridge_installation.as_ref().unwrap() + )); + } + if !cli.color_bridge_construction_element.is_none() { + cmd = cmd.arg(format!( + "--colorBridgeConstructionElement={}", + cli.color_bridge_construction_element.as_ref().unwrap() + )); + } + if !cli.color_tunnel.is_none() { + cmd = cmd.arg(format!( + "--colorTunnel={}", + cli.color_tunnel.as_ref().unwrap() + )); + } + if !cli.color_tunnel_part.is_none() { + cmd = cmd.arg(format!( + "--colorTunnelPart={}", + cli.color_tunnel_part.as_ref().unwrap() + )); + } + if !cli.color_tunnel_installation.is_none() { + cmd = cmd.arg(format!( + "--colorTunnelInstallation={}", + cli.color_tunnel_installation.as_ref().unwrap() + )); + } + if !cli.color_generic_city_object.is_none() { + cmd = cmd.arg(format!( + "--colorGenericCityObject={}", + cli.color_generic_city_object.as_ref().unwrap() + )); + } + + // lod filter + if !cli.lod_building.is_none() { + cmd = cmd.arg(format!( + "--lodBuilding={}", + cli.lod_building.as_ref().unwrap() + )); + } + if !cli.lod_building_part.is_none() { + cmd = cmd.arg(format!( + "--lodBuildingPart={}", + cli.lod_building_part.as_ref().unwrap() + )); + } + if !cli.lod_building_installation.is_none() { + cmd = cmd.arg(format!( + "--lodBuildingInstallation={}", + cli.lod_building_installation.as_ref().unwrap() + )); + } + if !cli.lod_tin_relief.is_none() { + cmd = cmd.arg(format!( + "--lodTINRelief={}", + cli.lod_tin_relief.as_ref().unwrap() + )); + } + if !cli.lod_road.is_none() { + cmd = cmd.arg(format!("--lodRoad={}", cli.lod_road.as_ref().unwrap())); + } + if !cli.lod_railway.is_none() { + cmd = cmd.arg(format!( + "--lodRailway={}", + cli.lod_railway.as_ref().unwrap() + )); + } + if !cli.lod_transport_square.is_none() { + cmd = cmd.arg(format!( + "--lodTransportSquare={}", + cli.lod_transport_square.as_ref().unwrap() + )); + } + if !cli.lod_water_body.is_none() { + cmd = cmd.arg(format!( + "--lodWaterBody={}", + cli.lod_water_body.as_ref().unwrap() + )); + } + if !cli.lod_plant_cover.is_none() { + cmd = cmd.arg(format!( + "--lodPlantCover={}", + cli.lod_plant_cover.as_ref().unwrap() + )); + } + if !cli.lod_solitary_vegetation_object.is_none() { + cmd = cmd.arg(format!( + "--lodSolitaryVegetationObject={}", + cli.lod_solitary_vegetation_object.as_ref().unwrap() + )); + } + if !cli.lod_land_use.is_none() { + cmd = cmd.arg(format!( + "--lodLandUse={}", + cli.lod_land_use.as_ref().unwrap() + )); + } + if !cli.lod_city_furniture.is_none() { + cmd = cmd.arg(format!( + "--lodCityFurniture={}", + cli.lod_city_furniture.as_ref().unwrap() + )); + } + if !cli.lod_bridge.is_none() { + cmd = cmd.arg(format!("--lodBridge={}", cli.lod_bridge.as_ref().unwrap())); + } + if !cli.lod_bridge_part.is_none() { + cmd = cmd.arg(format!( + "--lodBridgePart={}", + cli.lod_bridge_part.as_ref().unwrap() + )); + } + if !cli.lod_bridge_installation.is_none() { + cmd = cmd.arg(format!( + "--lodBridgeInstallation={}", + cli.lod_bridge_installation.as_ref().unwrap() + )); + } + if !cli.lod_bridge_construction_element.is_none() { + cmd = cmd.arg(format!( + "--lodBridgeConstructionElement={}", + cli.lod_bridge_construction_element.as_ref().unwrap() + )); + } + if !cli.lod_tunnel.is_none() { + cmd = cmd.arg(format!("--lodTunnel={}", cli.lod_tunnel.as_ref().unwrap())); + } + if !cli.lod_tunnel_part.is_none() { + cmd = cmd.arg(format!( + "--lodTunnelPart={}", + cli.lod_tunnel_part.as_ref().unwrap() + )); + } + if !cli.lod_tunnel_installation.is_none() { + cmd = cmd.arg(format!( + "--lodTunnelInstallation={}", + cli.lod_tunnel_installation.as_ref().unwrap() + )); + } + if !cli.lod_generic_city_object.is_none() { + cmd = cmd.arg(format!( + "--lodGenericCityObject={}", + cli.lod_generic_city_object.as_ref().unwrap() + )); + } + if let Some(ref cotypes) = world.cityobject_types { if cotypes.contains(&parser::CityObjectType::Building) || cotypes.contains(&parser::CityObjectType::BuildingPart) { cmd = cmd.arg("--simplify_ratio=1.0").arg("--skip_clip=true"); } + else + { + if !cli.reduce_vertices.is_none() { + cmd = cmd.arg(format!( + "--simplify_ratio={}", + cli.reduce_vertices.as_ref().unwrap() + )); + } + } } if log_enabled!(Level::Debug) { cmd = cmd.arg("--verbose");