From a372b223863607017176c4cc79866275a77afa7a Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Mon, 18 May 2020 17:06:08 +0200 Subject: [PATCH] make explicit type for predefinedEffects in Layer classes --- src/layer/AbstractLayer.ts | 12 ++++++++---- src/layer/AbstractSentinelHubV3Layer.ts | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/layer/AbstractLayer.ts b/src/layer/AbstractLayer.ts index 1e658d33..0db096cc 100644 --- a/src/layer/AbstractLayer.ts +++ b/src/layer/AbstractLayer.ts @@ -8,6 +8,8 @@ import { CRS_EPSG4326 } from 'src/crs'; import { GetMapParams, ApiType, PaginatedTiles, FlyoverInterval } from 'src/layer/const'; import { Dataset } from 'src/layer/dataset'; import { getAxiosReqParams, RequestConfiguration } from 'src/utils/cancelRequests'; + +import { PredefinedEffects } from 'src/mapDataManipulation/const'; import { runPredefinedEffectFunctions } from 'src/mapDataManipulation/runPredefinedEffectFunctions'; interface ConstructorParameters { @@ -41,13 +43,15 @@ export class AbstractLayer { // were sent to the services in getMapUrl() // This is a dirty fix, but gain and gamma need to be removed from the parameters in getMap() so the // errors in getMapUrl() are not triggered. - let gain, gamma; + + let predefinedEffects: PredefinedEffects = {}; + if (params.gain) { - gain = params.gain; + predefinedEffects.gain = params.gain; params.gain = undefined; } if (params.gamma) { - gamma = params.gamma; + predefinedEffects.gamma = params.gamma; params.gamma = undefined; } @@ -60,7 +64,7 @@ export class AbstractLayer { }; const response = await axios.get(url, requestConfig); let blob = response.data; - blob = await runPredefinedEffectFunctions(blob, { gain: gain, gamma: gamma }); + blob = await runPredefinedEffectFunctions(blob, predefinedEffects); return blob; default: diff --git a/src/layer/AbstractSentinelHubV3Layer.ts b/src/layer/AbstractSentinelHubV3Layer.ts index 83bbeed1..69709261 100644 --- a/src/layer/AbstractSentinelHubV3Layer.ts +++ b/src/layer/AbstractSentinelHubV3Layer.ts @@ -22,6 +22,8 @@ import { processingGetMap, createProcessingPayload, ProcessingPayload } from 'sr import { AbstractLayer } from 'src/layer/AbstractLayer'; import { CRS_EPSG4326, findCrsFromUrn } from 'src/crs'; import { getAxiosReqParams, RequestConfiguration } from '../utils/cancelRequests'; + +import { PredefinedEffects } from 'src/mapDataManipulation/const'; import { runPredefinedEffectFunctions } from 'src/mapDataManipulation/runPredefinedEffectFunctions'; interface ConstructorParameters { @@ -210,7 +212,9 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer { const shServiceHostname = this.getShServiceHostname(); let blob = await processingGetMap(shServiceHostname, updatedPayload, reqConfig); - blob = await runPredefinedEffectFunctions(blob, { gain: params.gain, gamma: params.gamma }); + + let predefinedEffects: PredefinedEffects = { gain: params.gain, gamma: params.gamma }; + blob = await runPredefinedEffectFunctions(blob, predefinedEffects); return blob; }