Skip to content

Conversation

@but0n
Copy link

@but0n but0n commented Oct 15, 2024

This PR adds a LazWriter class for managing LAZ file writing in the browser.

JavaScript Example:

...
const writer = new Module.LazWriter()
    .setPointFormat(pointFormat)
    .setTransform(
        header_info.offset.x,
        header_info.offset.y,
        header_info.offset.z,
        header_info.scale.x,
        header_info.scale.y,
        header_info.scale.z,
    );
writer.open(
    output.ptr,
    output.size,
);
for (var i = 0; i < pointCount; ++i) {
    laszip.getPoint(pointbuf.ptr);
    writer.writePoint(pointbuf.ptr);
}
const actual_size = writer.close();
const filebuf = output.resize(Number(actual_size)).to_owned_buffer();
const blob = new Blob([filebuf.buffer], { type: 'application/octet-stream' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'output.laz';
link.click();
URL.revokeObjectURL(url);

Additionally, the PR updates the CMakeLists.txt to include:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM_BIGINT -s EXPORTED_FUNCTIONS=['_malloc, _free']")

This ensures that symbols like _malloc and _free, which were previously exported from native code for internal use, are explicitly exported to the Module object. These changes were made necessary due to an Emscripten update from about a year ago (ChangeLog).

Let me know if you need any adjustments!

clean

Fix js bundle issue, enable ESM by default

Fix type definitions
@lmdc45
Copy link

lmdc45 commented May 13, 2025

 number of point records:    110000
  number of points by return: 0 0 0 0 0
  scale factor x y z:         0.009999999776483 0.009999999776483 0.009999999776483
  offset x y z:               0 0 0
  min x y z:                  636001.745784252882004 848935.181024819612503 406.25999091938138
  max x y z:                  637179.205757934600115 849497.881012242287397 520.50998836569488

Thanks for this
Noting this modifies the file a bit...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants