Skip to content

Commit

Permalink
test: add more tiff tag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Nov 26, 2023
1 parent 933db52 commit e9c8714
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/__test__/cog.image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SourceMemory } from '../__benchmark__/source.memory.js';
import { TiffMimeType } from '../const/tiff.mime.js';
import { Tiff } from '../tiff.js';
import { ByteSize } from '../util/bytes.js';
import { Photometric, TiffTag } from '../const/tiff.tag.id.js';

// 900913 properties.
const A = 6378137.0;
Expand Down Expand Up @@ -133,6 +134,11 @@ describe('Cog.Sparse', () => {
const { tileCount } = img;
assert.deepEqual(tileCount, { x: 2, y: 2 });

assert.equal(img.value(TiffTag.SamplesPerPixel), 4); // 4 bands
assert.deepEqual(img.value(TiffTag.BitsPerSample), [8, 8, 8, 8]);
assert.equal(img.value(TiffTag.Photometric), Photometric.Rgb);
assert.equal(img.value(TiffTag.GdalNoData), null);

for (let x = 0; x < tileCount.x; x++) {
for (let y = 0; y < tileCount.y; y++) {
const hasTile = await img.hasTile(x, y);
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/__test__/cog.read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TiffMimeType } from '../const/tiff.mime.js';
import { TiffVersion } from '../const/tiff.version.js';
import { TiffTag, TiffTagGeo } from '../index.js';
import { Tiff } from '../tiff.js';
import { Photometric, SampleFormat } from '../const/tiff.tag.id.js';

function validate(tif: Tiff): void {
assert.equal(tif.images.length, 5);
Expand Down Expand Up @@ -79,6 +80,12 @@ describe('CogRead', () => {
assert.equal(im.epsg, 2193);
assert.equal(im.compression, TiffMimeType.None);
assert.equal(im.isTiled(), false);

// 32 bit float DEM
assert.deepEqual(im.value(TiffTag.BitsPerSample), 32);
assert.equal(im.value(TiffTag.SampleFormat), SampleFormat.Float);
assert.equal(im.value(TiffTag.Photometric), Photometric.MinIsBlack);

assert.equal(im.tagsGeo.get(TiffTagGeo.GTCitationGeoKey), 'NZGD2000 / New Zealand Transverse Mercator 2000');
assert.equal(im.tagsGeo.get(TiffTagGeo.GeodeticCitationGeoKey), 'NZGD2000');
assert.deepEqual(await im.fetch(TiffTag.StripByteCounts), [8064, 8064, 8064, 8064, 8064, 8064, 8064, 5040]);
Expand All @@ -96,6 +103,7 @@ describe('CogRead', () => {
assert.equal(im.isGeoTagsLoaded, true);
assert.equal(im.epsg, 2193);
assert.equal(im.compression, TiffMimeType.Lzw);
assert.deepEqual(im.value(TiffTag.BitsPerSample), [8, 8, 8, 8]);

const geoTags = [...im.tagsGeo.keys()].map((key) => TiffTagGeo[key]);
assert.deepEqual(geoTags, [
Expand Down

0 comments on commit e9c8714

Please sign in to comment.