Skip to content

Commit

Permalink
test(lasparser): add test for parseChunk
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Oct 3, 2024
1 parent 7cb0195 commit 3c3ab33
Showing 1 changed file with 63 additions and 6 deletions.
69 changes: 63 additions & 6 deletions test/unit/lasparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@ const lasUrl = `${baseurl}/data_test.las`;
const url = 'https://github.com/connormanning/copc.js/raw/master/src/test/data';
const lazV14Url = `${url}/ellipsoid-1.4.laz`;

const copcUrl = `${url}/ellipsoid.copc.laz`;

describe('LASParser', function () {
let lasData;
let lazV14Data;
it('fetch binaries', async function () {
let copcData;
describe('fetch binaries', function () {
const networkOptions = process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {};
lasData = await Fetcher.arrayBuffer(lasUrl, networkOptions);
lazV14Data = await Fetcher.arrayBuffer(lazV14Url, networkOptions);
}).timeout(4000);
it('fetch las data', async function () {
lasData = await Fetcher.arrayBuffer(lasUrl, networkOptions);
});
it('fetch laz data', async function () {
lazV14Data = await Fetcher.arrayBuffer(lazV14Url, networkOptions);
});
it('fetch copc data', async function _it() {
copcData = await Fetcher.arrayBuffer(copcUrl, networkOptions);
});
});

describe('unit tests', function () {
describe('unit tests', function _describe() {
const epsilon = 0.1;
LASParser.enableLazPerf('./examples/libs/laz-perf');

Expand All @@ -40,6 +50,7 @@ describe('LASParser', function () {
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x + origin.x, header.max[0], epsilon));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y + origin.y, header.max[1], epsilon));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z + origin.z, header.max[2], epsilon));
await LASParser.terminate();
});

it('parses a laz file to a THREE.BufferGeometry', async function () {
Expand All @@ -59,9 +70,55 @@ describe('LASParser', function () {
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x + origin.x, header.max[0], epsilon));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y + origin.y, header.max[1], epsilon));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z + origin.z, header.max[2], epsilon));
await LASParser.terminate();
});

afterEach(async function () {
it('parses a copc chunk to a THREE.BufferGeometry', async function _it() {
if (!copcData) { this.skip(); }
const header = {
fileSignature: 'LASF',
fileSourceId: 0,
globalEncoding: 16,
projectId: '00000000-0000-0000-0000000000000000',
majorVersion: 1,
minorVersion: 4,
systemIdentifier: '',
generatingSoftware: '',
fileCreationDayOfYear: 1,
fileCreationYear: 1,
headerLength: 375,
pointDataOffset: 1424,
vlrCount: 3,
pointDataRecordFormat: 7,
pointDataRecordLength: 36,
pointCount: 100000,
pointCountByReturn: [
50002, 49998, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0,
],
scale: [0.01, 0.01, 0.01],
offset: [-8242596, 4966606, 0],
min: [-8242746, 4966506, -50],
max: [-8242446, 4966706, 50],
waveformDataOffset: 0,
evlrOffset: 630520,
evlrCount: 1,
};
const options = {
in: {
pointCount: header.pointCount,
header,
},
// eb,
};
const bufferGeometry = await LASParser.parseChunk(copcData, options);

assert.strictEqual(bufferGeometry.attributes.position.count, header.pointCount);
assert.strictEqual(bufferGeometry.attributes.intensity.count, header.pointCount);
assert.strictEqual(bufferGeometry.attributes.classification.count, header.pointCount);
assert.strictEqual(bufferGeometry.attributes.color.count, header.pointCount);
await LASParser.terminate();
});
});
Expand Down

0 comments on commit 3c3ab33

Please sign in to comment.