Skip to content

Commit

Permalink
fix(test): fetch local laz files behind proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Dec 2, 2021
1 parent 92cf0a3 commit b732c0a
Showing 1 changed file with 33 additions and 46 deletions.
79 changes: 33 additions & 46 deletions test/unit/lasparser.js
Expand Up @@ -11,55 +11,42 @@ describe('LASParser', function () {
return a - epsilon < b && a + epsilon > b;
}

before((done) => {
Promise.all([Fetcher.arrayBuffer(
'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/data_test.las',
{ networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {} },
), Fetcher.arrayBuffer(
'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/data_test.laz',
{ networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {} },
)]).then((res) => {
lasData = res[0];
lazData = res[1];
done();
});
before(async () => {
const networkOptions = process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {};
const baseurl = 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/';
lazData = await Fetcher.arrayBuffer(`${baseurl}data_test.laz`, networkOptions);
lasData = await Fetcher.arrayBuffer(`${baseurl}data_test.las`, networkOptions);
});

it('parses a las file to a THREE.BufferGeometry', (done) => {
LASParser.parse(lasData).then((bufferGeometry) => {
assert.strictEqual(bufferGeometry.userData.pointsCount, 106);
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.color, undefined);

assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));

done();
});
it('parses a las file to a THREE.BufferGeometry', async () => {
const bufferGeometry = await LASParser.parse(lasData);
assert.strictEqual(bufferGeometry.userData.pointsCount, 106);
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.color, undefined);

assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));
});

it('parses a laz file to a THREE.BufferGeometry', (done) => {
LASParser.parse(lazData).then((bufferGeometry) => {
assert.strictEqual(bufferGeometry.userData.pointsCount, 57084);
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.color, undefined);

assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));

done();
});
it('parses a laz file to a THREE.BufferGeometry', async () => {
const bufferGeometry = await LASParser.parse(lazData);
assert.strictEqual(bufferGeometry.userData.pointsCount, 57084);
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
assert.strictEqual(bufferGeometry.attributes.color, undefined);

assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));
});
});

0 comments on commit b732c0a

Please sign in to comment.