Skip to content

Commit

Permalink
fix: single render dont request more than one band
Browse files Browse the repository at this point in the history
  • Loading branch information
hongfaqiu committed Sep 21, 2024
1 parent 6976fe0 commit 575bdd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
registry = https://registry.npmjs.org/
registry = https://registry.npmjs.org/
link-workspace-packages=true
14 changes: 7 additions & 7 deletions packages/TIFFImageryProvider/src/TIFFImageryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export class TIFFImageryProvider {
}

const { single, multi, convertToRGB } = this.renderOptions;
this.readSamples = multi ? [multi.r.band - 1, multi.g.band - 1, multi.b.band - 1] : convertToRGB ? [0, 1, 2] : Array.from({ length: samples }, (_, index) => index);
this.readSamples = multi ? [multi.r.band - 1, multi.g.band - 1, multi.b.band - 1] : convertToRGB ? [0, 1, 2] : [single.band - 1];
if (single?.expression) {
this.readSamples = findAndSortBandNumbers(single.expression);
}
Expand Down Expand Up @@ -504,7 +504,7 @@ export class TIFFImageryProvider {
startX = x << (reqz - z);
startY = y << (reqz - z);
}

const index = this.requestLevels[z];
let image = this._images[index];
if (!image) {
Expand Down Expand Up @@ -547,7 +547,7 @@ export class TIFFImageryProvider {
const buffer = 1;
window = [window[0] - buffer, window[1] - buffer, window[2] + buffer, window[3] + buffer]
const sourceWidth = window[2] - window[0], sourceHeight = window[3] - window[1];

const options = {
window,
pool: getWorkerPool(),
Expand All @@ -567,7 +567,7 @@ export class TIFFImageryProvider {
res = await Promise.all((res).map((array) => reverseArray({ array, width: res.width, height: res.height })));
}
}

if (this._proj?.project && this.tilingScheme instanceof TIFFImageryProviderTilingScheme) {
const sourceRect = this.tilingScheme.tileXYToNativeRectangle2(x, y, z);
const targetRect = this.tilingScheme.tileXYToRectangle(x, y, z);
Expand All @@ -591,7 +591,7 @@ export class TIFFImageryProvider {
}
res = result
}

const tileNum = 1 << (reqz - z)
const x0 = (reqx - startX) / tileNum;
const y0 = (reqy - startY) / tileNum;
Expand Down Expand Up @@ -619,7 +619,7 @@ export class TIFFImageryProvider {
throw error;
}
}

async requestImage(
x: number,
y: number,
Expand All @@ -637,7 +637,7 @@ export class TIFFImageryProvider {

try {
const { width, height, data } = await this._loadTile(x, y, z);

if (this._destroyed || !width || !height) {
return undefined;
}
Expand Down

0 comments on commit 575bdd9

Please sign in to comment.