Skip to content

Commit 06b9d57

Browse files
Merge pull request #305 from 3DBAG/ahn5-pdal-issue
Ahn5 pdal issue
2 parents a5c1f3e + ed9e386 commit 06b9d57

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

packages/common/src/bag3d/common/utils/geodata.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -269,33 +269,29 @@ def pdal_info(
269269
]
270270
cmd_list.append("--all") if with_all else cmd_list.append("--metadata")
271271
cmd_list.append("{local_path}")
272-
try:
273-
return_code, output = pdal.execute(
274-
"pdal",
275-
command=" ".join(cmd_list),
276-
local_path=file_path,
277-
silent=(not verbose),
278-
output_logging="BUFFER",
279-
)
280-
except Exception as e:
281-
if "Global encoding WKT flag" in str(e):
282-
logger.warning(f"Pdal failed for tile {file_path} with error {e}.")
283-
logger.warning("Setting --readers.las.nosrs true")
284-
cmd_list.append("--readers.las.nosrs true")
285-
return_code, output = pdal.execute(
286-
"pdal",
287-
command=" ".join(cmd_list),
288-
local_path=file_path,
289-
silent=(not verbose),
290-
)
291-
else:
292-
raise
272+
273+
return_code, output = pdal.execute(
274+
"pdal",
275+
command=" ".join(cmd_list),
276+
local_path=file_path,
277+
silent=(not verbose),
278+
output_logging="BUFFER",
279+
)
280+
281+
if "Global encoding WKT flag" in str(output):
282+
logger.warning(f"Pdal failed for tile {file_path} with output {output}.")
283+
# Remove the first line
284+
output_lines = output.split("\n")
285+
if len(output_lines) > 1:
286+
logger.warning(f"Removing first line from PDAL output : {output_lines[0]}")
287+
output = "\n".join(output_lines[1:])
288+
293289
output_processed = output.replace("\\u0000", "")
294290

295291
try:
296292
json_data = json.loads(output_processed)
297293
except JSONDecodeError as e:
298-
raise Failure(f"Failed to make JSON from pdal output: {output}. {e}")
294+
raise Failure(f"Failed to make JSON from pdal output: {output_processed}. {e}")
299295

300296
return return_code, json_data
301297

0 commit comments

Comments
 (0)