From 7896690dd7ec8cbe7c5a24ce132add13871a163a Mon Sep 17 00:00:00 2001 From: cs3099group-be-4 Date: Thu, 26 Apr 2018 09:19:19 +0100 Subject: Fix critical live image tile serving bug --- src/conversion/czi/pyramidWorker.ts | 6 +++--- src/conversion/types/helpers.ts | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/conversion/czi/pyramidWorker.ts b/src/conversion/czi/pyramidWorker.ts index 7adb747..00cb8b4 100644 --- a/src/conversion/czi/pyramidWorker.ts +++ b/src/conversion/czi/pyramidWorker.ts @@ -43,7 +43,7 @@ const findRelatedTiles: Function = function(plane: CZIHeightMap, desired: TileBo }; export const getTile: Function = async function(imageDir: string, cVal: string, x:number = 0, y:number = 0, w:number = 1024, h:number = 1024, zoom: number = 1): Promise { - log = logger.for({component: "CZI Live Server", req: {imageDir: imageDir, cVal: cVal, x:x = 0, y:y = 0, w:w, h:h, zoom: zoom}}); + log = logger.for({component: "CZI Live Server", req: {imageDir: imageDir, cVal: cVal, x:x, y:y, w:w, h:h, zoom: zoom}}); let layout: WholeCZIHierarchy = JSON.parse(await jobQueue.enqueue(2, readFile, null, imageDir + "layout.json", 'utf8')); if (!layout.complete) { @@ -85,7 +85,7 @@ const getFinalTile: Function = async function(imageDir: string, imageTier: CZIHe let outputFileName: string = `${imageDir}tmp/${id}-out.png` try { await new Promise((res) => { - shell.exec(`${execpaths} vips arrayjoin "${involvedTiles}" ${intermediateFileName} --across ${imageTier.plane[0].length} --vips-concurrency=2`); + shell.exec(`${execpaths} vips arrayjoin "${involvedTiles}" ${intermediateFileName} --across ${relatedTiles[0].length} --vips-concurrency=2`); res(); }); } catch (err) { @@ -118,7 +118,7 @@ const getFinalTile: Function = async function(imageDir: string, imageTier: CZIHe } }) - log.info(`Gen new Tile: ${outputFileName} X:${desiredRegion.left} Y:${desiredRegion.top} W:${desiredRegion.width()} H:${desiredRegion.height()} Z:${cVal}`); + log.debug(`Gen new Tile: X:${desiredRegion.left} Y:${desiredRegion.top} W:${desiredRegion.width()} H:${desiredRegion.height()} Z:${cVal}`); return { dimensions: new TileBounds( 0, extractionRegion.width(), diff --git a/src/conversion/types/helpers.ts b/src/conversion/types/helpers.ts index 4621bf6..6fd3be0 100644 --- a/src/conversion/types/helpers.ts +++ b/src/conversion/types/helpers.ts @@ -58,16 +58,16 @@ export class TileBounds { return this.bottom - this.top; } public scaleDown(level: number) { - this.left = Math.ceil(this.left / level), - this.right = Math.ceil(this.right / level), - this.top = Math.ceil(this.top / level), - this.bottom = Math.ceil(this.bottom / level) + this.left = Math.floor(this.left / level), + this.right = Math.floor(this.right / level), + this.top = Math.floor(this.top / level), + this.bottom = Math.floor(this.bottom / level) } public scaleUp(level: number) { this.left = Math.floor(this.left * level), - this.right = Math.ceil(this.right * level), - this.top = Math.ceil(this.top * level), - this.bottom = Math.ceil(this.bottom * level) + this.right = Math.floor(this.right * level), + this.top = Math.floor(this.top * level), + this.bottom = Math.floor(this.bottom * level) } } -- cgit v1.2.1