Skip to main content

Crate tilepack

Crate tilepack 

Source
Expand description

§tilepack

Reader and writer for the tilepack container format: a single-file, header-first container for tiled multi-band image pyramids, designed to be read over HTTP range requests from immutable object storage. One file holds one photographic asset (a planar raster or a cubemap panorama) as one or more band groups — RGB, near-infrared, thermal, depth — each a pyramid of independently fetchable tiles.

This crate is the format core: header, descriptor, and index parsing, the pyramid and canonical-order math (Layout), a Writer, and the split16 helpers. It is pure Rust and compiles for wasm32-unknown-unknown — image decoding and tile encoding live in the caller (the browser, or the native tiler crate). It performs no I/O of its own beyond the optional TilepackReader convenience over a Read + Seek source.

§Reading over range requests

use tilepack::{FrontMatter, required_len};

// Fetch a generous opening prefix, then let the format tell you exactly
// how much front matter it needs.
let mut prefix = fetch(0..65_536);
loop {
    match FrontMatter::parse(&prefix) {
        Ok(fm) => {
            // fm.tile_range(loc) / fm.level_range(g, level) now plan every fetch.
            let _ = fm;
            break;
        }
        Err(tilepack::ParseError::Truncated { needed }) => {
            prefix = fetch(0..needed);
        }
        Err(e) => panic!("bad tilepack: {e}"),
    }
}

Re-exports§

pub use descriptor::Codec;
pub use descriptor::GroupDescriptor;
pub use descriptor::GroupFlags;
pub use descriptor::Radiometry;
pub use descriptor::SampleType;
pub use descriptor::Semantic;
pub use error::ParseError;
pub use error::WriteError;
pub use header::HEADER_LEN;
pub use header::Header;
pub use header::MAGIC;
pub use header::VERSION;
pub use layout::Face;
pub use layout::Layout;
pub use layout::TileLoc;
pub use reader::FrontMatter;
pub use reader::TilepackReader;
pub use reader::TilepackView;
pub use reader::required_len;
pub use split16::split16_pack;
pub use split16::split16_pack_vec;
pub use split16::split16_unpack;
pub use split16::split16_unpack_vec;
pub use writer::Writer;
pub use writer::WriterParams;

Modules§

cube
Cubemap face geometry.
descriptor
Per-group descriptors: what a band group’s blobs mean and how they tile.
error
Error types for parsing and writing tilepack containers.
header
The 24-byte fixed header at offset 0.
layout
Pyramid geometry and canonical tile ordering — the math shared by the reader, the writer, and any producer. Every dimension and every tile ordinal is derived from the header plus descriptors; nothing here decodes a tile.
reader
Reading a tilepack: parse front matter from a prefix, then address tiles by byte range or by slice.
split16
Packing and unpacking u16 counts as webp-split16 RGB bytes.
writer
Assembling a tilepack from encoded tile blobs.