Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and test mark_points_to_use_for_digital_models_with_new_dimension… #22

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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",
)
Expand All @@ -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):
Expand Down Expand Up @@ -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",
Expand All @@ -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(
Expand All @@ -381,7 +378,7 @@ def main(
dtm_dimension,
output_dsm,
output_dtm,
keep_temporary_dimensions,
keep_temporary_dims,
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import tempfile

import numpy as np
Expand All @@ -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,
)


Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand All @@ -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