Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
alavenant committed Sep 25, 2024
1 parent 51cda27 commit cb5f844
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pdaltools/standardize_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_writer_parameters(new_parameters: Dict) -> Dict:
return params


def remove_points_from_class(points, class_points_removed: []) -> None:
def remove_points_from_class(points, class_points_removed: []) :
input_dimensions = list(points.dtype.fields.keys())
dim_class = input_dimensions.index("Classification")

Expand All @@ -97,6 +97,8 @@ def rewrite_with_pdal(input_file: str, output_file: str, params_from_parser: Dic
if class_points_removed:
points = remove_points_from_class(points, class_points_removed)

#ToDo : it seems that the forward="all" doesn't work because we use a new pipeline

params = get_writer_parameters(params_from_parser)
pipeline_end = pdal.Pipeline(arrays=[points])
pipeline_end |= pdal.Writer.las(output_file, forward="all", **params)
Expand Down
2 changes: 1 addition & 1 deletion script/test/test_run_remove_classes_in_las.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ python -m pdaltools.standardize_format \
--input_file test/data/classified_laz/test_data_77050_627755_LA93_IGN69.laz \
--output_file test/tmp/replaced_cmdline.laz \
--record_format 6 \
--remove_class 2 \
--class_points_removed 2 \
3 changes: 1 addition & 2 deletions test/test_las_remove_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def test_remove_one_dimension():

assert list(points_end.dtype.fields.keys()).index("DIM_2") >= 0 # should still contains DIM_2

with pytest.raises(ValueError):
list(points_end.dtype.fields.keys()).index("DIM_1") # should not have DIM_1
assert "DIM_1" not in points_end.dtype.fields.keys(), "LAS should not have dimension DIM_1"

with pytest.raises(TypeError):
numpy.array_equal(points_ini, points_end) # output data should not be the same
Expand Down

0 comments on commit cb5f844

Please sign in to comment.