Skip to content

Commit

Permalink
fix: native tiff range request error
Browse files Browse the repository at this point in the history
  • Loading branch information
hongfaqiu committed Mar 14, 2024
1 parent 27523ca commit 78ca47f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/TIFFImageryProvider/src/TIFFImageryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,18 @@ export class TIFFImageryProvider {

private async _build(url: string | File | Blob, options: TIFFImageryProviderOptions = {}) {
const { tileSize, renderOptions, projFunc, requestOptions } = options;
const source = await (url instanceof File || url instanceof Blob ? fromBlob(url) : fromUrl(url, requestOptions))
this._source = source;
const image = await source.getImage();
let source = await (url instanceof File || url instanceof Blob ? fromBlob(url) : fromUrl(url, requestOptions))
let image = await source.getImage();
this._isTiled = image.isTiled;

// handle native tiff range request error
if (!this._isTiled && typeof url === 'string') {
source = await fromBlob(await (await fetch(url)).blob());
image = await source.getImage();
}

this._source = source;

// 获取空间范围
this.origin = this._getOrigin(image);
this.bbox = image.getBoundingBox();
Expand Down Expand Up @@ -574,8 +581,8 @@ export class TIFFImageryProvider {

private _createTile() {
const canv = document.createElement("canvas");
canv.width = this.tileSize;
canv.height = this.tileSize;
canv.width = this.tileWidth;
canv.height = this.tileHeight;
canv.style.imageRendering = "pixelated";
return canv;
}
Expand Down

0 comments on commit 78ca47f

Please sign in to comment.