Skip to content

Commit

Permalink
Merge pull request #64 from jcphill/jcphill-load-blob
Browse files Browse the repository at this point in the history
load from File/Blob on front-end
  • Loading branch information
DanielJDufour authored Feb 17, 2022
2 parents f4a2351 + 5749e28 commit ad4681a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion src/parseData.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit ad4681a

Please sign in to comment.