README.md
1
2# What is this?
3
4LAZperf is an alternative [LAZ](http://laszip.org) implementation. It supports compilation
5to WASM via [Emscripten](https://emscripten.org/) so that LAZ data can be decoded in a browser.
6
7# Building LAZperf for Windows/UNIX
8
9Previous versions of LAZperf were header-only C++ libraries, so you could simply include the
10project header files in your project. Primarily due to licensing issues, this is no longer the
11case and LAZperf needs to be built as a library that links with your code. LAZperf uses
12CMake as a build system, though it's probably simple to port to another build system as there
13are few source files and no dependencies. Assuming you have Git, CMake, make and C++11 compiler
14installed, here is the
15process on the Unix command line. The process is similar on Windows.
16
17 git clone https://github.com/hobu/laz-perf.git
18 cd laz-perf
19 mkdir build
20 cd build
21 cmake ..
22 make
23
24This should build the library `liblazperf.so` (or similar). You can install this library along
25with the supporting header files as follows:
26
27 make install
28
29# Using LAZperf on Windows/UNIX
30
31Although the LAZperf library is focused on decoding the LAZ data itself, there is support
32for reading a complete LAS or LAZ file. If you have LAZ-comrpessed data, you can decompress
33by creating a decompressor for the right point type and providing a callback that will
34provide data from the LAZ source as requested by the decompressor. For example, to read
35point format 0 data, you might do the following:
36
37 using namespace lazperf;
38
39 void cb(unsigned char *buf, int len)
40 {
41 static unsigned char my_laz_data[] = {...};
42 static int idx = 0;
43
44 std::copy(buf, buf + len, my_laz_data + idx);
45 idx += len;
46 }
47
48 point_decompressor_0 decompressor(cb);
49
50 char pointbuf[100];
51 for (int i = 0; i < num_points; ++i)
52 decompressor(pointbuf);
53
54Compression follows a similar pattern -- see the accompanying examples and tests.
55
56You can also use LAZperf to read LAZ data from an entire LAZ or LAS file:
57
58 using namespace lazperf;
59
60 reader::named_file f(filename);
61
62 char pointbuf[100];
63 for (size_t i = 0; i < f.header().point_count; ++i)
64 c.readPoint(pointbuf);
65
66A memory file interface exists If your LAS/LAZ data is internal rather than in a file:
67
68 using namespace lazperf;
69
70 reader::mem_file f(buf, bufsize);
71
72 char pointbuf[100];
73 for (size_t i = 0; i < f.header().point_count; ++i)
74 c.readPoint(pointbuf);
75
76
77# Buiding LAZperf for use in a browser.
78
79In order to build LAZperf for the browser, you must have the
80[Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) installed.
81You will also need Git and CMake.
82Activate the installation to set the necessary EMSDK environment variable then follow
83these steps:
84
85 git clone https://github.com/hobu/laz-perf.git
86 cd laz-perf
87 mkdir build
88 cd build
89 . ../emscripten-build.sh
90
91This should create two files in the subdirectory build/cpp/emscripten: laz-perf.js and
92laz-perf.wasm. Both are necessary for running LAZperf from the browser.
93
94# Using LAZperf in a browser
95
96See the file cpp/emscripten/index.html for an example of how to decode LAZ data in
97the browser. Note that laz-perf.js will fetch laz-perf.wasm when run. You don't need
98to fetch it manually.
99
100