Skip to content

Commit

Permalink
make explicit type for predefinedEffects in Layer classes
Browse files Browse the repository at this point in the history
  • Loading branch information
zcernigoj committed May 18, 2020
1 parent 69091f5 commit a372b22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/layer/AbstractLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion src/layer/AbstractSentinelHubV3Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a372b22

Please sign in to comment.