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

update algo MNx and test #24

Merged
merged 14 commits into from
Oct 10, 2024
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.3.0

Update algorithm of [mark_points_to_use_for_digital_models_with_new_dimension](pdal_ign_macro/mark_points_to_use_for_digital_models_with_new_dimension.py),
alavenant marked this conversation as resolved.
Show resolved Hide resolved

### 0.2.1

Fix (and test) arguments parsing in [mark_points_to_use_for_digital_models_with_new_dimension](pdal_ign_macro/mark_points_to_use_for_digital_models_with_new_dimension.py)
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pdal_ign_macro/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.2.1"
__version__ = "0.3.0"


if __name__ == "__main__":
Expand Down
Binary file added test/data/mnx/input/crop_1.laz
Binary file not shown.
Binary file added test/data/mnx/input/crop_2.laz
Binary file not shown.
Binary file added test/data/mnx/input/crop_3.laz
Binary file not shown.
Binary file added test/data/mnx/reference/crop_1.laz
Binary file not shown.
Binary file added test/data/mnx/reference/crop_2.laz
Binary file not shown.
Binary file added test/data/mnx/reference/crop_3.laz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import numpy as np
import pdal

import pytest

from pdaltools.las_remove_dimensions import remove_dimensions_from_las
alavenant marked this conversation as resolved.
Show resolved Hide resolved


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,
Expand Down Expand Up @@ -131,3 +136,62 @@ def test_parse_args():
parsed_args_keys = args.__dict__.keys()
main_parameters = inspect.signature(main).parameters.keys()
assert parsed_args_keys == main_parameters


@pytest.mark.parametrize(
"crop",
[
"crop_1.laz",
"crop_2.laz",
"crop_3.laz",
],
)
def test_algo_mark_points_for_dm_with_reference(crop):
ini_las = "test/data/mnx/input/" + crop
dsm_dimension = "dsm_marker"
dtm_dimension = "dtm_marker"
with tempfile.NamedTemporaryFile(suffix="_after.las") as las_output:
main(
ini_las,
las_output.name,
dsm_dimension,
dtm_dimension,
"",
"",
keep_temporary_dims=False,
skip_buffer=True,
)
pipeline = pdal.Pipeline()
pipeline.execute()
alavenant marked this conversation as resolved.
Show resolved Hide resolved

def sort_points(points):
sorted_index = np.lexsort((points["Y"], points["X"], points["Z"], points["GpsTime"]))
np.set_printoptions(precision=30)
sorted_points = points[sorted_index]
return sorted_points

pipeline_calc = pdal.Pipeline() | pdal.Reader.las(filename=las_output.name)
pipeline_calc.execute()
arr_result = pipeline_calc.arrays[0]

# read reference :
ref_las = "test/data/mnx/reference/" + crop

pipeline_ref = pdal.Pipeline() | pdal.Reader.las(filename=ref_las)
pipeline_ref.execute()
arr_reference = pipeline_ref.arrays[0]

assert len(arr_result) == len(arr_reference)

arr_result = sort_points(arr_result)
arr_reference = sort_points(arr_reference)

arr_result_dimensions = list(arr_result.dtype.fields.keys())
arr_ref_dimensions = list(arr_reference.dtype.fields.keys())

assert arr_result_dimensions == arr_ref_dimensions

for dim in arr_result_dimensions:
diff_mask = np.where(arr_result[dim] == arr_reference[dim], 0, 1)
nb_pts_incorrect = np.count_nonzero(diff_mask)
assert nb_pts_incorrect == 0