-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
321 additions
and
1,090 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
const test = require('tape'); | ||
const test = require('node:test'); | ||
const assert = require('node:assert/strict'); | ||
const fileBag = require('../lib/file-bag'); | ||
|
||
|
||
test('file bag', function (t) { | ||
test('file bag', async function (t) { | ||
|
||
t.test('find file for valid point', function (t) { | ||
await t.test('find file for valid point', function () { | ||
|
||
const data = require('./fixtures/data-with-meta/tatry.json'); | ||
const fb = fileBag(data); | ||
|
||
const { file, meta } = fb.find([ -106.827126, 40.483468 ]); | ||
t.equal(file, '/var/lib/tatry/srmt-250m_13_3.tif'); | ||
const { file, meta } = fb.find([-106.827126, 40.483468]); | ||
assert.equal(file, '/var/lib/tatry/srmt-250m_13_3.tif'); | ||
|
||
t.equal(meta.width, 480); | ||
t.equal(meta.height, 192); | ||
t.equal(meta.it.length, 6); | ||
t.end(); | ||
assert.equal(meta.width, 480); | ||
assert.equal(meta.height, 192); | ||
assert.equal(meta.it.length, 6); | ||
}); | ||
|
||
t.test('find file with best resolution', function (t) { | ||
await t.test('find file with best resolution', function () { | ||
|
||
const data = require('./fixtures/data-with-meta/tatry-resolution.json'); | ||
const fb = fileBag(data); | ||
|
||
const { file, meta } = fb.find([ -106.827126, 40.483468 ]); | ||
t.equal(file, '/var/lib/tatry/srmt-60m_13_3.tif'); | ||
const { file, meta } = fb.find([-106.827126, 40.483468]); | ||
assert.equal(file, '/var/lib/tatry/srmt-60m_13_3.tif'); | ||
|
||
t.equal(meta.width, 480); | ||
t.equal(meta.height, 192); | ||
t.equal(meta.it.length, 6); | ||
t.end(); | ||
assert.equal(meta.width, 480); | ||
assert.equal(meta.height, 192); | ||
assert.equal(meta.it.length, 6); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
const test = require('tape'); | ||
const test = require('node:test'); | ||
const assert = require('node:assert/strict'); | ||
const interpolate = require('../lib/interpolate'); | ||
|
||
|
||
test('interpolate should calculate bilinear interpolation', function (t) { | ||
test('interpolate should calculate bilinear interpolation', function () { | ||
function approx(a, b, e, msg = `${a} should differ from ${b} by no more than ${e}`) { | ||
t.ok(Math.abs(a - b) < e, msg); | ||
assert(Math.abs(a - b) < e, msg); | ||
} | ||
|
||
let window = [ | ||
14, 20, | ||
15, 21 | ||
]; | ||
let point = [ 14.5, 20.2 ]; | ||
let point = [14.5, 20.2]; | ||
let values = [ | ||
91, 210, | ||
162, 95 | ||
]; | ||
|
||
t.plan(1); | ||
let v = interpolate(point, window, values); | ||
approx(v, 146.1, 0.000000001); | ||
}); |
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 |
---|---|---|
@@ -1,72 +1,61 @@ | ||
const test = require('tape'); | ||
const test = require('node:test'); | ||
const assert = require('node:assert/strict'); | ||
const { promises: { open }, constants: { O_RDONLY } } = require('fs'); | ||
const path = require('path'); | ||
|
||
const { header, ifd, parse } = require('../../lib/lame-tiff/file'); | ||
|
||
test('tiff file', function (t) { | ||
test('tiff file', async function (t) { | ||
const file = path.resolve(__dirname, '..', 'fixtures', 'data', 'srmt-250m_13_3.tif'); | ||
let fh; | ||
const fh = await open(file, O_RDONLY); | ||
|
||
t.test('before', async function(t) { | ||
fh = await open(file, O_RDONLY); | ||
t.end(); | ||
}); | ||
|
||
t.test('should parse header', async function (t) { | ||
|
||
t.plan(3); | ||
await t.test('should parse header', async function () { | ||
const h = await header(fh); | ||
|
||
t.equal(h.fh, fh); | ||
t.equal(h.littleEndian, true); | ||
t.equal(h.ifdOffset, 8); | ||
assert.equal(h.fh, fh); | ||
assert.equal(h.littleEndian, true); | ||
assert.equal(h.ifdOffset, 8); | ||
}); | ||
|
||
t.test('should parse ifd', async function (t) { | ||
await t.test('should parse ifd', async function () { | ||
|
||
const data = await ifd({ | ||
fh: fh, | ||
littleEndian: true, | ||
ifdOffset: 8 | ||
}); | ||
|
||
t.equal(data.length, 12); | ||
assert.equal(data.length, 12); | ||
data.forEach(d => { | ||
t.ok(d.name); | ||
t.ok(d.value); | ||
assert(d.name); | ||
assert(d.value); | ||
}); | ||
t.end(); | ||
}); | ||
|
||
t.test('should parse file directory', async function (t) { | ||
|
||
t.plan(4); | ||
await t.test('should parse file directory', async function () { | ||
|
||
const result = await parse(file); | ||
|
||
t.ok(result.fh); | ||
t.ok(result.littleEndian); | ||
t.ok(result.fileDirectory); | ||
t.same(result.fileDirectory, { | ||
assert(result.fh); | ||
assert(result.littleEndian); | ||
assert(result.fileDirectory); | ||
assert.deepEqual(result.fileDirectory, { | ||
ImageWidth: 480, | ||
ImageLength: 192, | ||
BitsPerSample: 16, | ||
Compression: 1, | ||
StripOffsets: [ 578, 8258, 15938, 23618, 31298, 38978, 46658, 54338, 62018, 69698, 77378, 85058, 92738, 100418, 108098, 115778, 123458, 131138, 138818, 146498, 154178, 161858, 169538, 177218 ], | ||
StripOffsets: [578, 8258, 15938, 23618, 31298, 38978, 46658, 54338, 62018, 69698, 77378, 85058, 92738, 100418, 108098, 115778, 123458, 131138, 138818, 146498, 154178, 161858, 169538, 177218], | ||
SamplesPerPixel: 1, | ||
RowsPerStrip: 8, | ||
StripByteCounts: [ 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680 ], | ||
StripByteCounts: [7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680, 7680], | ||
PlanarConfiguration: 1, | ||
SampleFormat: 2, | ||
ModelPixelScale: [ 0.00208333333, 0.00208333333, 0 ], | ||
ModelTiepoint: [ 0, 0, 0, -107.00208331573002, 40.808333172039994, 0 ], | ||
ModelPixelScale: [0.00208333333, 0.00208333333, 0], | ||
ModelTiepoint: [0, 0, 0, -107.00208331573002, 40.808333172039994, 0], | ||
}); | ||
}); | ||
|
||
t.test('after', async function(t) { | ||
await fh.close(); | ||
t.end(); | ||
await result.fh.close(); | ||
}); | ||
|
||
await fh.close(); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
const test = require('tape'); | ||
const test = require('node:test'); | ||
const assert = require('node:assert/strict'); | ||
const path = require('path'); | ||
|
||
const metas = require('../lib/metas'); | ||
|
||
test('metas should extract metas from directory', async function (t) { | ||
test('metas should extract metas from directory', async function () { | ||
|
||
const dir = path.resolve(__dirname, 'fixtures', 'data'); | ||
|
||
t.plan(2); | ||
|
||
const data = await metas(dir); | ||
t.ok(data); | ||
t.equal(data.length, 2); | ||
assert(data); | ||
assert.equal(data.length, 2); | ||
}); |
Oops, something went wrong.