Skip to content

Commit b732c0a

Browse files
committed
fix(test): fetch local laz files behind proxy.
1 parent 92cf0a3 commit b732c0a

File tree

1 file changed

+33
-46
lines changed

1 file changed

+33
-46
lines changed

test/unit/lasparser.js

+33-46
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,42 @@ describe('LASParser', function () {
1111
return a - epsilon < b && a + epsilon > b;
1212
}
1313

14-
before((done) => {
15-
Promise.all([Fetcher.arrayBuffer(
16-
'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/data_test.las',
17-
{ networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {} },
18-
), Fetcher.arrayBuffer(
19-
'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/data_test.laz',
20-
{ networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {} },
21-
)]).then((res) => {
22-
lasData = res[0];
23-
lazData = res[1];
24-
done();
25-
});
14+
before(async () => {
15+
const networkOptions = process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {};
16+
const baseurl = 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/';
17+
lazData = await Fetcher.arrayBuffer(`${baseurl}data_test.laz`, networkOptions);
18+
lasData = await Fetcher.arrayBuffer(`${baseurl}data_test.las`, networkOptions);
2619
});
2720

28-
it('parses a las file to a THREE.BufferGeometry', (done) => {
29-
LASParser.parse(lasData).then((bufferGeometry) => {
30-
assert.strictEqual(bufferGeometry.userData.pointsCount, 106);
31-
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
32-
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
33-
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
34-
assert.strictEqual(bufferGeometry.attributes.color, undefined);
35-
36-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
37-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
38-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
39-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
40-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
41-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));
42-
43-
done();
44-
});
21+
it('parses a las file to a THREE.BufferGeometry', async () => {
22+
const bufferGeometry = await LASParser.parse(lasData);
23+
assert.strictEqual(bufferGeometry.userData.pointsCount, 106);
24+
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
25+
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
26+
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
27+
assert.strictEqual(bufferGeometry.attributes.color, undefined);
28+
29+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
30+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
31+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
32+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
33+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
34+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));
4535
});
4636

47-
it('parses a laz file to a THREE.BufferGeometry', (done) => {
48-
LASParser.parse(lazData).then((bufferGeometry) => {
49-
assert.strictEqual(bufferGeometry.userData.pointsCount, 57084);
50-
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
51-
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
52-
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
53-
assert.strictEqual(bufferGeometry.attributes.color, undefined);
54-
55-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
56-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
57-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
58-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
59-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
60-
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));
61-
62-
done();
63-
});
37+
it('parses a laz file to a THREE.BufferGeometry', async () => {
38+
const bufferGeometry = await LASParser.parse(lazData);
39+
assert.strictEqual(bufferGeometry.userData.pointsCount, 57084);
40+
assert.strictEqual(bufferGeometry.attributes.position.count, bufferGeometry.userData.pointsCount);
41+
assert.strictEqual(bufferGeometry.attributes.intensity.count, bufferGeometry.userData.pointsCount);
42+
assert.strictEqual(bufferGeometry.attributes.classification.count, bufferGeometry.userData.pointsCount);
43+
assert.strictEqual(bufferGeometry.attributes.color, undefined);
44+
45+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.x, bufferGeometry.userData.mins[0], 0.1));
46+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.y, bufferGeometry.userData.mins[1], 0.1));
47+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.min.z, bufferGeometry.userData.mins[2], 0.1));
48+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.x, bufferGeometry.userData.maxs[0], 0.1));
49+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.y, bufferGeometry.userData.maxs[1], 0.1));
50+
assert.ok(compareWithEpsilon(bufferGeometry.boundingBox.max.z, bufferGeometry.userData.maxs[2], 0.1));
6451
});
6552
});

0 commit comments

Comments
 (0)