-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for LZW compression
- Loading branch information
Showing
19 changed files
with
467 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/tiler-sharp/src/pipeline/__tests__/decompress.lzw.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { before, describe, it } from 'node:test'; | ||
|
||
import { fsa } from '@basemaps/shared'; | ||
import { TestTiff } from '@basemaps/test'; | ||
import { Tiff } from '@cogeotiff/core'; | ||
import assert from 'assert'; | ||
import { createHash } from 'crypto'; | ||
|
||
import { LzwDecompressor } from '../decompressor.lzw.js'; | ||
|
||
describe('decompressor.lzw', () => { | ||
let tiff: Tiff; | ||
before(async () => { | ||
tiff = await Tiff.create(fsa.source(TestTiff.CompressLzw)); | ||
}); | ||
|
||
it('should decode a 64x64 lzw tile', async () => { | ||
const tile = await tiff.images[0].getTile(0, 0); | ||
|
||
const ret = await LzwDecompressor.decompress({ | ||
tiff, | ||
imageId: 0, | ||
x: 0, | ||
y: 0, | ||
bytes: tile!.bytes, | ||
}); | ||
|
||
const dataHash = createHash('sha256').update(ret.buffer).digest('hex'); | ||
console.log(dataHash); | ||
|
||
assert.equal(ret.width, 512); | ||
assert.equal(ret.height, 512); | ||
assert.equal(ret.buffer.length, 512 * 512); | ||
assert.equal(ret.buffer[0], 0x02); | ||
assert.equal(dataHash, '21cfddfdab9b130811a6d6f62f14bf67291698e6a0659538b75bc5ab4e5983db'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.