@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,395 +1,392 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LASModuleWasLoaded = exports.LASFile = void 0;
|
|
7
|
-
const laz_perf_1 = __importDefault(require("./libs/laz-perf"));
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import getModule from './libs/laz-perf';
|
|
8
3
|
let Module = null;
|
|
9
4
|
const POINT_FORMAT_READERS = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
}
|
|
40
35
|
};
|
|
41
|
-
|
|
42
|
-
* Reads incoming binary data depends on the Type parameter
|
|
43
|
-
* @param buf
|
|
44
|
-
* @param Type
|
|
45
|
-
* @param offset
|
|
46
|
-
* @param count
|
|
47
|
-
* @returns number | number[] from incoming binary data
|
|
48
|
-
*/
|
|
36
|
+
|
|
49
37
|
function readAs(buf, Type = {}, offset, count) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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;
|
|
61
53
|
}
|
|
62
|
-
|
|
63
|
-
* Parsing of header's attributes
|
|
64
|
-
* @param arraybuffer
|
|
65
|
-
* @returns header as LASHeader
|
|
66
|
-
*/
|
|
54
|
+
|
|
67
55
|
function parseLASHeader(arraybuffer) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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;
|
|
84
72
|
}
|
|
85
|
-
|
|
86
|
-
// Loads uncompressed files
|
|
87
|
-
//
|
|
73
|
+
|
|
88
74
|
class LASLoader {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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');
|
|
113
115
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
+
};
|
|
121
133
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
start = header.pointsOffset + readOffset * header.pointsStructSize;
|
|
138
|
-
const end = start + count * header.pointsStructSize;
|
|
139
|
-
readOffset += count;
|
|
140
|
-
this.readOffset = readOffset;
|
|
141
|
-
return {
|
|
142
|
-
buffer: arraybuffer.slice(start, end),
|
|
143
|
-
count,
|
|
144
|
-
hasMoreData: readOffset < header.pointsCount
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
const pointsToRead = Math.min(count * skip, header.pointsCount - readOffset);
|
|
148
|
-
const bufferSize = Math.ceil(pointsToRead / skip);
|
|
149
|
-
let pointsRead = 0;
|
|
150
|
-
const buf = new Uint8Array(bufferSize * header.pointsStructSize);
|
|
151
|
-
for (let i = 0; i < pointsToRead; i++) {
|
|
152
|
-
if (i % skip === 0) {
|
|
153
|
-
start = header.pointsOffset + readOffset * header.pointsStructSize;
|
|
154
|
-
const src = new Uint8Array(arraybuffer, start, header.pointsStructSize);
|
|
155
|
-
buf.set(src, pointsRead * header.pointsStructSize);
|
|
156
|
-
pointsRead++;
|
|
157
|
-
}
|
|
158
|
-
readOffset++;
|
|
159
|
-
}
|
|
160
|
-
this.readOffset = readOffset;
|
|
161
|
-
return {
|
|
162
|
-
buffer: buf.buffer,
|
|
163
|
-
count: pointsRead,
|
|
164
|
-
hasMoreData: readOffset < header.pointsCount
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Method which brings data to null to close the file
|
|
169
|
-
* @returns
|
|
170
|
-
*/
|
|
171
|
-
close() {
|
|
172
|
-
// @ts-ignore Possibly null
|
|
173
|
-
this.arraybuffer = null;
|
|
174
|
-
return true;
|
|
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++;
|
|
175
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
|
+
|
|
176
164
|
}
|
|
177
|
-
|
|
178
|
-
* LAZ Loader
|
|
179
|
-
* Uses NaCL module to load LAZ files
|
|
180
|
-
*/
|
|
165
|
+
|
|
181
166
|
class LAZLoader {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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();
|
|
190
178
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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));
|
|
211
199
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const header = parseLASHeader(this.instance.arraybuffer);
|
|
218
|
-
header.pointsFormatId &= 0x3f;
|
|
219
|
-
this.header = header;
|
|
220
|
-
return header;
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
throw new Error(`Failed to get header: ${error.message}`);
|
|
224
|
-
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
getHeader() {
|
|
203
|
+
if (!this.instance) {
|
|
204
|
+
throw new Error('You need to open the file before trying to read header');
|
|
225
205
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
throw new Error('You need to open the file before trying to read stuff');
|
|
235
|
-
}
|
|
236
|
-
const { header, instance } = this;
|
|
237
|
-
if (!header) {
|
|
238
|
-
throw new Error('You need to query header before reading, I maintain state that way, sorry :(');
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
const pointsToRead = Math.min(count * skip, header.pointsCount - instance.readOffset);
|
|
242
|
-
const bufferSize = Math.ceil(pointsToRead / skip);
|
|
243
|
-
let pointsRead = 0;
|
|
244
|
-
const thisBuf = new Uint8Array(bufferSize * header.pointsStructSize);
|
|
245
|
-
const bufRead = Module._malloc(header.pointsStructSize);
|
|
246
|
-
for (let i = 0; i < pointsToRead; i++) {
|
|
247
|
-
instance.getPoint(bufRead);
|
|
248
|
-
if (i % skip === 0) {
|
|
249
|
-
const a = new Uint8Array(Module.HEAPU8.buffer, bufRead, header.pointsStructSize);
|
|
250
|
-
thisBuf.set(a, pointsRead * header.pointsStructSize);
|
|
251
|
-
pointsRead++;
|
|
252
|
-
}
|
|
253
|
-
instance.readOffset++;
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
buffer: thisBuf.buffer,
|
|
257
|
-
count: pointsRead,
|
|
258
|
-
hasMoreData: instance.readOffset < header.pointsCount
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
catch (error) {
|
|
262
|
-
throw new Error(`Failed to read data: ${error.message}`);
|
|
263
|
-
}
|
|
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));
|
|
264
214
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
if (this.instance !== null) {
|
|
272
|
-
this.instance.delete();
|
|
273
|
-
this.instance = null;
|
|
274
|
-
}
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
catch (error) {
|
|
278
|
-
throw new Error(`Failed to close file: ${error.message}`);
|
|
279
|
-
}
|
|
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');
|
|
280
220
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
this.pointsCount = len;
|
|
290
|
-
this.pointSize = header.pointsStructSize;
|
|
291
|
-
this.scale = header.scale;
|
|
292
|
-
this.offset = header.offset;
|
|
293
|
-
this.mins = header.mins;
|
|
294
|
-
this.maxs = header.maxs;
|
|
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 :(');
|
|
295
229
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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++;
|
|
304
246
|
}
|
|
305
|
-
|
|
306
|
-
|
|
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));
|
|
307
258
|
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
this.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (this.determineVersion() > 13) {
|
|
321
|
-
throw new Error('Only file versions <= 1.3 are supported at this time');
|
|
322
|
-
}
|
|
323
|
-
this.determineFormat();
|
|
324
|
-
if (POINT_FORMAT_READERS[this.formatId] === undefined) {
|
|
325
|
-
throw new Error('The point format ID is not supported');
|
|
326
|
-
}
|
|
327
|
-
this.loader = this.isCompressed
|
|
328
|
-
? new LAZLoader(this.arraybuffer)
|
|
329
|
-
: new LASLoader(this.arraybuffer);
|
|
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));
|
|
330
271
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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');
|
|
353
307
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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');
|
|
362
335
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return this.loader.getHeader();
|
|
336
|
+
|
|
337
|
+
this.determineFormat();
|
|
338
|
+
|
|
339
|
+
if (POINT_FORMAT_READERS[this.formatId] === undefined) {
|
|
340
|
+
throw new Error('The point format ID is not supported');
|
|
369
341
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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');
|
|
378
353
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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;
|
|
386
369
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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;
|
|
391
383
|
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
getUnpacker() {
|
|
387
|
+
return LASDecoder;
|
|
388
|
+
}
|
|
389
|
+
|
|
392
390
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
/* eslint no-use-before-define: 2 */
|
|
391
|
+
export const LASModuleWasLoaded = false;
|
|
392
|
+
//# sourceMappingURL=laslaz-decoder.js.map
|