Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

Commit

Permalink
Don't use parallel decompression when we detect that the chunk table …
Browse files Browse the repository at this point in the history
…was not written
  • Loading branch information
tmontaigu committed Jul 17, 2020
1 parent 7a5bbad commit 33f6d40
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pylas/lasreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,22 @@ def _read_compressed_points_data(self, laszip_vlr, point_format):
current_pos = self.stream.tell()
points_data = bytearray(self.stream.read(size_of_point_data))
offset_to_chunk_table = struct.unpack("<q", points_data[:8])[0]
offset_to_chunk_table -= current_pos
struct.pack_into("<q", points_data, 0, offset_to_chunk_table)

lazrs_parallel = True
if offset_to_chunk_table == current_pos:
# The compressor was interrupted before being able to write the chunk table
# The parallel decompression relies on the chunk table, so we can't use it
lazrs_parallel = False
elif offset_to_chunk_table != -1:
offset_to_chunk_table -= current_pos
struct.pack_into("<q", points_data, 0, offset_to_chunk_table)

try:
decompressed_points = lazrs_decompress_buffer(
points_data,
point_format.dtype.itemsize,
self.header.point_count,
laszip_vlr
laszip_vlr,
parallel=lazrs_parallel
)
except errors.LazError as e:
logger.error("lazrs failed to decompress points: {}".format(e))
Expand Down Expand Up @@ -193,7 +200,6 @@ def _decompress_with_laszip_executable(self):

return new_source


def _read_internal_waveform_packet(self):
""" reads and returns the waveform vlr header, waveform record
"""
Expand Down

0 comments on commit 33f6d40

Please sign in to comment.