diff --git a/pdal_ign_macro/mark_points_to_use_for_digital_models_with_new_dimension.py b/pdal_ign_macro/mark_points_to_use_for_digital_models_with_new_dimension.py index 11a1a1b..0fe1e19 100755 --- a/pdal_ign_macro/mark_points_to_use_for_digital_models_with_new_dimension.py +++ b/pdal_ign_macro/mark_points_to_use_for_digital_models_with_new_dimension.py @@ -14,7 +14,7 @@ """ -def parse_args(): +def parse_args(argv=None): parser = argparse.ArgumentParser( "Tool to apply pdal pipelines to select points for DSM and DTM calculation" + "(add dimensions with positive values for the selected points)" @@ -51,7 +51,6 @@ def parse_args(): ) parser.add_argument( "--skip_buffer", - "-s", action="store_true", help="If set, skip adding a buffer from the neighbor tiles based on their name", ) @@ -71,18 +70,16 @@ def parse_args(): "--tile_width", type=int, default=1000, - action="store_true", help="width of tiles in meters (required when running with a buffer)", ) parser.add_argument( "--tile_coord_scale", type=int, default=1000, - action="store_true", help="scale used in the filename to describe coordinates in meters (required when running with a buffer)", ) - return parser.parse_args() + return parser.parse_args(argv) def define_marking_pipeline(input_las, output_las, dsm_dimension, dtm_dimension): @@ -352,7 +349,7 @@ def main( dtm_dimension, output_dsm, output_dtm, - keep_temporary_dimensions=False, + keep_temporary_dims=False, skip_buffer=False, buffer_width=25, spatial_ref="EPSG:2154", @@ -367,7 +364,7 @@ def main( dtm_dimension, output_dsm, output_dtm, - keep_temporary_dimensions, + keep_temporary_dims, ) else: mark_with_buffer = run_on_buffered_las( @@ -381,7 +378,7 @@ def main( dtm_dimension, output_dsm, output_dtm, - keep_temporary_dimensions, + keep_temporary_dims, ) diff --git a/test/pdal_ign_macro/test_mark_points_to_use_for_digital_models_with_new_dimension.py b/test/pdal_ign_macro/test_mark_points_to_use_for_digital_models_with_new_dimension.py index f551d01..07ff379 100644 --- a/test/pdal_ign_macro/test_mark_points_to_use_for_digital_models_with_new_dimension.py +++ b/test/pdal_ign_macro/test_mark_points_to_use_for_digital_models_with_new_dimension.py @@ -1,3 +1,4 @@ +import inspect import tempfile import numpy as np @@ -6,6 +7,7 @@ from pdal_ign_macro.mark_points_to_use_for_digital_models_with_new_dimension import ( main, mark_points_to_use_for_digital_models_with_new_dimension, + parse_args, ) @@ -76,7 +78,7 @@ def test_main_no_buffer(): dtm_dimension, "", "", - keep_temporary_dimensions=False, + keep_temporary_dims=False, skip_buffer=True, ) pipeline = pdal.Pipeline() @@ -103,7 +105,7 @@ def test_main_with_buffer(): dtm_dimension, "", "", - keep_temporary_dimensions=False, + keep_temporary_dims=False, skip_buffer=False, buffer_width=10, tile_width=50, @@ -119,3 +121,13 @@ def test_main_with_buffer(): arr = pipeline.arrays[0] assert np.any(arr[dsm_dimension] == 1) assert np.any(arr[dtm_dimension] == 1) + + +def test_parse_args(): + # sanity check for arguments parsing + args = parse_args( + ["--input_las", "test/data/4_6.las", "--output_las", "tmp/parse_args_out.las"] + ) + parsed_args_keys = args.__dict__.keys() + main_parameters = inspect.signature(main).parameters.keys() + assert parsed_args_keys == main_parameters