Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

geotiff

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geotiff - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

test/data/setup_data.sh

297

dist/geotiff.js

@@ -275,8 +275,12 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

* @param {ArrayBuffer} rawData the raw data stream of the file as an ArrayBuffer.
* @param {Object} [options] further options.
* @param {Boolean} [options.cache=false] whether or not decoded tiles shall be cached.
*/
function GeoTIFF(rawData) {
function GeoTIFF(rawData, options) {
_classCallCheck(this, GeoTIFF);
this.dataView = new DataView(rawData);
options = options || {};
this.cache = options.cache || false;

@@ -467,3 +471,3 @@ var BOM = this.dataView.getUint16(0, 0);

}
return new _geotiffimage2.default(fileDirectoryAndGeoKey[0], fileDirectoryAndGeoKey[1], this.dataView, this.littleEndian);
return new _geotiffimage2.default(fileDirectoryAndGeoKey[0], fileDirectoryAndGeoKey[1], this.dataView, this.littleEndian, this.cache);
}

@@ -528,2 +532,39 @@

var arrayForType = function arrayForType(format, bitsPerSample, size) {
switch (format) {
case 1:
// unsigned integer data
switch (bitsPerSample) {
case 8:
return new Uint8Array(size);
case 16:
return new Uint16Array(size);
case 32:
return new Uint32Array(size);
}
break;
case 2:
// twos complement signed integer data
switch (bitsPerSample) {
case 8:
return new Int8Array(size);
case 16:
return new Int16Array(size);
case 32:
return new Int32Array(size);
}
break;
case 3:
// floating point data
switch (bitsPerSample) {
case 32:
return new Float32Array(size);
case 64:
return new Float64Array(size);
}
break;
}
throw Error("Unsupported data format/bitsPerSample");
};
var GeoTIFFImage = function () {

@@ -537,5 +578,6 @@ /**

* @param {Boolean} littleEndian Whether the file is encoded in little or big endian
* @param {Boolean} cache Whether or not decoded tiles shall be cached
*/
function GeoTIFFImage(fileDirectory, geoKeys, dataView, littleEndian) {
function GeoTIFFImage(fileDirectory, geoKeys, dataView, littleEndian, cache) {
_classCallCheck(this, GeoTIFFImage);

@@ -547,3 +589,3 @@

this.littleEndian = littleEndian;
this.tiles = {};
this.tiles = cache ? {} : null;
this.isTiled = fileDirectory.StripOffsets ? false : true;

@@ -729,36 +771,3 @@ var planarConfiguration = fileDirectory.PlanarConfiguration;

var bitsPerSample = this.fileDirectory.BitsPerSample[sampleIndex];
switch (format) {
case 1:
// unsigned integer data
switch (bitsPerSample) {
case 8:
return new Uint8Array(size);
case 16:
return new Uint16Array(size);
case 32:
return new Uint32Array(size);
}
break;
case 2:
// twos complement signed integer data
switch (bitsPerSample) {
case 8:
return new Int8Array(size);
case 16:
return new Int16Array(size);
case 32:
return new Int32Array(size);
}
break;
case 3:
// floating point data
switch (bitsPerSample) {
case 32:
return new Float32Array(size);
case 64:
return new Float64Array(size);
}
break;
}
throw Error("Unsupported data format/bitsPerSample");
return arrayForType(format, bitsPerSample, size);
}

@@ -780,4 +789,4 @@ }, {

}, {
key: "getTileOrStripAsync",
value: function getTileOrStripAsync(x, y, sample, callback) {
key: "getTileOrStrip",
value: function getTileOrStrip(x, y, sample, callback) {
var numTilesPerRow = Math.ceil(this.getWidth() / this.getTileWidth());

@@ -793,6 +802,7 @@ var numTilesPerCol = Math.ceil(this.getHeight() / this.getTileHeight());

if (index in this.tiles && false) {
return callback(null, {
x: x, y: y, sample: sample, data: tiles[index]
});
if (tiles !== null && index in tiles) {
if (callback) {
return callback(null, { x: x, y: y, sample: sample, data: tiles[index] });
}
return tiles[index];
} else {

@@ -808,35 +818,15 @@ var offset, byteCount;

var slice = this.dataView.buffer.slice(offset, offset + byteCount);
return this.getDecoder().decodeBlockAsync(slice, function (error, data) {
if (!error) {
tiles[index] = data;
}
callback(error, { x: x, y: y, sample: sample, data: data });
});
}
}
}, {
key: "getTileOrStrip",
value: function getTileOrStrip(x, y, sample) {
var numTilesPerRow = Math.ceil(this.getWidth() / this.getTileWidth());
var numTilesPerCol = Math.ceil(this.getHeight() / this.getTileHeight());
var index;
if (this.planarConfiguration === 1) {
index = y * numTilesPerRow + x;
} else if (this.planarConfiguration === 2) {
index = sample * numTilesPerRow * numTilesPerCol + y * numTilesPerRow + x;
}
if (index in this.tiles) {
return this.tiles[index];
} else {
var offset, byteCount;
if (this.isTiled) {
offset = this.fileDirectory.TileOffsets[index];
byteCount = this.fileDirectory.TileByteCounts[index];
} else {
offset = this.fileDirectory.StripOffsets[index];
byteCount = this.fileDirectory.StripByteCounts[index];
if (callback) {
return this.getDecoder().decodeBlockAsync(slice, function (error, data) {
if (!error && tiles !== null) {
tiles[index] = data;
}
callback(error, { x: x, y: y, sample: sample, data: data });
});
}
var slice = this.dataView.buffer.slice(offset, offset + byteCount);
return this.tiles[index] = this.getDecoder().decodeBlock(slice);
var block = this.getDecoder().decodeBlock(slice);
if (tiles !== null) {
tiles[index] = block;
}
return block;
}

@@ -846,3 +836,3 @@ }

key: "_readRasterAsync",
value: function _readRasterAsync(imageWindow, samples, valueArrays, callback, callbackError) {
value: function _readRasterAsync(imageWindow, samples, valueArrays, interleave, callback, callbackError) {
var tileWidth = this.getTileWidth();

@@ -893,4 +883,11 @@ var tileHeight = this.getTileHeight();

var pixelOffset = (y * tileWidth + x) * bytesPerPixel;
var windowCoordinate = (y + firstLine - imageWindow[1]) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[_sampleIndex][windowCoordinate] = sampleReaders[_sampleIndex].call(dataView, pixelOffset + srcSampleOffsets[_sampleIndex], littleEndian);
var value = sampleReaders[_sampleIndex].call(dataView, pixelOffset + srcSampleOffsets[_sampleIndex], littleEndian);
var windowCoordinate;
if (interleave) {
windowCoordinate = (y + firstLine - imageWindow[1]) * windowWidth * samples.length + (x + firstCol - imageWindow[0]) * samples.length + _sampleIndex;
valueArrays[windowCoordinate] = value;
} else {
windowCoordinate = (y + firstLine - imageWindow[1]) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[_sampleIndex][windowCoordinate] = value;
}
}

@@ -935,3 +932,3 @@ }

key: "_readRaster",
value: function _readRaster(imageWindow, samples, valueArrays, callback, callbackError) {
value: function _readRaster(imageWindow, samples, valueArrays, interleave, callback, callbackError) {
try {

@@ -965,4 +962,4 @@ var tileWidth = this.getTileWidth();

for (var yTile = minYTile; yTile <= maxYTile; ++yTile) {
for (var xTile = minXTile; xTile <= maxXTile; ++xTile) {
for (var yTile = minYTile; yTile < maxYTile; ++yTile) {
for (var xTile = minXTile; xTile < maxXTile; ++xTile) {
var firstLine = yTile * tileHeight;

@@ -983,4 +980,11 @@ var firstCol = xTile * tileWidth;

var pixelOffset = (y * tileWidth + x) * bytesPerPixel;
var windowCoordinate = (y + firstLine - imageWindow[1]) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[sampleIndex][windowCoordinate] = sampleReaders[sampleIndex].call(tile, pixelOffset + srcSampleOffsets[sampleIndex], this.littleEndian);
var value = sampleReaders[sampleIndex].call(tile, pixelOffset + srcSampleOffsets[sampleIndex], this.littleEndian);
var windowCoordinate;
if (interleave) {
windowCoordinate = (y + firstLine - imageWindow[1]) * windowWidth * samples.length + (x + firstCol - imageWindow[0]) * samples.length + sampleIndex;
valueArrays[windowCoordinate] = value;
} else {
windowCoordinate = (y + firstLine - imageWindow[1]) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[sampleIndex][windowCoordinate] = value;
}
}

@@ -991,3 +995,4 @@ }

}
return callback(valueArrays);
callback(valueArrays);
return valueArrays;
} catch (error) {

@@ -1002,3 +1007,6 @@ return callbackError(error);

* @callback GeoTIFFImage~readCallback
* @param {TypedArray[]} array the requested data as a summary array, one TypedArray for each requested sample
* @param {(TypedArray|TypedArray[])} array the requested data as a either a
* single typed array or a list of
* typed arrays, depending on the
* 'interleave' option.
*/

@@ -1018,6 +1026,17 @@

*
* @param {Array} [imageWindow=whole image] the subset to read data from.
* @param {Array} [samples=all samples] the selection of samples to read from.
* @param {GeoTIFFImage~readCallback} callback the success callback
* @param {GeoTIFFImage~readErrorCallback} callbackError the error callback
* @param {Object} [options] optional parameters
* @param {Array} [options.window=whole image] the subset to read data from.
* @param {Array} [options.samples=all samples] the selection of samples to read from.
* @param {Boolean} [options.interleave=false] whether the data shall be read
* in one single array or separate
* arrays.
* @param {GeoTIFFImage~readCallback} [callback] the success callback. this
* parameter is mandatory for
* asynchronous decoders (some
* compression mechanisms).
* @param {GeoTIFFImage~readErrorCallback} [callbackError] the error callback
* @returns {(TypedArray|TypedArray[]|null)} in synchonous cases, the decoded
* array(s) is/are returned. In
* asynchronous cases, nothing is
* returned.
*/

@@ -1027,40 +1046,38 @@

key: "readRasters",
value: function readRasters() {
var imageWindow, samples, callback, callbackError;
var argCount = arguments.length;
if (argCount > 4 || argCount === 0) {
throw new Error("Invalid number of arguments passed.");
value: function readRasters() /* arguments are read via the 'arguments' object */{
var options, callback, callbackError;
switch (arguments.length) {
case 0:
break;
case 1:
if (typeof arguments[0] === "function") {
callback = arguments[0];
} else {
options = arguments[0];
}
break;
case 2:
if (typeof arguments[0] === "function") {
callback = arguments[0];
callbackError = arguments[1];
} else {
options = arguments[0];
callback = arguments[1];
}
break;
case 3:
options = arguments[0];
callback = arguments[1];
callbackError = arguments[2];
break;
default:
throw new Error("Invalid number of arguments passed.");
}
options = options || {};
callbackError = callbackError || function () {};
var last = arguments[argCount - 1],
prevLast = arguments[argCount - 2];
var imageWindow = options.window || [0, 0, this.getWidth(), this.getHeight()],
samples = options.samples,
interleave = options.interleave;
if (typeof prevLast === "function") {
callback = prevLast;
callbackError = last;
switch (argCount) {
case 3:
imageWindow = arguments[0];
break;
case 4:
imageWindow = arguments[0];
samples = arguments[1];
break;
}
} else {
callback = last;
switch (argCount) {
case 2:
imageWindow = arguments[0];
break;
case 3:
imageWindow = arguments[0];
samples = arguments[1];
break;
}
}
imageWindow = imageWindow || [0, 0, this.getWidth(), this.getHeight()];
if (imageWindow[0] < 0 || imageWindow[1] < 0 || imageWindow[2] > this.getWidth() || imageWindow[3] > this.getHeight()) {

@@ -1072,5 +1089,2 @@ throw new Error("Select window is out of image bounds.");

callback = callback || function () {};
callbackError = callbackError || function () {};
var imageWindowWidth = imageWindow[2] - imageWindow[0];

@@ -1093,5 +1107,12 @@ var imageWindowHeight = imageWindow[3] - imageWindow[1];

}
var valueArrays = [];
for (i = 0; i < samples.length; ++i) {
valueArrays.push(this.getArrayForSample(samples[i], numPixels));
var valueArrays;
if (interleave) {
var format = Math.max.apply(null, this.fileDirectory.SampleFormat),
bitsPerSample = Math.max.apply(null, this.fileDirectory.BitsPerSample);
valueArrays = arrayForType(format, bitsPerSample, numPixels * samples.length);
} else {
valueArrays = [];
for (i = 0; i < samples.length; ++i) {
valueArrays.push(this.getArrayForSample(samples[i], numPixels));
}
}

@@ -1101,5 +1122,9 @@

if (decoder.isAsync()) {
return this._readRasterAsync(imageWindow, samples, valueArrays, callback, callbackError);
if (!callback) {
throw new Error("No callback specified for asynchronous raster reading.");
}
return this._readRasterAsync(imageWindow, samples, valueArrays, interleave, callback, callbackError);
} else {
return this._readRaster(imageWindow, samples, valueArrays, callback, callbackError);
callback = callback || function () {};
return this._readRaster(imageWindow, samples, valueArrays, interleave, callback, callbackError);
}

@@ -1412,5 +1437,7 @@ }

* @param {(string|ArrayBuffer)} data Raw data to parse the GeoTIFF from.
* @param {Object} [options] further options.
* @param {Boolean} [options.cache=false] whether or not decoded tiles shall be cached.
* @returns {GeoTIFF} the parsed geotiff file.
*/
var parse = function parse(data) {
var parse = function parse(data, options) {
var rawData, i, strLen, view;

@@ -1428,3 +1455,3 @@ if (typeof data === "string" || data instanceof String) {

}
return new _geotiff2.default(rawData);
return new _geotiff2.default(rawData, options);
};

@@ -1431,0 +1458,0 @@

@@ -1,1 +0,1 @@

!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var f=function(){function a(){d(this,a)}return e(a,[{key:"isAsync",value:function(){return!this.decodeBlock}}]),a}();c["default"]=f},{}],2:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlockAsync",value:function(a,b){throw new Error("DeflateDecoder is not yet implemented.")}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],3:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlock",value:function(a){throw new Error("LZWDecoder is not yet implemented")}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],4:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlock",value:function(a){for(var b=new DataView(a),c=[],d=0;d<a.byteLength;++d){var e=b.getInt8(d);if(0>e){var f=b.getUint8(d+1);e=-e;for(var g=0;e>=g;++g)c.push(f);d+=1}else{for(var g=0;e>=g;++g)c.push(b.getUint8(d+g+1));d+=e+1}}return new Uint8Array(c).buffer}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],5:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlock",value:function(a){return a}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],6:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var g=a("./globals"),h=a("./geotiffimage.js"),i=d(h),j=function(){function a(b){e(this,a),this.dataView=new DataView(b);var c=this.dataView.getUint16(0,0);if(18761===c)this.littleEndian=!0;else{if(19789!==c)throw new TypeError("Invalid byte order value.");this.littleEndian=!1}if(42!==this.dataView.getUint16(2,this.littleEndian))throw new TypeError("Invalid magic number.");this.fileDirectories=this.parseFileDirectories(this.dataView.getUint32(4,this.littleEndian))}return f(a,[{key:"getFieldTypeLength",value:function(a){switch(a){case g.fieldTypes.BYTE:case g.fieldTypes.ASCII:case g.fieldTypes.SBYTE:case g.fieldTypes.UNDEFINED:return 1;case g.fieldTypes.SHORT:case g.fieldTypes.SSHORT:return 2;case g.fieldTypes.LONG:case g.fieldTypes.SLONG:case g.fieldTypes.FLOAT:return 4;case g.fieldTypes.RATIONAL:case g.fieldTypes.SRATIONAL:case g.fieldTypes.DOUBLE:return 8;default:throw new RangeError("Invalid field type: "+a)}}},{key:"getValues",value:function(a,b,c){var d,e=null,f=null,h=this.getFieldTypeLength(a);switch(a){case g.fieldTypes.BYTE:case g.fieldTypes.ASCII:case g.fieldTypes.UNDEFINED:e=new Uint8Array(b),f=this.dataView.getUint8;break;case g.fieldTypes.SBYTE:e=new Int8Array(b),f=this.dataView.getInt8;break;case g.fieldTypes.SHORT:e=new Uint16Array(b),f=this.dataView.getUint16;break;case g.fieldTypes.SSHORT:e=new Int16Array(b),f=this.dataView.getInt16;break;case g.fieldTypes.LONG:e=new Uint32Array(b),f=this.dataView.getUint32;break;case g.fieldTypes.SLONG:e=new Int32Array(b),f=this.dataView.getInt32;break;case g.fieldTypes.RATIONAL:e=new Uint32Array(2*b),f=this.dataView.getUint32;break;case g.fieldTypes.SRATIONAL:e=new Int32Array(2*b),f=this.dataView.getInt32;break;case g.fieldTypes.FLOAT:e=new Float32Array(b),f=this.dataView.getFloat32;break;case g.fieldTypes.DOUBLE:e=new Float64Array(b),f=this.dataView.getFloat64;break;default:throw new RangeError("Invalid field type: "+a)}if(a!==g.fieldTypes.RATIONAL&&a!==g.fieldTypes.SRATIONAL)for(d=0;b>d;++d)e[d]=f.call(this.dataView,c+d*h,this.littleEndian);else for(d=0;2*b>d;d+=2)e[d]=f.call(this.dataView,c+d*h,this.littleEndian),e[d+1]=f.call(this.dataView,c+(d+1)*h,this.littleEndian);return a===g.fieldTypes.ASCII?String.fromCharCode.apply(null,e):e}},{key:"getFieldValues",value:function(a,b,c,d){var e,f=this.getFieldTypeLength(b);if(4>=f*c)e=this.getValues(b,c,d);else{var h=this.dataView.getUint32(d,this.littleEndian);e=this.getValues(b,c,h)}return 1===c&&-1===g.arrayFields.indexOf(a)&&b!==g.fieldTypes.RATIONAL&&b!==g.fieldTypes.SRATIONAL?e[0]:e}},{key:"parseGeoKeyDirectory",value:function(a){var b=a.GeoKeyDirectory;if(!b)return null;for(var c={},d=4;d<4*b[3];d+=4){var e=g.geoKeyNames[b[d]],f=b[d+1]?g.fieldTagNames[b[d+1]]:null,h=b[d+2],i=b[d+3],j=null;if(f){if(j=a[f],"undefined"==typeof j||null===j)throw new Error("Could not get value of geoKey '"+e+"'.");"string"==typeof j?j=j.substring(i,i+h-1):j.subarray&&(j=j.subarray(i,i+h-1))}else j=i;c[e]=j}return c}},{key:"parseFileDirectories",value:function(a){for(var b=a,c=[];0!==b;){for(var d=this.dataView.getUint16(b,this.littleEndian),e={},f=a+2,h=0;d>h;f+=12,++h){var i=this.dataView.getUint16(f,this.littleEndian),j=this.dataView.getUint16(f+2,this.littleEndian),k=this.dataView.getUint32(f+4,this.littleEndian);e[g.fieldTagNames[i]]=this.getFieldValues(i,j,k,f+8)}c.push([e,this.parseGeoKeyDirectory(e)]),b=this.dataView.getUint32(f,this.littleEndian)}return c}},{key:"getImage",value:function(a){a=a||0;var b=this.fileDirectories[a];if(!b)throw new RangeError("Invalid image index");return new i["default"](b[0],b[1],this.dataView,this.littleEndian)}},{key:"getImageCount",value:function(){return this.fileDirectories.length}}]),a}();c["default"]=j},{"./geotiffimage.js":7,"./globals":8}],7:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var g=a("./globals"),h=a("./compression/raw.js"),i=d(h),j=a("./compression/lzw.js"),k=d(j),l=a("./compression/deflate.js"),m=d(l),n=a("./compression/packbits.js"),o=d(n),p=function(a,b,c){for(var d=0,e=b;c>e;++e)d+=a[e];return d},q=function(){function a(b,c,d,f){e(this,a),this.fileDirectory=b,this.geoKeys=c,this.dataView=d,this.littleEndian=f,this.tiles={},this.isTiled=b.StripOffsets?!1:!0;var g=b.PlanarConfiguration;if(this.planarConfiguration="undefined"==typeof g?1:g,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");switch(this.fileDirectory.Compression){case 1:this.decoder=new i["default"];break;case 5:this.decoder=new k["default"];break;case 6:throw new Error("JPEG compression not supported.");case 8:this.decoder=new m["default"];break;case 32773:this.decoder=new o["default"];break;default:throw new Error("Unknown compresseion method identifier: "+this.fileDirectory.Compression)}}return f(a,[{key:"getFileDirectory",value:function(){return this.fileDirectory}},{key:"getGeoKeys",value:function(){return this.geoKeys}},{key:"getWidth",value:function(){return this.fileDirectory.ImageWidth}},{key:"getHeight",value:function(){return this.fileDirectory.ImageLength}},{key:"getSamplesPerPixel",value:function(){return this.fileDirectory.SamplesPerPixel}},{key:"getTileWidth",value:function(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}},{key:"getTileHeight",value:function(){return this.isTiled?this.fileDirectory.TileLength:this.fileDirectory.RowsPerStrip}},{key:"getBytesPerPixel",value:function(){for(var a=0,b=0;b<this.fileDirectory.BitsPerSample.length;++b){var c=this.fileDirectory.BitsPerSample[b];if(c%8!==0)throw new Error("Sample bit-width of "+c+" is not supported.");if(c!==this.fileDirectory.BitsPerSample[0])throw new Error("Differing size of samples in a pixel are not supported.");a+=c}return a/8}},{key:"getSampleByteSize",value:function(a){if(a>=this.fileDirectory.BitsPerSample.length)throw new RangeError("Sample index "+a+" is out of range.");var b=this.fileDirectory.BitsPerSample[a];if(b%8!==0)throw new Error("Sample bit-width of "+b+" is not supported.");return b/8}},{key:"getReaderForSample",value:function(a){var b=this.fileDirectory.SampleFormat[a],c=this.fileDirectory.BitsPerSample[a];switch(b){case 1:switch(c){case 8:return DataView.prototype.getUint8;case 16:return DataView.prototype.getUint16;case 32:return DataView.prototype.getUint32}break;case 2:switch(c){case 8:return DataView.prototype.getInt8;case 16:return DataView.prototype.getInt16;case 32:return DataView.prototype.getInt32}break;case 3:switch(c){case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}}},{key:"getArrayForSample",value:function(a,b){var c=this.fileDirectory.SampleFormat[a],d=this.fileDirectory.BitsPerSample[a];switch(c){case 1:switch(d){case 8:return new Uint8Array(b);case 16:return new Uint16Array(b);case 32:return new Uint32Array(b)}break;case 2:switch(d){case 8:return new Int8Array(b);case 16:return new Int16Array(b);case 32:return new Int32Array(b)}break;case 3:switch(d){case 32:return new Float32Array(b);case 64:return new Float64Array(b)}}throw Error("Unsupported data format/bitsPerSample")}},{key:"getDecoder",value:function(){return this.decoder}},{key:"getTileOrStripAsync",value:function(a,b,c,d){var e,f=Math.ceil(this.getWidth()/this.getTileWidth()),g=Math.ceil(this.getHeight()/this.getTileHeight()),h=this.tiles;if(1===this.planarConfiguration?e=b*f+a:2===this.planarConfiguration&&(e=c*f*g+b*f+a),e in this.tiles,1){var i,j;this.isTiled?(i=this.fileDirectory.TileOffsets[e],j=this.fileDirectory.TileByteCounts[e]):(i=this.fileDirectory.StripOffsets[e],j=this.fileDirectory.StripByteCounts[e]);var k=this.dataView.buffer.slice(i,i+j);return this.getDecoder().decodeBlockAsync(k,function(f,g){f||(h[e]=g),d(f,{x:a,y:b,sample:c,data:g})})}return d(null,{x:a,y:b,sample:c,data:h[e]})}},{key:"getTileOrStrip",value:function(a,b,c){var d,e=Math.ceil(this.getWidth()/this.getTileWidth()),f=Math.ceil(this.getHeight()/this.getTileHeight());if(1===this.planarConfiguration?d=b*e+a:2===this.planarConfiguration&&(d=c*e*f+b*e+a),d in this.tiles)return this.tiles[d];var g,h;this.isTiled?(g=this.fileDirectory.TileOffsets[d],h=this.fileDirectory.TileByteCounts[d]):(g=this.fileDirectory.StripOffsets[d],h=this.fileDirectory.StripByteCounts[d]);var i=this.dataView.buffer.slice(g,g+h);return this.tiles[d]=this.getDecoder().decodeBlock(i)}},{key:"_readRasterAsync",value:function(a,b,c,d,e){function f(b,d){if(b)w=b;else for(var e=new DataView(d.data),f=d.y*i,j=d.x*h,k=(d.y+1)*i,l=(d.x+1)*h,m=(d.sample,Math.max(0,a[1]-f));m<Math.min(i,i-(k-a[3]));++m)for(var p=Math.max(0,a[0]-j);p<Math.min(h,h-(l-a[2]));++p){var s=(m*h+p)*o,t=(m+f-a[1])*n+p+j-a[0];c[B][t]=r[B].call(e,s+q[B],v)}u-=1,g()}function g(){t&&0===u&&(w?e(w):d(c))}for(var h=this.getTileWidth(),i=this.getTileHeight(),j=Math.floor(a[0]/h),k=Math.ceil(a[2]/h),l=Math.floor(a[1]/i),m=Math.ceil(a[3]/i),n=(Math.ceil(this.getWidth()/h),a[2]-a[0]),o=(a[3]-a[1],this.getBytesPerPixel()),q=(this.getWidth(),[]),r=[],s=0;s<b.length;++s)1===this.planarConfiguration?q.push(p(this.fileDirectory.BitsPerSample,0,b[s])/8):q.push(0),r.push(this.getReaderForSample(b[s]));for(var t=!1,u=0,v=this.littleEndian,w=null,x=l;m>=x;++x)for(var y=j;k>=y;++y)for(var z=0;z<b.length;++z){var A=b[z];2===this.planarConfiguration&&(o=this.getSampleByteSize(A));var B=z;u+=1,this.getTileOrStripAsync(y,x,A,f)}t=!0,g()}},{key:"_readRaster",value:function(a,b,c,d,e){try{for(var f=this.getTileWidth(),g=this.getTileHeight(),h=Math.floor(a[0]/f),i=Math.ceil(a[2]/f),j=Math.floor(a[1]/g),k=Math.ceil(a[3]/g),l=(Math.ceil(this.getWidth()/f),a[2]-a[0]),m=(a[3]-a[1],this.getBytesPerPixel()),n=(this.getWidth(),[]),o=[],q=0;q<b.length;++q)1===this.planarConfiguration?n.push(p(this.fileDirectory.BitsPerSample,0,b[q])/8):n.push(0),o.push(this.getReaderForSample(b[q]));for(var r=j;k>=r;++r)for(var s=h;i>=s;++s)for(var t=r*g,u=s*f,v=(r+1)*g,w=(s+1)*f,x=0;x<b.length;++x){var y=b[x];2===this.planarConfiguration&&(m=this.getSampleByteSize(y));for(var z=new DataView(this.getTileOrStrip(s,r,y)),A=Math.max(0,a[1]-t);A<Math.min(g,g-(v-a[3]));++A)for(var B=Math.max(0,a[0]-u);B<Math.min(f,f-(w-a[2]));++B){var C=(A*f+B)*m,D=(A+t-a[1])*l+B+u-a[0];c[x][D]=o[x].call(z,C+n[x],this.littleEndian)}}return d(c)}catch(E){return e(E)}}},{key:"readRasters",value:function(){var a,b,c,d,e=arguments.length;if(e>4||0===e)throw new Error("Invalid number of arguments passed.");var f=arguments[e-1],g=arguments[e-2];if("function"==typeof g)switch(c=g,d=f,e){case 3:a=arguments[0];break;case 4:a=arguments[0],b=arguments[1]}else switch(c=f,e){case 2:a=arguments[0];break;case 3:a=arguments[0],b=arguments[1]}if(a=a||[0,0,this.getWidth(),this.getHeight()],a[0]<0||a[1]<0||a[2]>this.getWidth()||a[3]>this.getHeight())throw new Error("Select window is out of image bounds.");if(a[0]>a[2]||a[1]>a[3])throw new Error("Invalid subsets");c=c||function(){},d=d||function(){};var h,i=a[2]-a[0],j=a[3]-a[1],k=i*j;if(b){for(h=0;h<b.length;++h)if(b[h]>=this.fileDirectory.SamplesPerPixel)throw new RangeError("Invalid sample index '"+b[h]+"'.")}else for(b=[],h=0;h<this.fileDirectory.SamplesPerPixel;++h)b.push(h);var l=[];for(h=0;h<b.length;++h)l.push(this.getArrayForSample(b[h],k));var m=this.getDecoder();return m.isAsync()?this._readRasterAsync(a,b,l,c,d):this._readRaster(a,b,l,c,d)}},{key:"getTiePoints",value:function(){if(!this.fileDirectory.ModelTiepoint)return[];for(var a=[],b=0;b<this.fileDirectory.ModelTiepoint.length;b+=6)a.push({i:this.fileDirectory.ModelTiepoint[b],j:this.fileDirectory.ModelTiepoint[b+1],k:this.fileDirectory.ModelTiepoint[b+2],x:this.fileDirectory.ModelTiepoint[b+3],y:this.fileDirectory.ModelTiepoint[b+4],z:this.fileDirectory.ModelTiepoint[b+5]});return a}},{key:"getGDALMetadata",value:function(){var a={};if(!this.fileDirectory.GDAL_METADATA)return null;for(var b=g.parseXml(this.fileDirectory.GDAL_METADATA),c=b.evaluate("GDALMetadata/Item",b,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),d=0;d<c.snapshotLength;++d){var e=c.snapshotItem(d);a[e.getAttribute("name")]=e.textContent}return a}}]),a}();c["default"]=q},{"./compression/deflate.js":2,"./compression/lzw.js":3,"./compression/packbits.js":4,"./compression/raw.js":5,"./globals":8}],8:[function(a,b,c){"use strict";var d,e={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams"},f={};for(d in e)f[e[d]]=parseInt(d);var g=[f.BitsPerSample,f.ExtraSamples,f.SampleFormat,f.StripByteCounts,f.StripOffsets,f.StripRowCounts,f.TileByteCounts,f.TileOffsets],h={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"},i={};for(d in h)i[h[d]]=parseInt(d);var j={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},k={};for(d in j)k[j[d]]=parseInt(d);var l;"undefined"==typeof window?l=function(b){var c=a("xmldom").DOMParser;return(new c).parseFromString(b,"text/xml")}:"undefined"!=typeof window.DOMParser?l=function(a){return(new window.DOMParser).parseFromString(a,"text/xml")}:"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(l=function(a){var b=new window.ActiveXObject("Microsoft.XMLDOM");return b.async="false",b.loadXML(a),b}),b.exports={fieldTags:f,fieldTagNames:e,arrayFields:g,fieldTypes:i,fieldTypeNames:h,geoKeys:k,geoKeyNames:j,parseXml:l}},{xmldom:"xmldom"}],9:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}var e=a("./geotiff.js"),f=d(e),g=function(a){var b,c,d,e;if("string"==typeof a||a instanceof String)for(b=new ArrayBuffer(2*a.length),e=new Uint16Array(b),c=0,d=a.length;d>c;++c)e[c]=a.charCodeAt(c);else{if(!(a instanceof ArrayBuffer))throw new Error("Invalid input data given.");b=a}return new f["default"](b)};"undefined"!=typeof b&&"undefined"!=typeof b.exports&&(b.exports.parse=g),"undefined"!=typeof window&&(window.GeoTIFF={parse:g})},{"./geotiff.js":6}]},{},[9]);
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var f=function(){function a(){d(this,a)}return e(a,[{key:"isAsync",value:function(){return!this.decodeBlock}}]),a}();c["default"]=f},{}],2:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlockAsync",value:function(a,b){throw new Error("DeflateDecoder is not yet implemented.")}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],3:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlock",value:function(a){throw new Error("LZWDecoder is not yet implemented")}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],4:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlock",value:function(a){for(var b=new DataView(a),c=[],d=0;d<a.byteLength;++d){var e=b.getInt8(d);if(0>e){var f=b.getUint8(d+1);e=-e;for(var g=0;e>=g;++g)c.push(f);d+=1}else{for(var g=0;e>=g;++g)c.push(b.getUint8(d+g+1));d+=e+1}}return new Uint8Array(c).buffer}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],5:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var h=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var i=a("../abstractdecoder.js"),j=d(i),k=function(a){function b(){return e(this,b),f(this,Object.getPrototypeOf(b).apply(this,arguments))}return g(b,a),h(b,[{key:"decodeBlock",value:function(a){return a}}]),b}(j["default"]);c["default"]=k},{"../abstractdecoder.js":1}],6:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var g=a("./globals"),h=a("./geotiffimage.js"),i=d(h),j=function(){function a(b,c){e(this,a),this.dataView=new DataView(b),c=c||{},this.cache=c.cache||!1;var d=this.dataView.getUint16(0,0);if(18761===d)this.littleEndian=!0;else{if(19789!==d)throw new TypeError("Invalid byte order value.");this.littleEndian=!1}if(42!==this.dataView.getUint16(2,this.littleEndian))throw new TypeError("Invalid magic number.");this.fileDirectories=this.parseFileDirectories(this.dataView.getUint32(4,this.littleEndian))}return f(a,[{key:"getFieldTypeLength",value:function(a){switch(a){case g.fieldTypes.BYTE:case g.fieldTypes.ASCII:case g.fieldTypes.SBYTE:case g.fieldTypes.UNDEFINED:return 1;case g.fieldTypes.SHORT:case g.fieldTypes.SSHORT:return 2;case g.fieldTypes.LONG:case g.fieldTypes.SLONG:case g.fieldTypes.FLOAT:return 4;case g.fieldTypes.RATIONAL:case g.fieldTypes.SRATIONAL:case g.fieldTypes.DOUBLE:return 8;default:throw new RangeError("Invalid field type: "+a)}}},{key:"getValues",value:function(a,b,c){var d,e=null,f=null,h=this.getFieldTypeLength(a);switch(a){case g.fieldTypes.BYTE:case g.fieldTypes.ASCII:case g.fieldTypes.UNDEFINED:e=new Uint8Array(b),f=this.dataView.getUint8;break;case g.fieldTypes.SBYTE:e=new Int8Array(b),f=this.dataView.getInt8;break;case g.fieldTypes.SHORT:e=new Uint16Array(b),f=this.dataView.getUint16;break;case g.fieldTypes.SSHORT:e=new Int16Array(b),f=this.dataView.getInt16;break;case g.fieldTypes.LONG:e=new Uint32Array(b),f=this.dataView.getUint32;break;case g.fieldTypes.SLONG:e=new Int32Array(b),f=this.dataView.getInt32;break;case g.fieldTypes.RATIONAL:e=new Uint32Array(2*b),f=this.dataView.getUint32;break;case g.fieldTypes.SRATIONAL:e=new Int32Array(2*b),f=this.dataView.getInt32;break;case g.fieldTypes.FLOAT:e=new Float32Array(b),f=this.dataView.getFloat32;break;case g.fieldTypes.DOUBLE:e=new Float64Array(b),f=this.dataView.getFloat64;break;default:throw new RangeError("Invalid field type: "+a)}if(a!==g.fieldTypes.RATIONAL&&a!==g.fieldTypes.SRATIONAL)for(d=0;b>d;++d)e[d]=f.call(this.dataView,c+d*h,this.littleEndian);else for(d=0;2*b>d;d+=2)e[d]=f.call(this.dataView,c+d*h,this.littleEndian),e[d+1]=f.call(this.dataView,c+(d+1)*h,this.littleEndian);return a===g.fieldTypes.ASCII?String.fromCharCode.apply(null,e):e}},{key:"getFieldValues",value:function(a,b,c,d){var e,f=this.getFieldTypeLength(b);if(4>=f*c)e=this.getValues(b,c,d);else{var h=this.dataView.getUint32(d,this.littleEndian);e=this.getValues(b,c,h)}return 1===c&&-1===g.arrayFields.indexOf(a)&&b!==g.fieldTypes.RATIONAL&&b!==g.fieldTypes.SRATIONAL?e[0]:e}},{key:"parseGeoKeyDirectory",value:function(a){var b=a.GeoKeyDirectory;if(!b)return null;for(var c={},d=4;d<4*b[3];d+=4){var e=g.geoKeyNames[b[d]],f=b[d+1]?g.fieldTagNames[b[d+1]]:null,h=b[d+2],i=b[d+3],j=null;if(f){if(j=a[f],"undefined"==typeof j||null===j)throw new Error("Could not get value of geoKey '"+e+"'.");"string"==typeof j?j=j.substring(i,i+h-1):j.subarray&&(j=j.subarray(i,i+h-1))}else j=i;c[e]=j}return c}},{key:"parseFileDirectories",value:function(a){for(var b=a,c=[];0!==b;){for(var d=this.dataView.getUint16(b,this.littleEndian),e={},f=a+2,h=0;d>h;f+=12,++h){var i=this.dataView.getUint16(f,this.littleEndian),j=this.dataView.getUint16(f+2,this.littleEndian),k=this.dataView.getUint32(f+4,this.littleEndian);e[g.fieldTagNames[i]]=this.getFieldValues(i,j,k,f+8)}c.push([e,this.parseGeoKeyDirectory(e)]),b=this.dataView.getUint32(f,this.littleEndian)}return c}},{key:"getImage",value:function(a){a=a||0;var b=this.fileDirectories[a];if(!b)throw new RangeError("Invalid image index");return new i["default"](b[0],b[1],this.dataView,this.littleEndian,this.cache)}},{key:"getImageCount",value:function(){return this.fileDirectories.length}}]),a}();c["default"]=j},{"./geotiffimage.js":7,"./globals":8}],7:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();Object.defineProperty(c,"__esModule",{value:!0});var g=a("./globals"),h=a("./compression/raw.js"),i=d(h),j=a("./compression/lzw.js"),k=d(j),l=a("./compression/deflate.js"),m=d(l),n=a("./compression/packbits.js"),o=d(n),p=function(a,b,c){for(var d=0,e=b;c>e;++e)d+=a[e];return d},q=function(a,b,c){switch(a){case 1:switch(b){case 8:return new Uint8Array(c);case 16:return new Uint16Array(c);case 32:return new Uint32Array(c)}break;case 2:switch(b){case 8:return new Int8Array(c);case 16:return new Int16Array(c);case 32:return new Int32Array(c)}break;case 3:switch(b){case 32:return new Float32Array(c);case 64:return new Float64Array(c)}}throw Error("Unsupported data format/bitsPerSample")},r=function(){function a(b,c,d,f,g){e(this,a),this.fileDirectory=b,this.geoKeys=c,this.dataView=d,this.littleEndian=f,this.tiles=g?{}:null,this.isTiled=b.StripOffsets?!1:!0;var h=b.PlanarConfiguration;if(this.planarConfiguration="undefined"==typeof h?1:h,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");switch(this.fileDirectory.Compression){case 1:this.decoder=new i["default"];break;case 5:this.decoder=new k["default"];break;case 6:throw new Error("JPEG compression not supported.");case 8:this.decoder=new m["default"];break;case 32773:this.decoder=new o["default"];break;default:throw new Error("Unknown compresseion method identifier: "+this.fileDirectory.Compression)}}return f(a,[{key:"getFileDirectory",value:function(){return this.fileDirectory}},{key:"getGeoKeys",value:function(){return this.geoKeys}},{key:"getWidth",value:function(){return this.fileDirectory.ImageWidth}},{key:"getHeight",value:function(){return this.fileDirectory.ImageLength}},{key:"getSamplesPerPixel",value:function(){return this.fileDirectory.SamplesPerPixel}},{key:"getTileWidth",value:function(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}},{key:"getTileHeight",value:function(){return this.isTiled?this.fileDirectory.TileLength:this.fileDirectory.RowsPerStrip}},{key:"getBytesPerPixel",value:function(){for(var a=0,b=0;b<this.fileDirectory.BitsPerSample.length;++b){var c=this.fileDirectory.BitsPerSample[b];if(c%8!==0)throw new Error("Sample bit-width of "+c+" is not supported.");if(c!==this.fileDirectory.BitsPerSample[0])throw new Error("Differing size of samples in a pixel are not supported.");a+=c}return a/8}},{key:"getSampleByteSize",value:function(a){if(a>=this.fileDirectory.BitsPerSample.length)throw new RangeError("Sample index "+a+" is out of range.");var b=this.fileDirectory.BitsPerSample[a];if(b%8!==0)throw new Error("Sample bit-width of "+b+" is not supported.");return b/8}},{key:"getReaderForSample",value:function(a){var b=this.fileDirectory.SampleFormat[a],c=this.fileDirectory.BitsPerSample[a];switch(b){case 1:switch(c){case 8:return DataView.prototype.getUint8;case 16:return DataView.prototype.getUint16;case 32:return DataView.prototype.getUint32}break;case 2:switch(c){case 8:return DataView.prototype.getInt8;case 16:return DataView.prototype.getInt16;case 32:return DataView.prototype.getInt32}break;case 3:switch(c){case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}}},{key:"getArrayForSample",value:function(a,b){var c=this.fileDirectory.SampleFormat[a],d=this.fileDirectory.BitsPerSample[a];return q(c,d,b)}},{key:"getDecoder",value:function(){return this.decoder}},{key:"getTileOrStrip",value:function(a,b,c,d){var e,f=Math.ceil(this.getWidth()/this.getTileWidth()),g=Math.ceil(this.getHeight()/this.getTileHeight()),h=this.tiles;if(1===this.planarConfiguration?e=b*f+a:2===this.planarConfiguration&&(e=c*f*g+b*f+a),null!==h&&e in h)return d?d(null,{x:a,y:b,sample:c,data:h[e]}):h[e];var i,j;this.isTiled?(i=this.fileDirectory.TileOffsets[e],j=this.fileDirectory.TileByteCounts[e]):(i=this.fileDirectory.StripOffsets[e],j=this.fileDirectory.StripByteCounts[e]);var k=this.dataView.buffer.slice(i,i+j);if(d)return this.getDecoder().decodeBlockAsync(k,function(f,g){f||null===h||(h[e]=g),d(f,{x:a,y:b,sample:c,data:g})});var l=this.getDecoder().decodeBlock(k);return null!==h&&(h[e]=l),l}},{key:"_readRasterAsync",value:function(a,b,c,d,e,f){function g(e,f){if(e)x=e;else for(var g=new DataView(f.data),k=f.y*j,l=f.x*i,m=(f.y+1)*j,n=(f.x+1)*i,p=(f.sample,Math.max(0,a[1]-k));p<Math.min(j,j-(m-a[3]));++p)for(var t=Math.max(0,a[0]-l);t<Math.min(i,i-(n-a[2]));++t){var u,y=(p*i+t)*q,z=s[C].call(g,y+r[C],w);d?(u=(p+k-a[1])*o*b.length+(t+l-a[0])*b.length+C,c[u]=z):(u=(p+k-a[1])*o+t+l-a[0],c[C][u]=z)}v-=1,h()}function h(){u&&0===v&&(x?f(x):e(c))}for(var i=this.getTileWidth(),j=this.getTileHeight(),k=Math.floor(a[0]/i),l=Math.ceil(a[2]/i),m=Math.floor(a[1]/j),n=Math.ceil(a[3]/j),o=(Math.ceil(this.getWidth()/i),a[2]-a[0]),q=(a[3]-a[1],this.getBytesPerPixel()),r=(this.getWidth(),[]),s=[],t=0;t<b.length;++t)1===this.planarConfiguration?r.push(p(this.fileDirectory.BitsPerSample,0,b[t])/8):r.push(0),s.push(this.getReaderForSample(b[t]));for(var u=!1,v=0,w=this.littleEndian,x=null,y=m;n>=y;++y)for(var z=k;l>=z;++z)for(var A=0;A<b.length;++A){var B=b[A];2===this.planarConfiguration&&(q=this.getSampleByteSize(B));var C=A;v+=1,this.getTileOrStripAsync(z,y,B,g)}u=!0,h()}},{key:"_readRaster",value:function(a,b,c,d,e,f){try{for(var g=this.getTileWidth(),h=this.getTileHeight(),i=Math.floor(a[0]/g),j=Math.ceil(a[2]/g),k=Math.floor(a[1]/h),l=Math.ceil(a[3]/h),m=(Math.ceil(this.getWidth()/g),a[2]-a[0]),n=(a[3]-a[1],this.getBytesPerPixel()),o=(this.getWidth(),[]),q=[],r=0;r<b.length;++r)1===this.planarConfiguration?o.push(p(this.fileDirectory.BitsPerSample,0,b[r])/8):o.push(0),q.push(this.getReaderForSample(b[r]));for(var s=k;l>s;++s)for(var t=i;j>t;++t)for(var u=s*h,v=t*g,w=(s+1)*h,x=(t+1)*g,y=0;y<b.length;++y){var z=b[y];2===this.planarConfiguration&&(n=this.getSampleByteSize(z));for(var A=new DataView(this.getTileOrStrip(t,s,z)),B=Math.max(0,a[1]-u);B<Math.min(h,h-(w-a[3]));++B)for(var C=Math.max(0,a[0]-v);C<Math.min(g,g-(x-a[2]));++C){var D,E=(B*g+C)*n,F=q[y].call(A,E+o[y],this.littleEndian);d?(D=(B+u-a[1])*m*b.length+(C+v-a[0])*b.length+y,c[D]=F):(D=(B+u-a[1])*m+C+v-a[0],c[y][D]=F)}}return e(c),c}catch(G){return f(G)}}},{key:"readRasters",value:function(){var a,b,c;switch(arguments.length){case 0:break;case 1:"function"==typeof arguments[0]?b=arguments[0]:a=arguments[0];break;case 2:"function"==typeof arguments[0]?(b=arguments[0],c=arguments[1]):(a=arguments[0],b=arguments[1]);break;case 3:a=arguments[0],b=arguments[1],c=arguments[2];break;default:throw new Error("Invalid number of arguments passed.")}a=a||{},c=c||function(){};var d=a.window||[0,0,this.getWidth(),this.getHeight()],e=a.samples,f=a.interleave;if(d[0]<0||d[1]<0||d[2]>this.getWidth()||d[3]>this.getHeight())throw new Error("Select window is out of image bounds.");if(d[0]>d[2]||d[1]>d[3])throw new Error("Invalid subsets");var g,h=d[2]-d[0],i=d[3]-d[1],j=h*i;if(e){for(g=0;g<e.length;++g)if(e[g]>=this.fileDirectory.SamplesPerPixel)throw new RangeError("Invalid sample index '"+e[g]+"'.")}else for(e=[],g=0;g<this.fileDirectory.SamplesPerPixel;++g)e.push(g);var k;if(f){var l=Math.max.apply(null,this.fileDirectory.SampleFormat),m=Math.max.apply(null,this.fileDirectory.BitsPerSample);k=q(l,m,j*e.length)}else for(k=[],g=0;g<e.length;++g)k.push(this.getArrayForSample(e[g],j));var n=this.getDecoder();if(n.isAsync()){if(!b)throw new Error("No callback specified for asynchronous raster reading.");return this._readRasterAsync(d,e,k,f,b,c)}return b=b||function(){},this._readRaster(d,e,k,f,b,c)}},{key:"getTiePoints",value:function(){if(!this.fileDirectory.ModelTiepoint)return[];for(var a=[],b=0;b<this.fileDirectory.ModelTiepoint.length;b+=6)a.push({i:this.fileDirectory.ModelTiepoint[b],j:this.fileDirectory.ModelTiepoint[b+1],k:this.fileDirectory.ModelTiepoint[b+2],x:this.fileDirectory.ModelTiepoint[b+3],y:this.fileDirectory.ModelTiepoint[b+4],z:this.fileDirectory.ModelTiepoint[b+5]});return a}},{key:"getGDALMetadata",value:function(){var a={};if(!this.fileDirectory.GDAL_METADATA)return null;for(var b=g.parseXml(this.fileDirectory.GDAL_METADATA),c=b.evaluate("GDALMetadata/Item",b,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),d=0;d<c.snapshotLength;++d){var e=c.snapshotItem(d);a[e.getAttribute("name")]=e.textContent}return a}}]),a}();c["default"]=r},{"./compression/deflate.js":2,"./compression/lzw.js":3,"./compression/packbits.js":4,"./compression/raw.js":5,"./globals":8}],8:[function(a,b,c){"use strict";var d,e={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams"},f={};for(d in e)f[e[d]]=parseInt(d);var g=[f.BitsPerSample,f.ExtraSamples,f.SampleFormat,f.StripByteCounts,f.StripOffsets,f.StripRowCounts,f.TileByteCounts,f.TileOffsets],h={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"},i={};for(d in h)i[h[d]]=parseInt(d);var j={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},k={};for(d in j)k[j[d]]=parseInt(d);var l;"undefined"==typeof window?l=function(b){var c=a("xmldom").DOMParser;return(new c).parseFromString(b,"text/xml")}:"undefined"!=typeof window.DOMParser?l=function(a){return(new window.DOMParser).parseFromString(a,"text/xml")}:"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(l=function(a){var b=new window.ActiveXObject("Microsoft.XMLDOM");return b.async="false",b.loadXML(a),b}),b.exports={fieldTags:f,fieldTagNames:e,arrayFields:g,fieldTypes:i,fieldTypeNames:h,geoKeys:k,geoKeyNames:j,parseXml:l}},{xmldom:"xmldom"}],9:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}var e=a("./geotiff.js"),f=d(e),g=function(a,b){var c,d,e,g;if("string"==typeof a||a instanceof String)for(c=new ArrayBuffer(2*a.length),g=new Uint16Array(c),d=0,e=a.length;e>d;++d)g[d]=a.charCodeAt(d);else{if(!(a instanceof ArrayBuffer))throw new Error("Invalid input data given.");c=a}return new f["default"](c,b)};"undefined"!=typeof b&&"undefined"!=typeof b.exports&&(b.exports.parse=g),"undefined"!=typeof window&&(window.GeoTIFF={parse:g})},{"./geotiff.js":6}]},{},[9]);

@@ -126,3 +126,3 @@ 'use strict';

dist: {
src: ['src/*.js', 'test/*.js'],
src: ['README.md', 'src/*.js', 'test/*.js'],
options: {

@@ -129,0 +129,0 @@ destination: 'docs'

{
"curly" : true,
"eqeqeq" : true,
"curly": true,
"eqeqeq": true,
"esnext": true,
"immed" : true,
"latedef" : true,
"newcap" : true,
"noarg" : true,
"sub" : true,
"undef" : true,
"boss" : true,
"eqnull" : true,
"browser" : true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"node": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"browser": true,
"browserify": true,
"globals" : {
"_" : true,
"module" : true,
"exports" : true
"globals": {
"_": true,
"module": true,
"exports": true
}
}
{
"name": "geotiff",
"version": "0.2.0",
"version": "0.3.0",
"description": "GeoTIFF image decoding in JavaScript",

@@ -5,0 +5,0 @@ "repository": "https://github.com/constantinius/geotiff.js",

@@ -107,9 +107,11 @@ # geotiff.js

var samples = [0, 1, 2, 3];
image.readRasters(rasterWindow, samples, function(rasters) {
for (var i = 0; i < rasters.length; ++i) {
console.log(rasters[i]);
}
});
// to read all the complete rasters
// var rasters = image.readRasters(null, null, function(rasters) { ... });
var rasters = image.readRasters({window: rasterWindow, samples: samples});
for (var i = 0; i < rasters.length; ++i) {
console.log(rasters[i]);
}
// to read all samples with no subsets:
rasters = image.readRasters();
// to read the data in a single interleaved array:
var array = image.readRasters({interleave: true});
```

@@ -136,11 +138,10 @@

var image = tiff.getImage();
var raster = image.readRasters(null, null, function(rasters) {
var canvas = document.getElementById("plot");
var plot = new plotty.plot({
canvas: canvas, data: rasters[0],
width: image.getWidth(), height: image.getHeight(),
domain: [0, 256], colorScale: "viridis"
});
plot.render();
var rasters = image.readRasters();
var canvas = document.getElementById("plot");
var plot = new plotty.plot({
canvas: canvas, data: rasters[0],
width: image.getWidth(), height: image.getHeight(),
domain: [0, 256], colorScale: "viridis"
});
plot.render();
</script>

@@ -156,1 +157,8 @@ ```

* Better support for geokeys
## Acknowledgements
This library was inspired by
[GeotiffParser](https://github.com/xlhomme/GeotiffParser.js). It provided a
great starting point, but lacked the capabilities to read the raw raster data
which is the aim of geotiff.js.

@@ -10,5 +10,9 @@ import {fieldTags, fieldTagNames, arrayFields, fieldTypes, fieldTypeNames, geoKeys, geoKeyNames} from "./globals";

* @param {ArrayBuffer} rawData the raw data stream of the file as an ArrayBuffer.
* @param {Object} [options] further options.
* @param {Boolean} [options.cache=false] whether or not decoded tiles shall be cached.
*/
constructor(rawData) {
constructor(rawData, options) {
this.dataView = new DataView(rawData);
options = options || {};
this.cache = options.cache || false;

@@ -208,3 +212,3 @@ var BOM = this.dataView.getUint16(0, 0);

}
return new GeoTIFFImage(fileDirectoryAndGeoKey[0], fileDirectoryAndGeoKey[1], this.dataView, this.littleEndian);
return new GeoTIFFImage(fileDirectoryAndGeoKey[0], fileDirectoryAndGeoKey[1], this.dataView, this.littleEndian, this.cache);
}

@@ -211,0 +215,0 @@

@@ -17,2 +17,36 @@ import {fieldTags, fieldTagNames, arrayFields, fieldTypes, fieldTypeNames, parseXml} from "./globals";

var arrayForType = function(format, bitsPerSample, size) {
switch (format) {
case 1: // unsigned integer data
switch (bitsPerSample) {
case 8:
return new Uint8Array(size);
case 16:
return new Uint16Array(size);
case 32:
return new Uint32Array(size);
}
break;
case 2: // twos complement signed integer data
switch (bitsPerSample) {
case 8:
return new Int8Array(size);
case 16:
return new Int16Array(size);
case 32:
return new Int32Array(size);
}
break;
case 3: // floating point data
switch (bitsPerSample) {
case 32:
return new Float32Array(size);
case 64:
return new Float64Array(size);
}
break;
}
throw Error("Unsupported data format/bitsPerSample");
};
export default class GeoTIFFImage {

@@ -26,4 +60,5 @@ /**

* @param {Boolean} littleEndian Whether the file is encoded in little or big endian
* @param {Boolean} cache Whether or not decoded tiles shall be cached
*/
constructor(fileDirectory, geoKeys, dataView, littleEndian) {
constructor(fileDirectory, geoKeys, dataView, littleEndian, cache) {
this.fileDirectory = fileDirectory;

@@ -33,3 +68,3 @@ this.geoKeys = geoKeys;

this.littleEndian = littleEndian;
this.tiles = {};
this.tiles = cache ? {} : null;
this.isTiled = (fileDirectory.StripOffsets) ? false : true;

@@ -182,33 +217,3 @@ var planarConfiguration = fileDirectory.PlanarConfiguration;

var bitsPerSample = this.fileDirectory.BitsPerSample[sampleIndex];
switch (format) {
case 1: // unsigned integer data
switch (bitsPerSample) {
case 8:
return new Uint8Array(size);
case 16:
return new Uint16Array(size);
case 32:
return new Uint32Array(size);
}
break;
case 2: // twos complement signed integer data
switch (bitsPerSample) {
case 8:
return new Int8Array(size);
case 16:
return new Int16Array(size);
case 32:
return new Int32Array(size);
}
break;
case 3: // floating point data
switch (bitsPerSample) {
case 32:
return new Float32Array(size);
case 64:
return new Float64Array(size);
}
break;
}
throw Error("Unsupported data format/bitsPerSample");
return arrayForType(format, bitsPerSample, size);
}

@@ -227,3 +232,3 @@

*/
getTileOrStripAsync(x, y, sample, callback) {
getTileOrStrip(x, y, sample, callback) {
var numTilesPerRow = Math.ceil(this.getWidth() / this.getTileWidth());

@@ -240,41 +245,8 @@ var numTilesPerCol = Math.ceil(this.getHeight() / this.getTileHeight());

if (index in this.tiles && false) {
return callback(null, {
x: x, y: y, sample: sample, data: tiles[index]
});
if (tiles !== null && index in tiles) {
if (callback) {
return callback(null, {x: x, y: y, sample: sample, data: tiles[index]});
}
else {
var offset, byteCount;
if (this.isTiled) {
offset = this.fileDirectory.TileOffsets[index];
byteCount = this.fileDirectory.TileByteCounts[index];
}
else {
offset = this.fileDirectory.StripOffsets[index];
byteCount = this.fileDirectory.StripByteCounts[index];
}
var slice = this.dataView.buffer.slice(offset, offset + byteCount);
return this.getDecoder().decodeBlockAsync(slice, function(error, data) {
if (!error) {
tiles[index] = data;
}
callback(error, {x: x, y: y, sample: sample, data: data});
});
}
}
getTileOrStrip(x, y, sample) {
var numTilesPerRow = Math.ceil(this.getWidth() / this.getTileWidth());
var numTilesPerCol = Math.ceil(this.getHeight() / this.getTileHeight());
var index;
if (this.planarConfiguration === 1) {
index = y * numTilesPerRow + x;
return tiles[index];
}
else if (this.planarConfiguration === 2) {
index = sample * numTilesPerRow * numTilesPerCol + y * numTilesPerRow + x;
}
if (index in this.tiles) {
return this.tiles[index];
}
else {

@@ -291,7 +263,19 @@ var offset, byteCount;

var slice = this.dataView.buffer.slice(offset, offset + byteCount);
return this.tiles[index] = this.getDecoder().decodeBlock(slice);
if (callback) {
return this.getDecoder().decodeBlockAsync(slice, function(error, data) {
if (!error && tiles !== null) {
tiles[index] = data;
}
callback(error, {x: x, y: y, sample: sample, data: data});
});
}
var block = this.getDecoder().decodeBlock(slice);
if (tiles !== null) {
tiles[index] = block;
}
return block;
}
}
_readRasterAsync(imageWindow, samples, valueArrays, callback, callbackError) {
_readRasterAsync(imageWindow, samples, valueArrays, interleave, callback, callbackError) {
var tileWidth = this.getTileWidth();

@@ -343,6 +327,17 @@ var tileHeight = this.getTileHeight();

var pixelOffset = (y * tileWidth + x) * bytesPerPixel;
var windowCoordinate = (
y + firstLine - imageWindow[1]
) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[_sampleIndex][windowCoordinate] = sampleReaders[_sampleIndex].call(dataView, pixelOffset + srcSampleOffsets[_sampleIndex], littleEndian);
var value = sampleReaders[_sampleIndex].call(dataView, pixelOffset + srcSampleOffsets[_sampleIndex], littleEndian);
var windowCoordinate;
if (interleave) {
windowCoordinate =
(y + firstLine - imageWindow[1]) * windowWidth * samples.length +
(x + firstCol - imageWindow[0]) * samples.length +
_sampleIndex;
valueArrays[windowCoordinate] = value;
}
else {
windowCoordinate = (
y + firstLine - imageWindow[1]
) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[_sampleIndex][windowCoordinate] = value;
}
}

@@ -388,3 +383,3 @@ }

_readRaster(imageWindow, samples, valueArrays, callback, callbackError) {
_readRaster(imageWindow, samples, valueArrays, interleave, callback, callbackError) {
try {

@@ -419,4 +414,4 @@ var tileWidth = this.getTileWidth();

for (var yTile = minYTile; yTile <= maxYTile; ++yTile) {
for (var xTile = minXTile; xTile <= maxXTile; ++xTile) {
for (var yTile = minYTile; yTile < maxYTile; ++yTile) {
for (var xTile = minXTile; xTile < maxXTile; ++xTile) {
var firstLine = yTile * tileHeight;

@@ -437,6 +432,17 @@ var firstCol = xTile * tileWidth;

var pixelOffset = (y * tileWidth + x) * bytesPerPixel;
var windowCoordinate = (
y + firstLine - imageWindow[1]
) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[sampleIndex][windowCoordinate] = sampleReaders[sampleIndex].call(tile, pixelOffset + srcSampleOffsets[sampleIndex], this.littleEndian);
var value = sampleReaders[sampleIndex].call(tile, pixelOffset + srcSampleOffsets[sampleIndex], this.littleEndian);
var windowCoordinate;
if (interleave) {
windowCoordinate =
(y + firstLine - imageWindow[1]) * windowWidth * samples.length +
(x + firstCol - imageWindow[0]) * samples.length +
sampleIndex;
valueArrays[windowCoordinate] = value;
}
else {
windowCoordinate = (
y + firstLine - imageWindow[1]
) * windowWidth + x + firstCol - imageWindow[0];
valueArrays[sampleIndex][windowCoordinate] = value;
}
}

@@ -447,3 +453,4 @@ }

}
return callback(valueArrays);
callback(valueArrays);
return valueArrays;
}

@@ -459,3 +466,6 @@ catch (error) {

* @callback GeoTIFFImage~readCallback
* @param {TypedArray[]} array the requested data as a summary array, one TypedArray for each requested sample
* @param {(TypedArray|TypedArray[])} array the requested data as a either a
* single typed array or a list of
* typed arrays, depending on the
* 'interleave' option.
*/

@@ -475,46 +485,60 @@

*
* @param {Array} [imageWindow=whole image] the subset to read data from.
* @param {Array} [samples=all samples] the selection of samples to read from.
* @param {GeoTIFFImage~readCallback} callback the success callback
* @param {GeoTIFFImage~readErrorCallback} callbackError the error callback
* @param {Object} [options] optional parameters
* @param {Array} [options.window=whole image] the subset to read data from.
* @param {Array} [options.samples=all samples] the selection of samples to read from.
* @param {Boolean} [options.interleave=false] whether the data shall be read
* in one single array or separate
* arrays.
* @param {GeoTIFFImage~readCallback} [callback] the success callback. this
* parameter is mandatory for
* asynchronous decoders (some
* compression mechanisms).
* @param {GeoTIFFImage~readErrorCallback} [callbackError] the error callback
* @returns {(TypedArray|TypedArray[]|null)} in synchonous cases, the decoded
* array(s) is/are returned. In
* asynchronous cases, nothing is
* returned.
*/
readRasters() {
var imageWindow, samples, callback, callbackError;
var argCount = arguments.length;
if (argCount > 4 || argCount === 0) {
throw new Error("Invalid number of arguments passed.");
readRasters(/* arguments are read via the 'arguments' object */) {
// parse the arguments
var options, callback, callbackError;
switch (arguments.length) {
case 0:
break;
case 1:
if (typeof arguments[0] === "function") {
callback = arguments[0];
}
else {
options = arguments[0];
}
break;
case 2:
if (typeof arguments[0] === "function") {
callback = arguments[0];
callbackError = arguments[1];
}
else {
options = arguments[0];
callback = arguments[1];
}
break;
case 3:
options = arguments[0];
callback = arguments[1];
callbackError = arguments[2];
break;
default:
throw new Error("Invalid number of arguments passed.");
}
var last = arguments[argCount-1],
prevLast = arguments[argCount-2];
// set up default arguments
options = options || {};
callbackError = callbackError || function(error) { console.error(error); };
if (typeof prevLast === "function") {
callback = prevLast;
callbackError = last;
switch (argCount) {
case 3:
imageWindow = arguments[0];
break;
case 4:
imageWindow = arguments[0];
samples = arguments[1];
break;
}
}
else {
callback = last;
switch (argCount) {
case 2:
imageWindow = arguments[0];
break;
case 3:
imageWindow = arguments[0];
samples = arguments[1];
break;
}
}
var imageWindow = options.window || [0, 0, this.getWidth(), this.getHeight()],
samples = options.samples,
interleave = options.interleave;
imageWindow = imageWindow || [0, 0, this.getWidth(), this.getHeight()];
// check parameters
if (imageWindow[0] < 0 ||

@@ -530,5 +554,2 @@ imageWindow[1] < 0 ||

callback = callback || function() {};
callbackError = callbackError || function() {};
var imageWindowWidth = imageWindow[2] - imageWindow[0];

@@ -552,13 +573,30 @@ var imageWindowHeight = imageWindow[3] - imageWindow[1];

}
var valueArrays = [];
for (i = 0; i < samples.length; ++i) {
valueArrays.push(this.getArrayForSample(samples[i], numPixels));
var valueArrays;
if (interleave) {
var format = Math.max.apply(null, this.fileDirectory.SampleFormat),
bitsPerSample = Math.max.apply(null, this.fileDirectory.BitsPerSample);
valueArrays = arrayForType(format, bitsPerSample, numPixels * samples.length);
}
else {
valueArrays = [];
for (i = 0; i < samples.length; ++i) {
valueArrays.push(this.getArrayForSample(samples[i], numPixels));
}
}
// start reading data, sync or async
var decoder = this.getDecoder();
if (decoder.isAsync()) {
return this._readRasterAsync(imageWindow, samples, valueArrays, callback, callbackError);
if (!callback) {
throw new Error("No callback specified for asynchronous raster reading.");
}
return this._readRasterAsync(
imageWindow, samples, valueArrays, interleave, callback, callbackError
);
}
else {
return this._readRaster(imageWindow, samples, valueArrays, callback, callbackError);
callback = callback || function() {};
return this._readRaster(
imageWindow, samples, valueArrays, interleave, callback, callbackError
);
}

@@ -565,0 +603,0 @@ }

@@ -6,5 +6,7 @@ import GeoTIFF from "./geotiff.js";

* @param {(string|ArrayBuffer)} data Raw data to parse the GeoTIFF from.
* @param {Object} [options] further options.
* @param {Boolean} [options.cache=false] whether or not decoded tiles shall be cached.
* @returns {GeoTIFF} the parsed geotiff file.
*/
var parse = function(data) {
var parse = function(data, options) {
var rawData, i, strLen, view;

@@ -24,3 +26,3 @@ if (typeof data === "string" || data instanceof String) {

}
return new GeoTIFF(rawData);
return new GeoTIFF(rawData, options);
};

@@ -27,0 +29,0 @@

@@ -5,7 +5,4 @@ var expect = require("chai").expect;

describe("mainTests", function() {
it("geotiff.js module available", function() {
expect(GeoTIFF).to.be.ok;
});
var retrieve = function(filename, callback) {
var retrieve = function(filename, done, callback) {
var xhr = new XMLHttpRequest();

@@ -18,4 +15,4 @@ xhr.open('GET', '/base/test/data/' + filename, true);

xhr.onerror = function(e) {
console.log(e)
//throw new Error(e);
console.error(e);
done(error);
};

@@ -26,4 +23,8 @@ callback;

it("geotiff.js module available", function() {
expect(GeoTIFF).to.be.ok;
});
it("should work on stripped tiffs", function(done) {
retrieve("stripped.tiff", function(tiff) {
retrieve("stripped.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -36,14 +37,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Uint16Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -53,3 +53,3 @@ });

it("should work on tiled tiffs", function(done) {
retrieve("tiled.tiff", function(tiff) {
retrieve("tiled.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -62,14 +62,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Uint16Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -79,3 +78,3 @@ });

it("should work on band interleaved tiffs", function(done) {
retrieve("interleave.tiff", function(tiff) {
retrieve("interleave.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -88,14 +87,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Uint16Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -105,3 +103,3 @@ });

it("should work on band interleaved and tiled tiffs", function(done) {
retrieve("interleave.tiff", function(tiff) {
retrieve("interleave.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -114,14 +112,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Uint16Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -131,3 +128,3 @@ });

it("should work on Int32 tiffs", function(done) {
retrieve("int32.tiff", function(tiff) {
retrieve("int32.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -140,14 +137,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Int32Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -157,3 +153,3 @@ });

it("should work on UInt32 tiffs", function(done) {
retrieve("uint32.tiff", function(tiff) {
retrieve("uint32.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -166,14 +162,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Uint32Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -183,3 +178,3 @@ });

it("should work on Float32 tiffs", function(done) {
retrieve("float32.tiff", function(tiff) {
retrieve("float32.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -192,14 +187,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Float32Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -209,3 +203,3 @@ });

it("should work on Float64 tiffs", function(done) {
retrieve("float64.tiff", function(tiff) {
retrieve("float64.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -218,14 +212,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Float64Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -235,3 +228,3 @@ });

it("should work on packbit compressed tiffs", function(done) {
retrieve("packbits.tiff", function(tiff) {
retrieve("packbits.tiff", done, function(tiff) {
expect(tiff).to.be.ok;

@@ -244,14 +237,13 @@ var image = tiff.getImage();

image.readRasters([200, 200, 210, 210], function(allData){
try {
var allData = image.readRasters({window: [200, 200, 210, 210]});
expect(allData).to.have.length(15);
expect(allData[0]).to.be.an.instanceof(Uint16Array);
image.readRasters([200, 200, 210, 210], [5], function(data) {
expect(data[0]).to.deep.equal(allData[5]);
done();
}, function(error) {
done(error);
});
}, function(error) {
var data = image.readRasters({window: [200, 200, 210, 210], samples: [5]});
expect(data[0]).to.deep.equal(allData[5]);
done();
}
catch (error) {
done(error);
});
}
});

@@ -261,8 +253,8 @@ });

it("should work with no options other than a callback", function(done) {
retrieve("packbits.tiff", function(tiff) {
retrieve("small.tiff", done, function(tiff) {
expect(tiff).to.be.ok;
var image = tiff.getImage();
image.readRasters(function(allData){
image.readRasters(function(allData) {
expect(allData).to.have.length(15);
expect(allData[0].length).to.equal(539*448);
expect(allData[0].length).to.equal(53*44);
done();

@@ -274,8 +266,8 @@ });

it("should work with callback and error callback", function(done) {
retrieve("packbits.tiff", function(tiff) {
retrieve("small.tiff", done, function(tiff) {
expect(tiff).to.be.ok;
var image = tiff.getImage();
image.readRasters(function(allData){
image.readRasters(function(allData) {
expect(allData).to.have.length(15);
expect(allData[0].length).to.equal(539*448);
expect(allData[0].length).to.equal(53*44);
done();

@@ -288,7 +280,7 @@ }, function(error) {

it("should work with imageWindow and callback", function(done) {
retrieve("packbits.tiff", function(tiff) {
it("should work with options and callback", function(done) {
retrieve("packbits.tiff", done, function(tiff) {
expect(tiff).to.be.ok;
var image = tiff.getImage();
image.readRasters([200, 200, 210, 210], function(allData){
image.readRasters({window: [200, 200, 210, 210]}, function(allData) {
expect(allData).to.have.length(15);

@@ -301,7 +293,7 @@ expect(allData[0].length).to.equal(10*10);

it("should work with imageWindow, callback and error callback", function(done) {
retrieve("packbits.tiff", function(tiff) {
it("should work with options, callback and error callback", function(done) {
retrieve("packbits.tiff", done, function(tiff) {
expect(tiff).to.be.ok;
var image = tiff.getImage();
image.readRasters([200, 200, 210, 210], function(allData){
image.readRasters({window: [200, 200, 210, 210]}, function(allData) {
expect(allData).to.have.length(15);

@@ -316,25 +308,15 @@ expect(allData[0].length).to.equal(10*10);

it("should work with imageWindow, samples and callback", function(done) {
retrieve("packbits.tiff", function(tiff) {
it("should work with interleaved reading", function(done) {
retrieve("packbits.tiff", done, function(tiff) {
expect(tiff).to.be.ok;
var image = tiff.getImage();
image.readRasters([200, 200, 210, 210], [0], function(allData){
expect(allData).to.have.length(1);
expect(allData[0].length).to.equal(10*10);
try {
var raster = image.readRasters({window: [200, 200, 210, 210], samples: [0, 1, 2, 3], interleave: true});
expect(raster).to.have.length(10 * 10 * 4);
expect(raster).to.be.an.instanceof(Uint16Array);
done();
});
});
});
it("should work with imageWindow, samples, callback and error callback", function(done) {
retrieve("packbits.tiff", function(tiff) {
expect(tiff).to.be.ok;
var image = tiff.getImage();
image.readRasters([200, 200, 210, 210], [0], function(allData){
expect(allData).to.have.length(1);
expect(allData[0].length).to.equal(10*10);
done();
}, function(error) {
}
catch (error) {
done(error);
});
}
});

@@ -341,0 +323,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc