diff --git a/src/index.js b/src/index.js index c947960..ef94d2a 100644 --- a/src/index.js +++ b/src/index.js @@ -59,6 +59,10 @@ class GeoRaster { this._url = data; this.rasterType = 'geotiff'; this.sourceType = 'url'; + } else if (typeof Blob !== 'undefined' && data instanceof Blob) { + this._data = data; + this.rasterType = 'geotiff'; + this.sourceType = 'Blob'; } else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(data)) { // this is node if (debug) console.log('data is a buffer'); diff --git a/src/parseData.js b/src/parseData.js index b139c12..2ef27ab 100644 --- a/src/parseData.js +++ b/src/parseData.js @@ -1,4 +1,4 @@ -import {fromArrayBuffer, fromUrl} from 'geotiff'; +import {fromArrayBuffer, fromUrl, fromBlob} from 'geotiff'; import {getPalette} from 'geotiff-palette'; import {unflatten} from './utils.js'; @@ -74,6 +74,8 @@ export default function parseData(data, debug) { let initFunction = fromArrayBuffer; if (data.sourceType === 'url') { initFunction = fromUrl; + } else if (data.sourceType === 'Blob') { + initFunction = fromBlob; } if (debug) console.log('data.rasterType is geotiff');