Crate laz

source · []
Expand description

Port of the Martin Isenburg’s laszip compression to Rust

LasZipCompressor and LasZipDecompressor are the two types that user wishing to compress and / or decompress LAZ data should use.

LasZipCompressor Examples

use laz::{LasZipError, LasZipCompressor, LazItemType, LazItemRecordBuilder};

// Here we use a Cursor but a std::fs::File will work just fine
let mut compressed_output = std::io::Cursor::new(vec![]);

// LazItem may have multiple versions of the compression algorithm
// the builder selects a default one
let items = LazItemRecordBuilder::new()
            .add_item(LazItemType::Point10)
            .add_item(LazItemType::RGB12)
            .build();
let mut compressor = LasZipCompressor::from_laz_items(&mut compressed_output, items)?;

let point = vec![0u8; 26];
compressor.compress_one(&point)?;
compressor.done()?; // don't forget to call done when you are...done compressing

LasZipCompressors can also be contructed from a LazVlr if you need to change the Chunk size or if you have the LazVlr from the orignal LAZ file that you want to write back

use laz::{LasZipError, LasZipCompressor, LazItemType, LazItemRecordBuilder, LazVlrBuilder};


let mut compressed_output = std::io::Cursor::new(vec![]);
let items = LazItemRecordBuilder::new()
            .add_item(LazItemType::Point10)
            .add_item(LazItemType::RGB12)
            .build();
let vlr = LazVlrBuilder::from_laz_items(items)
          .with_chunk_size(5_000)
          .build();

let mut compressor = LasZipCompressor::new(&mut compressed_output, vlr)?;

let point = vec![0u8; 26];
compressor.compress_one(&point)?;
compressor.done()?;

To create a LasZipDecompressor you need to have the record_data found in the LAZ file.

LasZipDecompressor Examples


use laz::{LasZipError, LazVlr, LasZipDecompressor};
use std::fs::File;

let mut laz_file = File::open("tests/data/point10.laz")?;
seek_to_start_of_laszip_record_data(&mut laz_file)?;

let vlr = LazVlr::read_from(&mut laz_file)?;
let mut decompression_output = vec![0u8; vlr.items_size() as usize];
let mut decompressor = LasZipDecompressor::new(&mut laz_file, vlr)?;

let mut ground_truth = vec![0u8; decompression_output.len()];
read_first_point("tests/data/point10.las", &mut ground_truth)?;

decompressor.decompress_one(&mut decompression_output)?;
assert_eq!(&decompression_output, &ground_truth);

Parallelism

This crates has an optional feature ‘parallel’. When using this feature, additional Par structs and par_ methods are exposed.

Re-exports

pub use errors::LasZipError;
pub use laszip::LazCompressor;
pub use laszip::LazDecompressor;

Modules

Definitions of error related thins.

This module contains re-exports of the different version of LAS data compressors & decompressors as well as the definition of the point types.

Module with the important struct that people wishing to compress or decompress LAZ data can use

Everything about compressing & decompressing point records

Structs

Struct that handles the compression of the points into the given destination

LasZip decompressor that decompresses points.

Struct stored as part of the laszip’s vlr record_data

The data stored in the record_data of the Laszip Vlr

Builder struct to personalize the LazVlr

LasZip compressor that compresses using multiple threads

Laszip decompressor, that can decompress data using multiple threads

Enums

The different type of data / fields found in the definition of LAS points

Functions

Compresses all points

Decompresses all points from the buffer

Compresses all points in parallel

Actual the parallel decompression

Decompresses all points from the buffer in parallel.

Type Definitions

Shortcut for Results of this crate.