aboutsummaryrefslogtreecommitdiff
path: root/src/conversion/czi/tileExtraction.ts
diff options
context:
space:
mode:
authorTom Harley2018-03-29 12:22:06 +0100
committerTom Harley2018-03-29 12:22:06 +0100
commitb9c3dd19483972c68adfe15f2370485f8535fece (patch)
treeb51c7309311f45304192b1c8c93e5ecce40a8d2b /src/conversion/czi/tileExtraction.ts
parentMerge branch 'cjd24/conversion' into trh/czi-clean (diff)
downloadmedicine-b9c3dd19483972c68adfe15f2370485f8535fece.tar.gz
medicine-b9c3dd19483972c68adfe15f2370485f8535fece.zip

Clean up some of czi.ts

Diffstat (limited to 'src/conversion/czi/tileExtraction.ts')
-rw-r--r--src/conversion/czi/tileExtraction.ts19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/conversion/czi/tileExtraction.ts b/src/conversion/czi/tileExtraction.ts
index be8bd3c..a768f6e 100644
--- a/src/conversion/czi/tileExtraction.ts
+++ b/src/conversion/czi/tileExtraction.ts
@@ -1,9 +1,6 @@
-import { CZITile } from '../types/customPyramidIndex';
import { TileBounds } from '../types/helperCZITypes';
-import { SharpInstance } from 'sharp';
-import * as sharp from 'sharp';
-export const isTileRelated:Function = function(origCoords: TileBounds, desired: TileBounds): boolean {
+export const isTileRelated: Function = function(origCoords: TileBounds, desired: TileBounds): boolean {
if (((desired.left >= origCoords.left) &&
(desired.left < origCoords.right)) ||
@@ -14,8 +11,7 @@ export const isTileRelated:Function = function(origCoords: TileBounds, desired:
// Desired tile X overlaps base tile
((desired.left < origCoords.left) &&
- (desired.right > origCoords.right)))
- {
+ (desired.right > origCoords.right))) {
// Desired Y on top is within current tile
if (((desired.top >= origCoords.top) &&
@@ -27,8 +23,7 @@ export const isTileRelated:Function = function(origCoords: TileBounds, desired:
// Desired tile Y overlaps whole base tile
((desired.top < origCoords.top) &&
- (desired.bottom > origCoords.bottom)))
- {
+ (desired.bottom > origCoords.bottom))) {
//If all of the if statements have passed, then this tile
//is part of the overlap for the new tile to be created.
@@ -36,8 +31,7 @@ export const isTileRelated:Function = function(origCoords: TileBounds, desired:
}
}
return false;
-}
-
+};
/*
* Takes a base tile, and the whole bounds of a new tile, and uses this
@@ -47,7 +41,7 @@ export const isTileRelated:Function = function(origCoords: TileBounds, desired:
export const regionToExtract: Function = function(baseBounds: TileBounds, desired: TileBounds, zoomLevel: number): TileBounds {
//get the base tile area and create an object for the chunk to extract
- let chunkToExtract: TileBounds = new TileBounds(-1, -1, -1, -1);
+ const chunkToExtract: TileBounds = new TileBounds(-1, -1, -1, -1);
// check if the new tile overlaps the leftmost boundary
if (desired.left <= baseBounds.left) {
@@ -78,7 +72,7 @@ export const regionToExtract: Function = function(baseBounds: TileBounds, desire
}
if (chunkToExtract.left < 0 || chunkToExtract.right < 0 || chunkToExtract.top < 0 || chunkToExtract.bottom < 0) {
- throw new Error("Chunk to extract from base tile has invalid bound (< 0).");
+ throw new Error('Chunk to extract from base tile has invalid bound (< 0).');
}
chunkToExtract.left = Math.ceil(chunkToExtract.left / zoomLevel);
@@ -90,7 +84,6 @@ export const regionToExtract: Function = function(baseBounds: TileBounds, desire
return chunkToExtract;
};
-
// export const createHorizontalImageSlice: Function = async function (bufferBound: TileBounds, tileSize: number, tileOverlap: number, rowLength:number, row: Buffer[]): Promise<Buffer> {
// //prepare variables to squash all of the column data into one, for this row
// let imageVerticalSlice: SharpInstance = sharp(row[0]);