Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def lazrs_compress_points(points_data, parallel=True):
try:
import lazrs
except Exception as e:
raise LazError("lazrs is not installed") from e
try:
vlr = lazrs.LazVlr.new_for_compression(
points_data.point_format.id, points_data.point_format.num_extra_bytes)
compressed_data = lazrs.compress_points(
vlr,
np.frombuffer(points_data.array, np.uint8),
parallel
)
except lazrs.LazrsError as e:
raise LazError("lazrs error: {}".format(e)) from e
else:
return compressed_data, vlr.record_data()
def __init__(self, dest: BinaryIO, point_format: PointFormat, parallel: bool):
self.dest = dest
self.vlr = lazrs.LazVlr.new_for_compression(point_format.id, point_format.num_extra_bytes)
self.parallel = parallel
self.compressor = None