-
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.
refactor: missing files clean up types
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
packages/tiler-sharp/src/pipeline/__tests__/pipeline.color.ramp.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,66 @@ | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
import { Tiff } from '@basemaps/shared'; | ||
import { CompositionTiff } from '@basemaps/tiler'; | ||
|
||
import { DecompressedInterleaved } from '../decompressor.js'; | ||
import { PipelineColorRamp } from '../pipeline.color.ramp.js'; | ||
|
||
const FakeTiff = { images: [{ noData: -9999, resolution: [0.1, -0.1] }] } as unknown as Tiff; | ||
const FakeComp = { asset: FakeTiff, source: { x: 0, y: 0, imageId: 0 } } as CompositionTiff; | ||
|
||
describe('pipeline.color-ramp', () => { | ||
it('should color-ramp a float32 DEM with default ramp', async () => { | ||
const bytes: DecompressedInterleaved = { | ||
pixels: new Float32Array([-9999, 0, 100]), | ||
depth: 'float32', | ||
channels: 1, | ||
width: 3, | ||
height: 1, | ||
}; | ||
|
||
const output = await PipelineColorRamp.process(FakeComp, bytes); | ||
|
||
assert.equal(output.channels, 4); | ||
|
||
assert.equal(String(output.pixels.slice(0, 4)), '0,0,0,0'); | ||
assert.equal(String(output.pixels.slice(4, 8)), '167,205,228,255'); | ||
}); | ||
|
||
it('should color-ramp a uint8', async () => { | ||
const bytes: DecompressedInterleaved = { | ||
pixels: new Uint8Array([0, 128, 255]), | ||
depth: 'uint8', | ||
channels: 1, | ||
width: 3, | ||
height: 1, | ||
}; | ||
|
||
const output = await PipelineColorRamp.process(FakeComp, bytes); | ||
|
||
assert.equal(output.channels, 4); | ||
|
||
assert.equal(String(output.pixels.slice(0, 4)), '0,0,0,255'); | ||
assert.equal(String(output.pixels.slice(4, 8)), '128,128,128,255'); | ||
assert.equal(String(output.pixels.slice(8, 12)), '255,255,255,255'); | ||
}); | ||
|
||
it('should color-ramp a uint32', async () => { | ||
const bytes: DecompressedInterleaved = { | ||
pixels: new Uint32Array([0, 2 ** 31, 2 ** 32 - 1]), | ||
depth: 'uint32', | ||
channels: 1, | ||
width: 3, | ||
height: 1, | ||
}; | ||
|
||
const output = await PipelineColorRamp.process(FakeComp, bytes); | ||
|
||
assert.equal(output.channels, 4); | ||
|
||
assert.equal(String(output.pixels.slice(0, 4)), '0,0,0,255'); | ||
assert.equal(String(output.pixels.slice(4, 8)), '128,128,128,255'); | ||
assert.equal(String(output.pixels.slice(8, 12)), '255,255,255,255'); | ||
}); | ||
}); |
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