Skip to content

Commit 98c1681

Browse files
committed
Test that fillValue works outside the image extent
1 parent d94383f commit 98c1681

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/geotiff.spec.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,53 @@ describe('COG tests', async () => {
549549
expect(ghostValues).to.be.null;
550550
});
551551
});
552+
553+
describe('fillValue', async () => {
554+
it('should fill pixels outside the image area (to the left and above)', async () => {
555+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
556+
const image = await tiff.getImage(0);
557+
const data = await image.readRasters({ window: [-1, -1, 0, 0], fillValue: 42 });
558+
expect(data).to.have.lengthOf(15);
559+
for (const band of data) {
560+
expect(band).to.have.lengthOf(1);
561+
expect(band).to.deep.equal(new Uint16Array([42]));
562+
}
563+
});
564+
565+
it('should fill pixels outside the image area (to the right and below)', async () => {
566+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
567+
const image = await tiff.getImage(0);
568+
const data = await image.readRasters({ window: [512, 512, 513, 513], fillValue: 42 });
569+
expect(data).to.have.lengthOf(15);
570+
for (const band of data) {
571+
expect(band).to.have.lengthOf(1);
572+
expect(band).to.deep.equal(new Uint16Array([42]));
573+
}
574+
});
575+
576+
it('should fill areas in overview tiles outside the image extent (left)', async () => {
577+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
578+
const image = await tiff.getImage(1);
579+
const data = await image.readRasters({ window: [269, 0, 270, 1], fillValue: 42 });
580+
expect(data).to.have.lengthOf(15);
581+
for (const band of data) {
582+
expect(band).to.have.lengthOf(1);
583+
expect(band).to.deep.equal(new Uint16Array([42]));
584+
}
585+
});
586+
587+
it('should fill areas in overview tiles outside the image extent (below)', async () => {
588+
const tiff = await GeoTIFF.fromSource(createSource('cog.tiff'));
589+
const image = await tiff.getImage(1);
590+
const data = await image.readRasters({ window: [0, 224, 1, 225], fillValue: 42 });
591+
expect(data).to.have.lengthOf(15);
592+
for (const band of data) {
593+
expect(band).to.have.lengthOf(1);
594+
expect(band).to.deep.equal(new Uint16Array([42]));
595+
}
596+
});
597+
});
598+
552599
describe("64 bit tests", () => {
553600
it("DataView64 uint64 tests", () => {
554601
const littleEndianBytes = new Uint8Array([

0 commit comments

Comments
 (0)