Load GeoTiff from Blob #13189 #13703

This commit is contained in:
Matthias Mohr
2022-06-01 23:13:05 +02:00
parent 28b99b30a8
commit c2fc1f85bf
6 changed files with 70 additions and 5 deletions

View File

@@ -4,7 +4,12 @@
import DataTile from './DataTile.js';
import State from './State.js';
import TileGrid from '../tilegrid/TileGrid.js';
import {Pool, fromUrl as tiffFromUrl, fromUrls as tiffFromUrls} from 'geotiff';
import {
Pool,
fromBlob as tiffFromBlob,
fromUrl as tiffFromUrl,
fromUrls as tiffFromUrls,
} from 'geotiff';
import {
Projection,
get as getCachedProjection,
@@ -17,8 +22,9 @@ import {fromCode as unitsFromCode} from '../proj/Units.js';
/**
* @typedef {Object} SourceInfo
* @property {string} url URL for the source GeoTIFF.
* @property {Array<string>} [overviews] List of any overview URLs.
* @property {string} [url] URL for the source GeoTIFF.
* @property {Array<string>} [overviews] List of any overview URLs, only applies if the url parameter is given.
* @property {Blob} [blob] Blob containing the source GeoTIFF. `blob` and `url` are mutually exclusive.
* @property {number} [min=0] The minimum source data value. Rendered values are scaled from 0 to 1 based on
* the configured min and max. If not provided and raster statistics are available, those will be used instead.
* If neither are available, the minimum for the data type will be used. To disable this behavior, set
@@ -189,7 +195,9 @@ function getImagesForTIFF(tiff) {
*/
function getImagesForSource(source, options) {
let request;
if (source.overviews) {
if (source.blob) {
request = tiffFromBlob(source.blob);
} else if (source.overviews) {
request = tiffFromUrls(source.url, source.overviews, options);
} else {
request = tiffFromUrl(source.url, options);