Skip to content

Commit 7ef9c2e

Browse files
committed
User workers for slow fillValue tests
1 parent d634bcf commit 7ef9c2e

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/geotiff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class GeoTIFF extends GeoTIFFBase {
451451
* Get the n-th internal subfile of an image. By default, the first is returned.
452452
*
453453
* @param {Number} [index=0] the index of the image to return.
454-
* @returns {GeoTIFFImage} the image at the given index
454+
* @returns {Promise<GeoTIFFImage>} the image at the given index
455455
*/
456456
async getImage(index = 0) {
457457
const ifd = await this.requestIFD(index);

test/geotiff.spec.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@ import DataView64 from '../dist-module/dataview64.js';
1818

1919
const __dirname = dirname(new URL(import.meta.url).pathname);
2020

21-
// Set up a node server to make tiffs available at localhost:3000/test/data
21+
// Set up a node server to make tiffs available at localhost:3000/test/data, and a worker pool
2222
let server = null;
23+
let pool = null;
2324
before(async () => {
2425
const serve = serveStatic(__dirname);
2526
server = http.createServer((req, res) => {
2627
serve(req, res, finalhandler(req, res));
2728
});
2829
server.listen(3000);
30+
pool = new Pool();
2931
});
3032

3133
after(async () => {
3234
server.close();
35+
pool.destroy();
3336
});
3437

3538
function createSource(filename) {
@@ -256,11 +259,11 @@ describe('GeoTIFF', () => {
256259
});
257260

258261
it('should work with worker pool', async () => {
259-
const pool = new Pool();
262+
const testPool = new Pool();
260263
const tiff = await GeoTIFF.fromSource(createSource('nasa_raster.tiff'));
261264
const image = await tiff.getImage();
262-
await image.readRasters({ pool });
263-
pool.destroy();
265+
await image.readRasters({ pool: testPool });
266+
testPool.destroy();
264267
});
265268

266269
it('should work with LZW compressed tiffs that have an EOI Code after a CLEAR code', async () => {
@@ -650,21 +653,21 @@ describe('fillValue', async () => {
650653
}
651654
});
652655

653-
it('should fill areas in overview tiles outside the image extent (left)', async () => {
656+
it('should fill areas in overview tiles outside the image extent (left, with worker pool)', async () => {
654657
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
655658
const image = await tiff.getImage(1);
656-
const data = await image.readRasters({ window: [269, 0, 270, 1], fillValue: 42 });
659+
const data = await image.readRasters({ window: [269, 0, 270, 1], fillValue: 42, pool });
657660
expect(data).to.have.lengthOf(15);
658661
for (const band of data) {
659662
expect(band).to.have.lengthOf(1);
660663
expect(band).to.deep.equal(new Uint16Array([42]));
661664
}
662665
}).timeout(10000);
663666

664-
it('should fill areas in overview tiles outside the image extent (below)', async () => {
667+
it('should fill areas in overview tiles outside the image extent (below, with worker pool)', async () => {
665668
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
666669
const image = await tiff.getImage(1);
667-
const data = await image.readRasters({ window: [0, 224, 1, 225], fillValue: 42 });
670+
const data = await image.readRasters({ window: [0, 224, 1, 225], fillValue: 42, pool });
668671
expect(data).to.have.lengthOf(15);
669672
for (const band of data) {
670673
expect(band).to.have.lengthOf(1);

0 commit comments

Comments
 (0)