Skip to content

Commit c1d4fb9

Browse files
gjmooneymartinRenou
authored andcommitted
Save geotiff files to indexeddb
1 parent 8555031 commit c1d4fb9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/base/src/tools.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Protobuf from 'pbf';
1717
import shp from 'shpjs';
1818

1919
import RASTER_LAYER_GALLERY from '@/rasterlayer_gallery/raster_layer_gallery.json';
20+
import { getGdal } from './gdal';
2021

2122
export const debounce = (
2223
func: CallableFunction,
@@ -486,8 +487,18 @@ export const loadGeoTiff = async (
486487
fileBlob = await base64ToBlob(file.content, mimeType);
487488
}
488489

490+
const geotiff = new File([fileBlob], 'loaded.tif');
491+
const gdal = await getGdal();
492+
const result = await gdal.open(geotiff);
493+
const tifDataset = result.datasets[0];
494+
const metadata = await gdal.gdalinfo(tifDataset, ['-stats']);
495+
gdal.close(tifDataset);
496+
497+
await saveToIndexedDB(url, fileBlob, metadata);
498+
489499
return {
490500
file: fileBlob,
501+
metadata,
491502
sourceUrl: url,
492503
};
493504
};

0 commit comments

Comments
 (0)