Skip to content

Commit

Permalink
test(LAZPArser): add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Desplandis committed Sep 15, 2023
1 parent 288f06c commit d93bebc
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/unit/lazparser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import assert from 'assert';
import { HttpsProxyAgent } from 'https-proxy-agent';
import LAZParser from 'Parser/LAZParser';
import Fetcher from 'Provider/Fetcher';

describe('LAZParser', function () {
let lazChunk;
let parser;

before(async function () {
const networkOptions = process.env.HTTPS_PROXY ? {
agent: new HttpsProxyAgent(process.env.HTTPS_PROXY),
headers: { range: 'bytes=79462688-80225945' },
} : {
headers: { range: 'bytes=79462688-80225945' },
};
const url = 'https://s3.amazonaws.com/hobu-lidar/autzen-classified.copc.laz';
lazChunk = await Fetcher.arrayBuffer(url, networkOptions);
parser = LAZParser.parseChunk({
baseUrl: './node_modules/laz-perf/lib',
});
});

it('parses a laz file to a THREE.BufferGeometry', async function () {
const min = [635577.79, 848882.15, 406.14];
const max = [639003.73, 853537.66, 615.26];

const header = {
pointDataRecordFormat: 7,
pointDataRecordLength: 36,
scale: [0.01, 0.01, 0.01],
offset: [637290.75, 851209.9, 510.7],
};
const bufferGeometry = await parser(lazChunk, {
in: {
pointCount: 61201,
header,
eb: [],
},
out: {},
});

const epsilon = 0.1;

assert.ok(bufferGeometry.boundingBox.min.x + epsilon >= min[0]);
assert.ok(bufferGeometry.boundingBox.min.y + epsilon >= min[1]);
assert.ok(bufferGeometry.boundingBox.min.z + epsilon >= min[2]);
assert.ok(bufferGeometry.boundingBox.max.x - epsilon <= max[0]);
assert.ok(bufferGeometry.boundingBox.max.y - epsilon <= max[1]);
assert.ok(bufferGeometry.boundingBox.max.z - epsilon <= max[2]);
});
});

0 comments on commit d93bebc

Please sign in to comment.