-
Notifications
You must be signed in to change notification settings - Fork 125
/
open_jpg.test.js
83 lines (71 loc) · 2.36 KB
/
open_jpg.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var gdal = require('../lib/gdal.js');
var path = require('path');
var assert = require('chai').assert;
describe('Open', function() {
afterEach(gc);
describe('JPG', function() {
var filename, ds;
it('should not throw', function() {
filename = path.join(__dirname, 'data/a39se10.jpg');
ds = gdal.open(filename);
});
it('should be able to read raster size', function() {
assert.equal(ds.rasterSize.x, 1361);
assert.equal(ds.rasterSize.y, 1744);
assert.equal(ds.bands.count(), 3);
});
it('should be able to read geotransform', function() {
var expected_geotransform = [
1485309.3937136543,
3.28077925649814,
0,
603662.5109447651,
0,
-3.28077925649814
];
var actual_geotransform = ds.geoTransform;
var delta = 0.00001;
assert.closeTo(actual_geotransform[0], expected_geotransform[0], delta);
assert.closeTo(actual_geotransform[1], expected_geotransform[1], delta);
assert.closeTo(actual_geotransform[2], expected_geotransform[2], delta);
assert.closeTo(actual_geotransform[3], expected_geotransform[3], delta);
assert.closeTo(actual_geotransform[4], expected_geotransform[4], delta);
assert.closeTo(actual_geotransform[5], expected_geotransform[5], delta);
});
it('should not have projection', function() {
assert.isNull(ds.srs);
});
it('should be able to read statistics', function() {
var band = ds.bands.get(1);
var expected_stats = {
min: 0,
max: 255,
mean: 118.37471983296146,
std_dev: 50.89389997162665
};
var actual_stats = band.getStatistics(false, true);
var delta = 0.00001;
assert.closeTo(actual_stats.min, expected_stats.min, delta);
assert.closeTo(actual_stats.max, expected_stats.max, delta);
assert.closeTo(actual_stats.mean, expected_stats.mean, delta);
assert.closeTo(actual_stats.std_dev, expected_stats.std_dev, delta);
});
it('should be able to read block size', function() {
var band = ds.bands.get(1);
var size = band.blockSize;
assert.equal(size.x, 1361);
assert.equal(size.y, 1);
});
it('should have file list', function() {
var files = [
path.join(__dirname, 'data/a39se10.jpg'),
path.join(__dirname, 'data/a39se10.jpg.aux.xml'),
path.join(__dirname, 'data/a39se10.jgw')
];
var actual_files = ds.getFileList();
actual_files.sort();
files.sort();
assert.deepEqual(actual_files, files);
});
});
});