Skip to content

Commit

Permalink
Merge pull request #58 from IGNF/dev
Browse files Browse the repository at this point in the history
Merge dev on master for version to 1.7.2
  • Loading branch information
leavauchier authored Jul 18, 2024
2 parents 5f31a7d + 6607f30 commit 1e24a84
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.7.2
- Add possibility to select extra dimensions to keep in standardization

# 1.7.1
Same as 1.7.0 (new tag needed to publish on pypi due to incorrect package handling)

Expand Down
2 changes: 1 addition & 1 deletion pdaltools/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.7.1"
__version__ = "1.7.2"


if __name__ == "__main__":
Expand Down
11 changes: 10 additions & 1 deletion pdaltools/standardize_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- precision
- no extra-dims
"""

import argparse
import os
import subprocess as sp
Expand Down Expand Up @@ -42,6 +43,14 @@ def parse_args():
"--record_format", choices=[6, 8], type=int, help="Record format: 6 (no color) or 8 (4 color channels)"
)
parser.add_argument("--projection", default="EPSG:2154", type=str, help="Projection, eg. EPSG:2154")
parser.add_argument(
"--extra_dims",
default=[],
nargs="*",
type=str,
help="List of extra dims to keep in the output (default=[], use 'all' to keep all extra dims), "
"extra_dims must be specified with their type (see pdal.writers.las documentation, eg 'dim1=double')",
)

return parser.parse_args()

Expand Down Expand Up @@ -86,5 +95,5 @@ def standardize(input_file: str, output_file: str, params_from_parser: Dict) ->

if __name__ == "__main__":
args = parse_args()
params_from_parser = dict(dataformat_id=args.record_format, a_srs=args.projection)
params_from_parser = dict(dataformat_id=args.record_format, a_srs=args.projection, extra_dims=args.extra_dims)
standardize(args.input_file, args.output_file, params_from_parser)
Binary file not shown.
14 changes: 10 additions & 4 deletions test/test_standardize_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
INPUT_DIR = os.path.join(TEST_PATH, "data")

MUTLIPLE_PARAMS = [
{"dataformat_id": 6, "a_srs": "EPSG:2154"},
{"dataformat_id": 8, "a_srs": "EPSG:4326"},
{"dataformat_id": 6, "a_srs": "EPSG:2154", "extra_dims": []},
{"dataformat_id": 8, "a_srs": "EPSG:4326", "extra_dims": []},
{"dataformat_id": 8, "a_srs": "EPSG:2154", "extra_dims": ["dtm_marker=double", "dsm_marker=double"]},
{"dataformat_id": 8, "a_srs": "EPSG:2154", "extra_dims": "all"},
]


Expand Down Expand Up @@ -46,14 +48,18 @@ def _test_standardize_format_one_params_set(input_file, output_file, params):
assert metadata["dataformat_id"] == params["dataformat_id"]
# Check that there is no extra dim
dimensions = set([d.strip() for d in json_info["summary"]["dimensions"].split(",")])
assert dimensions == EXPECTED_DIMS_BY_DATAFORMAT[params["dataformat_id"]]
if params["extra_dims"] == "all":
assert EXPECTED_DIMS_BY_DATAFORMAT[params["dataformat_id"]].issubset(dimensions)
else:
extra_dims_names = [dim.split("=")[0] for dim in params["extra_dims"]]
assert dimensions == EXPECTED_DIMS_BY_DATAFORMAT[params["dataformat_id"]].union(extra_dims_names)

# TODO: Check srs
# TODO: check precision


def test_standardize_format():
input_file = os.path.join(INPUT_DIR, "test_data_77055_627760_LA93_IGN69.laz")
input_file = os.path.join(INPUT_DIR, "test_data_77055_627755_LA93_IGN69_extra_dims.laz")
output_file = os.path.join(TMP_PATH, "formatted.laz")
for params in MUTLIPLE_PARAMS:
_test_standardize_format_one_params_set(input_file, output_file, params)
Expand Down

0 comments on commit 1e24a84

Please sign in to comment.