lepcc

    Esri's LEPCC decoders (I3S point clouds: lepcc-xyz, lepcc-rgb, lepcc-intensity) in MoonBit

    lepcc
    i3s
    point-cloud
    decoder
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    5 hours ago
    Downloads
    3

    No dependencies

    #lepcc

    LEPCC (Limited Error Point Cloud Compression) decoders in MoonBit: the lepcc-xyz, lepcc-rgb and lepcc-intensity buffers of I3S point cloud scene layers, decoded as Esri's LEPCC C API does. Pure MoonBit on every backend (wasm, wasm-gc, js, native), with no dependencies.

    Part of mbt-map, a WebGIS library, published on its own.

    moon add t-ujiie-g/lepcc

    /// The number of points in a `lepcc-xyz` resource, or None if it is malformed.
    fn point_count(resource : FixedArray[Byte]) -> Int? {
    guard @lepcc.decode(Xyz, resource, 0, resource.length()) is Some(out) else {
    return None
    }
    Some(out[0].to_int() | (out[1].to_int() << 8) | (out[2].to_int() << 16) | (out[3].to_int() << 24))
    }

    decode(kind, data, start, len) gives one little-endian buffer, or None where Esri's decoder refuses the blob (and for blobs of no points or more than MAX_POINTS; the input is treated as untrusted):

    BytesContent
    8u32 count n, u32 0
    24 × n (Xyz)f64 x, y, z per point, absolute coordinates in the layer's spatial reference
    3 × n (Rgb)u8 r, g, b per point
    2 × n (Intensity)u16 per point

    FlagBytes blobs are not ported (always None). There is no encoder.

    #Matching Esri's library

    The repository compares the decoders with Esri's C++ (a pinned commit) on blobs its encoder writes, plus corrupted copies (lepcc:golden): no difference on the js and wasm-gc backends.

    #License

    Apache-2.0, as LEPCC itself (see NOTICE).

    BlobType

    pub(all) enum BlobType {
    Xyz
    Rgb
    Intensity
    FlagBytes
    } derive(Eq)

    What a blob holds, as lepcc_getBlobInfo names it (BlobType).

    BlobType::equal

    fn BlobType::equal(BlobType, BlobType) -> Bool

    BlobType::not_equal

    fn BlobType::not_equal(x : BlobType, y : BlobType) -> Bool

    MAX_POINTS

    let MAX_POINTS : Int

    The most points (colors, intensities) a blob may hold, and the most values any of its bit-stuffed arrays may unpack to.

    decode

    fn decode(kind : BlobType, data : FixedArray[Byte], start : Int, len : Int) -> FixedArray[Byte]?

    The blob in data[start, start + len) decoded as kind and laid out as mbt-map's FORMATS.md "LEPCC output", or None where its decoder refuses it (always for FlagBytes, which is not ported).