@loaders.gl/las 3.1.3 → 4.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/dist.min.js +14970 -100
- package/dist/index.js +8 -17
- package/dist/index.js.map +1 -0
- package/dist/las-loader.js +21 -28
- package/dist/las-loader.js.map +1 -0
- package/dist/las-worker.js +14908 -47
- package/dist/lib/get-las-schema.js +35 -44
- package/dist/lib/get-las-schema.js.map +1 -0
- package/dist/lib/las-types.js +2 -2
- package/dist/{es5/lib → lib}/las-types.js.map +0 -0
- package/dist/lib/laslaz-decoder.js +363 -366
- package/dist/lib/laslaz-decoder.js.map +1 -0
- package/dist/lib/libs/laz-perf.js +2 -19006
- package/dist/lib/libs/laz-perf.js.map +1 -0
- package/dist/lib/parse-las.js +178 -176
- package/dist/lib/parse-las.js.map +1 -0
- package/dist/workers/las-worker.js +4 -5
- package/dist/workers/las-worker.js.map +1 -0
- package/package.json +8 -7
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -61
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/las-loader.js +0 -32
- package/dist/es5/las-loader.js.map +0 -1
- package/dist/es5/lib/get-las-schema.js +0 -47
- package/dist/es5/lib/get-las-schema.js.map +0 -1
- package/dist/es5/lib/las-types.js +0 -2
- package/dist/es5/lib/laslaz-decoder.js +0 -412
- package/dist/es5/lib/laslaz-decoder.js.map +0 -1
- package/dist/es5/lib/libs/laz-perf.js +0 -2
- package/dist/es5/lib/libs/laz-perf.js.map +0 -1
- package/dist/es5/lib/parse-las.js +0 -226
- package/dist/es5/lib/parse-las.js.map +0 -1
- package/dist/es5/workers/las-worker.js +0 -8
- package/dist/es5/workers/las-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js +0 -9
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/las-loader.js +0 -24
- package/dist/esm/las-loader.js.map +0 -1
- package/dist/esm/lib/get-las-schema.js +0 -37
- package/dist/esm/lib/get-las-schema.js.map +0 -1
- package/dist/esm/lib/las-types.js +0 -2
- package/dist/esm/lib/las-types.js.map +0 -1
- package/dist/esm/lib/laslaz-decoder.js +0 -392
- package/dist/esm/lib/laslaz-decoder.js.map +0 -1
- package/dist/esm/lib/libs/laz-perf.js +0 -2
- package/dist/esm/lib/libs/laz-perf.js.map +0 -1
- package/dist/esm/lib/parse-las.js +0 -191
- package/dist/esm/lib/parse-las.js.map +0 -1
- package/dist/esm/workers/las-worker.js +0 -4
- package/dist/esm/workers/las-worker.js.map +0 -1
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import getModule from './libs/laz-perf';
|
|
3
|
-
let Module = null;
|
|
4
|
-
const POINT_FORMAT_READERS = {
|
|
5
|
-
0: dv => {
|
|
6
|
-
return {
|
|
7
|
-
position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],
|
|
8
|
-
intensity: dv.getUint16(12, true),
|
|
9
|
-
classification: dv.getUint8(15)
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
1: dv => {
|
|
13
|
-
return {
|
|
14
|
-
position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],
|
|
15
|
-
intensity: dv.getUint16(12, true),
|
|
16
|
-
classification: dv.getUint8(15)
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
2: dv => {
|
|
20
|
-
return {
|
|
21
|
-
position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],
|
|
22
|
-
intensity: dv.getUint16(12, true),
|
|
23
|
-
classification: dv.getUint8(15),
|
|
24
|
-
color: [dv.getUint16(20, true), dv.getUint16(22, true), dv.getUint16(24, true)]
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
3: dv => {
|
|
28
|
-
return {
|
|
29
|
-
position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],
|
|
30
|
-
intensity: dv.getUint16(12, true),
|
|
31
|
-
classification: dv.getUint8(15),
|
|
32
|
-
color: [dv.getUint16(28, true), dv.getUint16(30, true), dv.getUint16(32, true)]
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
function readAs(buf, Type = {}, offset, count) {
|
|
38
|
-
count = count === undefined || count === 0 ? 1 : count;
|
|
39
|
-
const sub = buf.slice(offset, offset + Type.BYTES_PER_ELEMENT * count);
|
|
40
|
-
const r = new Type(sub);
|
|
41
|
-
|
|
42
|
-
if (count === 1) {
|
|
43
|
-
return r[0];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const ret = [];
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < count; i++) {
|
|
49
|
-
ret.push(r[i]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return ret;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function parseLASHeader(arraybuffer) {
|
|
56
|
-
let start = 32 * 3 + 35;
|
|
57
|
-
const o = {
|
|
58
|
-
pointsOffset: readAs(arraybuffer, Uint32Array, 32 * 3),
|
|
59
|
-
pointsFormatId: readAs(arraybuffer, Uint8Array, 32 * 3 + 8),
|
|
60
|
-
pointsStructSize: readAs(arraybuffer, Uint16Array, 32 * 3 + 8 + 1),
|
|
61
|
-
pointsCount: readAs(arraybuffer, Uint32Array, 32 * 3 + 11),
|
|
62
|
-
scale: readAs(arraybuffer, Float64Array, start, 3)
|
|
63
|
-
};
|
|
64
|
-
start += 24;
|
|
65
|
-
o.offset = readAs(arraybuffer, Float64Array, start, 3);
|
|
66
|
-
start += 24;
|
|
67
|
-
const bounds = readAs(arraybuffer, Float64Array, start, 6);
|
|
68
|
-
start += 48;
|
|
69
|
-
o.maxs = [bounds[0], bounds[2], bounds[4]];
|
|
70
|
-
o.mins = [bounds[1], bounds[3], bounds[5]];
|
|
71
|
-
return o;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
class LASLoader {
|
|
75
|
-
constructor(arraybuffer) {
|
|
76
|
-
_defineProperty(this, "arraybuffer", void 0);
|
|
77
|
-
|
|
78
|
-
_defineProperty(this, "readOffset", 0);
|
|
79
|
-
|
|
80
|
-
_defineProperty(this, "header", {
|
|
81
|
-
pointsOffset: 0,
|
|
82
|
-
pointsFormatId: 0,
|
|
83
|
-
pointsStructSize: 0,
|
|
84
|
-
pointsCount: 0,
|
|
85
|
-
scale: [0, 0, 0],
|
|
86
|
-
offset: [0, 0, 0],
|
|
87
|
-
maxs: [0],
|
|
88
|
-
mins: [0],
|
|
89
|
-
totalToRead: 0,
|
|
90
|
-
totalRead: 0,
|
|
91
|
-
versionAsString: '',
|
|
92
|
-
isCompressed: true
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
this.arraybuffer = arraybuffer;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
open() {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
getHeader() {
|
|
103
|
-
this.header = parseLASHeader(this.arraybuffer);
|
|
104
|
-
return this.header;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
readData(count, skip) {
|
|
108
|
-
const {
|
|
109
|
-
header,
|
|
110
|
-
arraybuffer
|
|
111
|
-
} = this;
|
|
112
|
-
|
|
113
|
-
if (!header) {
|
|
114
|
-
throw new Error('Cannot start reading data till a header request is issued');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
let {
|
|
118
|
-
readOffset
|
|
119
|
-
} = this;
|
|
120
|
-
let start;
|
|
121
|
-
|
|
122
|
-
if (skip <= 1) {
|
|
123
|
-
count = Math.min(count, header.pointsCount - readOffset);
|
|
124
|
-
start = header.pointsOffset + readOffset * header.pointsStructSize;
|
|
125
|
-
const end = start + count * header.pointsStructSize;
|
|
126
|
-
readOffset += count;
|
|
127
|
-
this.readOffset = readOffset;
|
|
128
|
-
return {
|
|
129
|
-
buffer: arraybuffer.slice(start, end),
|
|
130
|
-
count,
|
|
131
|
-
hasMoreData: readOffset < header.pointsCount
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const pointsToRead = Math.min(count * skip, header.pointsCount - readOffset);
|
|
136
|
-
const bufferSize = Math.ceil(pointsToRead / skip);
|
|
137
|
-
let pointsRead = 0;
|
|
138
|
-
const buf = new Uint8Array(bufferSize * header.pointsStructSize);
|
|
139
|
-
|
|
140
|
-
for (let i = 0; i < pointsToRead; i++) {
|
|
141
|
-
if (i % skip === 0) {
|
|
142
|
-
start = header.pointsOffset + readOffset * header.pointsStructSize;
|
|
143
|
-
const src = new Uint8Array(arraybuffer, start, header.pointsStructSize);
|
|
144
|
-
buf.set(src, pointsRead * header.pointsStructSize);
|
|
145
|
-
pointsRead++;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
readOffset++;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
this.readOffset = readOffset;
|
|
152
|
-
return {
|
|
153
|
-
buffer: buf.buffer,
|
|
154
|
-
count: pointsRead,
|
|
155
|
-
hasMoreData: readOffset < header.pointsCount
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
close() {
|
|
160
|
-
this.arraybuffer = null;
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
class LAZLoader {
|
|
167
|
-
constructor(arraybuffer) {
|
|
168
|
-
_defineProperty(this, "arraybuffer", void 0);
|
|
169
|
-
|
|
170
|
-
_defineProperty(this, "instance", null);
|
|
171
|
-
|
|
172
|
-
_defineProperty(this, "header", null);
|
|
173
|
-
|
|
174
|
-
this.arraybuffer = arraybuffer;
|
|
175
|
-
|
|
176
|
-
if (!Module) {
|
|
177
|
-
Module = getModule();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
open() {
|
|
182
|
-
try {
|
|
183
|
-
const {
|
|
184
|
-
arraybuffer
|
|
185
|
-
} = this;
|
|
186
|
-
this.instance = new Module.LASZip();
|
|
187
|
-
const abInt = new Uint8Array(arraybuffer);
|
|
188
|
-
|
|
189
|
-
const buf = Module._malloc(arraybuffer.byteLength);
|
|
190
|
-
|
|
191
|
-
this.instance.arraybuffer = arraybuffer;
|
|
192
|
-
this.instance.buf = buf;
|
|
193
|
-
Module.HEAPU8.set(abInt, buf);
|
|
194
|
-
this.instance.open(buf, arraybuffer.byteLength);
|
|
195
|
-
this.instance.readOffset = 0;
|
|
196
|
-
return true;
|
|
197
|
-
} catch (error) {
|
|
198
|
-
throw new Error("Failed to open file: ".concat(error.message));
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
getHeader() {
|
|
203
|
-
if (!this.instance) {
|
|
204
|
-
throw new Error('You need to open the file before trying to read header');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
try {
|
|
208
|
-
const header = parseLASHeader(this.instance.arraybuffer);
|
|
209
|
-
header.pointsFormatId &= 0x3f;
|
|
210
|
-
this.header = header;
|
|
211
|
-
return header;
|
|
212
|
-
} catch (error) {
|
|
213
|
-
throw new Error("Failed to get header: ".concat(error.message));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
readData(count, offset, skip) {
|
|
218
|
-
if (!this.instance) {
|
|
219
|
-
throw new Error('You need to open the file before trying to read stuff');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const {
|
|
223
|
-
header,
|
|
224
|
-
instance
|
|
225
|
-
} = this;
|
|
226
|
-
|
|
227
|
-
if (!header) {
|
|
228
|
-
throw new Error('You need to query header before reading, I maintain state that way, sorry :(');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
try {
|
|
232
|
-
const pointsToRead = Math.min(count * skip, header.pointsCount - instance.readOffset);
|
|
233
|
-
const bufferSize = Math.ceil(pointsToRead / skip);
|
|
234
|
-
let pointsRead = 0;
|
|
235
|
-
const thisBuf = new Uint8Array(bufferSize * header.pointsStructSize);
|
|
236
|
-
|
|
237
|
-
const bufRead = Module._malloc(header.pointsStructSize);
|
|
238
|
-
|
|
239
|
-
for (let i = 0; i < pointsToRead; i++) {
|
|
240
|
-
instance.getPoint(bufRead);
|
|
241
|
-
|
|
242
|
-
if (i % skip === 0) {
|
|
243
|
-
const a = new Uint8Array(Module.HEAPU8.buffer, bufRead, header.pointsStructSize);
|
|
244
|
-
thisBuf.set(a, pointsRead * header.pointsStructSize);
|
|
245
|
-
pointsRead++;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
instance.readOffset++;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return {
|
|
252
|
-
buffer: thisBuf.buffer,
|
|
253
|
-
count: pointsRead,
|
|
254
|
-
hasMoreData: instance.readOffset < header.pointsCount
|
|
255
|
-
};
|
|
256
|
-
} catch (error) {
|
|
257
|
-
throw new Error("Failed to read data: ".concat(error.message));
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
close() {
|
|
262
|
-
try {
|
|
263
|
-
if (this.instance !== null) {
|
|
264
|
-
this.instance.delete();
|
|
265
|
-
this.instance = null;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return true;
|
|
269
|
-
} catch (error) {
|
|
270
|
-
throw new Error("Failed to close file: ".concat(error.message));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
class LASDecoder {
|
|
277
|
-
constructor(buffer, len, header) {
|
|
278
|
-
_defineProperty(this, "arrayb", void 0);
|
|
279
|
-
|
|
280
|
-
_defineProperty(this, "decoder", void 0);
|
|
281
|
-
|
|
282
|
-
_defineProperty(this, "pointsCount", void 0);
|
|
283
|
-
|
|
284
|
-
_defineProperty(this, "pointSize", void 0);
|
|
285
|
-
|
|
286
|
-
_defineProperty(this, "scale", void 0);
|
|
287
|
-
|
|
288
|
-
_defineProperty(this, "offset", void 0);
|
|
289
|
-
|
|
290
|
-
_defineProperty(this, "mins", void 0);
|
|
291
|
-
|
|
292
|
-
_defineProperty(this, "maxs", void 0);
|
|
293
|
-
|
|
294
|
-
this.arrayb = buffer;
|
|
295
|
-
this.decoder = POINT_FORMAT_READERS[header.pointsFormatId];
|
|
296
|
-
this.pointsCount = len;
|
|
297
|
-
this.pointSize = header.pointsStructSize;
|
|
298
|
-
this.scale = header.scale;
|
|
299
|
-
this.offset = header.offset;
|
|
300
|
-
this.mins = header.mins;
|
|
301
|
-
this.maxs = header.maxs;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
getPoint(index) {
|
|
305
|
-
if (index < 0 || index >= this.pointsCount) {
|
|
306
|
-
throw new Error('Point index out of range');
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
const dv = new DataView(this.arrayb, index * this.pointSize, this.pointSize);
|
|
310
|
-
return this.decoder(dv);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export class LASFile {
|
|
316
|
-
constructor(arraybuffer) {
|
|
317
|
-
_defineProperty(this, "arraybuffer", void 0);
|
|
318
|
-
|
|
319
|
-
_defineProperty(this, "formatId", 0);
|
|
320
|
-
|
|
321
|
-
_defineProperty(this, "loader", void 0);
|
|
322
|
-
|
|
323
|
-
_defineProperty(this, "isCompressed", true);
|
|
324
|
-
|
|
325
|
-
_defineProperty(this, "isOpen", false);
|
|
326
|
-
|
|
327
|
-
_defineProperty(this, "version", 0);
|
|
328
|
-
|
|
329
|
-
_defineProperty(this, "versionAsString", '');
|
|
330
|
-
|
|
331
|
-
this.arraybuffer = arraybuffer;
|
|
332
|
-
|
|
333
|
-
if (this.determineVersion() > 13) {
|
|
334
|
-
throw new Error('Only file versions <= 1.3 are supported at this time');
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
this.determineFormat();
|
|
338
|
-
|
|
339
|
-
if (POINT_FORMAT_READERS[this.formatId] === undefined) {
|
|
340
|
-
throw new Error('The point format ID is not supported');
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
this.loader = this.isCompressed ? new LAZLoader(this.arraybuffer) : new LASLoader(this.arraybuffer);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
determineFormat() {
|
|
347
|
-
const formatId = readAs(this.arraybuffer, Uint8Array, 32 * 3 + 8);
|
|
348
|
-
const bit7 = (formatId & 0x80) >> 7;
|
|
349
|
-
const bit6 = (formatId & 0x40) >> 6;
|
|
350
|
-
|
|
351
|
-
if (bit7 === 1 && bit6 === 1) {
|
|
352
|
-
throw new Error('Old style compression not supported');
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
this.formatId = formatId & 0x3f;
|
|
356
|
-
this.isCompressed = bit7 === 1 || bit6 === 1;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
determineVersion() {
|
|
360
|
-
const ver = new Int8Array(this.arraybuffer, 24, 2);
|
|
361
|
-
this.version = ver[0] * 10 + ver[1];
|
|
362
|
-
this.versionAsString = "".concat(ver[0], ".").concat(ver[1]);
|
|
363
|
-
return this.version;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
open() {
|
|
367
|
-
if (this.loader.open()) {
|
|
368
|
-
this.isOpen = true;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
getHeader() {
|
|
373
|
-
return this.loader.getHeader();
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
readData(count, start, skip) {
|
|
377
|
-
return this.loader.readData(count, start, skip);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
close() {
|
|
381
|
-
if (this.loader.close()) {
|
|
382
|
-
this.isOpen = false;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
getUnpacker() {
|
|
387
|
-
return LASDecoder;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
export const LASModuleWasLoaded = false;
|
|
392
|
-
//# sourceMappingURL=laslaz-decoder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/laslaz-decoder.ts"],"names":["getModule","Module","POINT_FORMAT_READERS","dv","position","getInt32","intensity","getUint16","classification","getUint8","color","readAs","buf","Type","offset","count","undefined","sub","slice","BYTES_PER_ELEMENT","r","ret","i","push","parseLASHeader","arraybuffer","start","o","pointsOffset","Uint32Array","pointsFormatId","Uint8Array","pointsStructSize","Uint16Array","pointsCount","scale","Float64Array","bounds","maxs","mins","LASLoader","constructor","totalToRead","totalRead","versionAsString","isCompressed","open","getHeader","header","readData","skip","Error","readOffset","Math","min","end","buffer","hasMoreData","pointsToRead","bufferSize","ceil","pointsRead","src","set","close","LAZLoader","instance","LASZip","abInt","_malloc","byteLength","HEAPU8","error","message","thisBuf","bufRead","getPoint","a","delete","LASDecoder","len","arrayb","decoder","pointSize","index","DataView","LASFile","determineVersion","determineFormat","formatId","loader","bit7","bit6","ver","Int8Array","version","isOpen","getUnpacker","LASModuleWasLoaded"],"mappings":";AAOA,OAAOA,SAAP,MAAsB,iBAAtB;AAEA,IAAIC,MAAW,GAAG,IAAlB;AAgBA,MAAMC,oBAAgC,GAAG;AACvC,KAAIC,EAAD,IAAQ;AACT,WAAO;AACLC,MAAAA,QAAQ,EAAE,CAACD,EAAE,CAACE,QAAH,CAAY,CAAZ,EAAe,IAAf,CAAD,EAAuBF,EAAE,CAACE,QAAH,CAAY,CAAZ,EAAe,IAAf,CAAvB,EAA6CF,EAAE,CAACE,QAAH,CAAY,CAAZ,EAAe,IAAf,CAA7C,CADL;AAELC,MAAAA,SAAS,EAAEH,EAAE,CAACI,SAAH,CAAa,EAAb,EAAiB,IAAjB,CAFN;AAGLC,MAAAA,cAAc,EAAEL,EAAE,CAACM,QAAH,CAAY,EAAZ;AAHX,KAAP;AAKD,GAPsC;AAQvC,KAAIN,E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Z,QAAI,KAAK0B,MAAL,CAAY1B,KAAZ,EAAJ,EAAyB;AACvB,WAAKgC,MAAL,GAAc,KAAd;AACD;AACF;;AAGDC,EAAAA,WAAW,GAAsB;AAC/B,WAAOlB,UAAP;AACD;;AA5FkB;AA+FrB,OAAO,MAAMmB,kBAAkB,GAAG,KAA3B","sourcesContent":["/*\n Modified from Uday Verma and Howard Butler's plasio\n https://github.com/verma/plasio/\n MIT License\n*/\n// laslaz.js - treat as compiled code\nimport type {LASHeader} from './las-types';\nimport getModule from './libs/laz-perf';\n\nlet Module: any = null;\n\ntype LASReader = (dv: DataView) => {\n [LASAttribute: string]: number | number[];\n};\n\ntype LASReaders = {\n [key: number]: LASReader;\n};\n\ntype LASData = {\n buffer: ArrayBuffer;\n count: number;\n hasMoreData: boolean;\n};\n\nconst POINT_FORMAT_READERS: LASReaders = {\n 0: (dv) => {\n return {\n position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],\n intensity: dv.getUint16(12, true),\n classification: dv.getUint8(15)\n };\n },\n 1: (dv) => {\n return {\n position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],\n intensity: dv.getUint16(12, true),\n classification: dv.getUint8(15)\n };\n },\n 2: (dv) => {\n return {\n position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],\n intensity: dv.getUint16(12, true),\n classification: dv.getUint8(15),\n color: [dv.getUint16(20, true), dv.getUint16(22, true), dv.getUint16(24, true)]\n };\n },\n 3: (dv) => {\n return {\n position: [dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)],\n intensity: dv.getUint16(12, true),\n classification: dv.getUint8(15),\n color: [dv.getUint16(28, true), dv.getUint16(30, true), dv.getUint16(32, true)]\n };\n }\n};\n\n/**\n * Reads incoming binary data depends on the Type parameter\n * @param buf\n * @param Type\n * @param offset\n * @param count\n * @returns number | number[] from incoming binary data\n */\nfunction readAs(buf: ArrayBuffer, Type: any = {}, offset: number, count?: number) {\n count = count === undefined || count === 0 ? 1 : count;\n const sub = buf.slice(offset, offset + Type.BYTES_PER_ELEMENT * count);\n\n const r = new Type(sub);\n if (count === 1) {\n return r[0];\n }\n\n const ret: number[] = [];\n for (let i = 0; i < count; i++) {\n ret.push(r[i]);\n }\n\n return ret;\n}\n\n/**\n * Parsing of header's attributes\n * @param arraybuffer\n * @returns header as LASHeader\n */\nfunction parseLASHeader(arraybuffer: ArrayBuffer): LASHeader {\n let start = 32 * 3 + 35;\n\n const o: Partial<LASHeader> = {\n pointsOffset: readAs(arraybuffer, Uint32Array, 32 * 3),\n pointsFormatId: readAs(arraybuffer, Uint8Array, 32 * 3 + 8),\n pointsStructSize: readAs(arraybuffer, Uint16Array, 32 * 3 + 8 + 1),\n pointsCount: readAs(arraybuffer, Uint32Array, 32 * 3 + 11),\n scale: readAs(arraybuffer, Float64Array, start, 3)\n };\n start += 24; // 8*3\n o.offset = readAs(arraybuffer, Float64Array, start, 3);\n start += 24;\n\n const bounds = readAs(arraybuffer, Float64Array, start, 6);\n start += 48; // 8*6;\n o.maxs = [bounds[0], bounds[2], bounds[4]];\n o.mins = [bounds[1], bounds[3], bounds[5]];\n\n return o as LASHeader;\n}\n\n// LAS Loader\n// Loads uncompressed files\n//\nclass LASLoader {\n arraybuffer: ArrayBuffer;\n readOffset: number = 0;\n header: LASHeader = {\n pointsOffset: 0,\n pointsFormatId: 0,\n pointsStructSize: 0,\n pointsCount: 0,\n scale: [0, 0, 0],\n offset: [0, 0, 0],\n maxs: [0],\n mins: [0],\n totalToRead: 0,\n totalRead: 0,\n versionAsString: '',\n isCompressed: true\n };\n\n constructor(arraybuffer: ArrayBuffer) {\n this.arraybuffer = arraybuffer;\n }\n\n /**\n * @returns boolean\n */\n open() {\n // Nothing needs to be done to open this\n return true;\n }\n /**\n * Parsing of incoming binary\n * @returns LASHeader\n */\n getHeader() {\n this.header = parseLASHeader(this.arraybuffer);\n return this.header;\n }\n\n /**\n * Reading data\n * @param count\n * @param skip\n * @returns new ArrayBuffer, count, hasMoreData\n */\n readData(count: number, skip: number) {\n const {header, arraybuffer} = this;\n if (!header) {\n throw new Error('Cannot start reading data till a header request is issued');\n }\n\n let {readOffset} = this;\n let start: number;\n\n if (skip <= 1) {\n count = Math.min(count, header.pointsCount - readOffset);\n start = header.pointsOffset + readOffset * header.pointsStructSize;\n const end = start + count * header.pointsStructSize;\n readOffset += count;\n this.readOffset = readOffset;\n return {\n buffer: arraybuffer.slice(start, end),\n count,\n hasMoreData: readOffset < header.pointsCount\n };\n }\n\n const pointsToRead = Math.min(count * skip, header.pointsCount - readOffset);\n const bufferSize = Math.ceil(pointsToRead / skip);\n let pointsRead = 0;\n\n const buf = new Uint8Array(bufferSize * header.pointsStructSize);\n for (let i = 0; i < pointsToRead; i++) {\n if (i % skip === 0) {\n start = header.pointsOffset + readOffset * header.pointsStructSize;\n const src = new Uint8Array(arraybuffer, start, header.pointsStructSize);\n\n buf.set(src, pointsRead * header.pointsStructSize);\n pointsRead++;\n }\n\n readOffset++;\n }\n this.readOffset = readOffset;\n\n return {\n buffer: buf.buffer,\n count: pointsRead,\n hasMoreData: readOffset < header.pointsCount\n };\n }\n /**\n * Method which brings data to null to close the file\n * @returns\n */\n close() {\n // @ts-ignore Possibly null\n this.arraybuffer = null;\n return true;\n }\n}\n\n/**\n * LAZ Loader\n * Uses NaCL module to load LAZ files\n */\nclass LAZLoader {\n arraybuffer: ArrayBuffer;\n instance: any = null; // LASZip instance\n header: LASHeader | null = null;\n\n constructor(arraybuffer: ArrayBuffer) {\n this.arraybuffer = arraybuffer;\n\n if (!Module) {\n // Avoid executing laz-perf on import\n Module = getModule();\n }\n }\n\n /**\n * Opens the file\n * @returns boolean\n */\n open(): boolean {\n try {\n const {arraybuffer} = this;\n this.instance = new Module.LASZip();\n const abInt = new Uint8Array(arraybuffer);\n const buf = Module._malloc(arraybuffer.byteLength);\n\n this.instance.arraybuffer = arraybuffer;\n this.instance.buf = buf;\n Module.HEAPU8.set(abInt, buf);\n this.instance.open(buf, arraybuffer.byteLength);\n\n this.instance.readOffset = 0;\n\n return true;\n } catch (error) {\n throw new Error(`Failed to open file: ${(error as Error).message}`);\n }\n }\n\n getHeader(): LASHeader {\n if (!this.instance) {\n throw new Error('You need to open the file before trying to read header');\n }\n\n try {\n const header = parseLASHeader(this.instance.arraybuffer);\n header.pointsFormatId &= 0x3f;\n this.header = header;\n return header;\n } catch (error) {\n throw new Error(`Failed to get header: ${(error as Error).message}`);\n }\n }\n /**\n * @param count\n * @param offset\n * @param skip\n * @returns Data\n */\n readData(count: number, offset: number, skip: number): LASData {\n if (!this.instance) {\n throw new Error('You need to open the file before trying to read stuff');\n }\n\n const {header, instance} = this;\n\n if (!header) {\n throw new Error(\n 'You need to query header before reading, I maintain state that way, sorry :('\n );\n }\n\n try {\n const pointsToRead = Math.min(count * skip, header.pointsCount - instance.readOffset);\n const bufferSize = Math.ceil(pointsToRead / skip);\n let pointsRead = 0;\n\n const thisBuf = new Uint8Array(bufferSize * header.pointsStructSize);\n const bufRead = Module._malloc(header.pointsStructSize);\n for (let i = 0; i < pointsToRead; i++) {\n instance.getPoint(bufRead);\n\n if (i % skip === 0) {\n const a = new Uint8Array(Module.HEAPU8.buffer, bufRead, header.pointsStructSize);\n thisBuf.set(a, pointsRead * header.pointsStructSize);\n pointsRead++;\n }\n\n instance.readOffset++;\n }\n\n return {\n buffer: thisBuf.buffer,\n count: pointsRead,\n hasMoreData: instance.readOffset < header.pointsCount\n };\n } catch (error) {\n throw new Error(`Failed to read data: ${(error as Error).message}`);\n }\n }\n\n /**\n * Deletes the instance\n * @returns boolean\n */\n close(): boolean {\n try {\n if (this.instance !== null) {\n this.instance.delete();\n this.instance = null;\n }\n return true;\n } catch (error) {\n throw new Error(`Failed to close file: ${(error as Error).message}`);\n }\n }\n}\n\n/**\n * Helper class: Decodes LAS records into points\n */\nclass LASDecoder {\n arrayb: ArrayBuffer;\n decoder: (dv: DataView) => {};\n pointsCount: number;\n pointSize: number;\n scale: [number, number, number];\n offset?: [number, number, number];\n mins?: number[];\n maxs?: number[];\n\n constructor(buffer: ArrayBuffer, len: number, header: LASHeader) {\n this.arrayb = buffer;\n this.decoder = POINT_FORMAT_READERS[header.pointsFormatId];\n this.pointsCount = len;\n this.pointSize = header.pointsStructSize;\n this.scale = header.scale;\n this.offset = header.offset;\n this.mins = header.mins;\n this.maxs = header.maxs;\n }\n\n /**\n * Decodes data depends on this point size\n * @param index\n * @returns New object\n */\n getPoint(index: number): {} {\n if (index < 0 || index >= this.pointsCount) {\n throw new Error('Point index out of range');\n }\n\n const dv = new DataView(this.arrayb, index * this.pointSize, this.pointSize);\n return this.decoder(dv);\n }\n}\n\n/**\n * A single consistent interface for loading LAS/LAZ files\n */\nexport class LASFile {\n arraybuffer: ArrayBuffer;\n formatId: number = 0;\n loader: LASLoader | LAZLoader;\n isCompressed: boolean = true;\n isOpen: boolean = false;\n version: number = 0;\n versionAsString: string = '';\n\n constructor(arraybuffer: ArrayBuffer) {\n this.arraybuffer = arraybuffer;\n\n if (this.determineVersion() > 13) {\n throw new Error('Only file versions <= 1.3 are supported at this time');\n }\n\n this.determineFormat();\n if (POINT_FORMAT_READERS[this.formatId] === undefined) {\n throw new Error('The point format ID is not supported');\n }\n\n this.loader = this.isCompressed\n ? new LAZLoader(this.arraybuffer)\n : new LASLoader(this.arraybuffer);\n }\n\n /**\n * Determines format in parameters of LASHeaer\n */\n determineFormat(): void {\n const formatId = readAs(this.arraybuffer, Uint8Array, 32 * 3 + 8);\n const bit7 = (formatId & 0x80) >> 7;\n const bit6 = (formatId & 0x40) >> 6;\n\n if (bit7 === 1 && bit6 === 1) {\n throw new Error('Old style compression not supported');\n }\n\n this.formatId = formatId & 0x3f;\n this.isCompressed = bit7 === 1 || bit6 === 1;\n }\n\n /**\n * Determines version\n * @returns version\n */\n determineVersion(): number {\n const ver = new Int8Array(this.arraybuffer, 24, 2);\n this.version = ver[0] * 10 + ver[1];\n this.versionAsString = `${ver[0]}.${ver[1]}`;\n return this.version;\n }\n\n /**\n * Reads if the file is open\n * @returns boolean\n */\n open(): void {\n if (this.loader.open()) {\n this.isOpen = true;\n }\n }\n /**\n * Gets the header\n * @returns Header\n */\n getHeader(): LASHeader {\n return this.loader.getHeader();\n }\n\n /**\n * @param count\n * @param start\n * @param skip\n * @returns Data\n */\n readData(count: number, start: number, skip: number): LASData {\n return this.loader.readData(count, start, skip);\n }\n\n /**\n * Closes the file\n */\n close(): void {\n if (this.loader.close()) {\n this.isOpen = false;\n }\n }\n /**\n */\n getUnpacker(): typeof LASDecoder {\n return LASDecoder;\n }\n}\n\nexport const LASModuleWasLoaded = false;\n\n/* eslint no-use-before-define: 2 */\n"],"file":"laslaz-decoder.js"}
|