Skip to content

Commit

Permalink
Refactor: mMake AbstractSentinelHubV3WithCCLayer deal with maxcc para…
Browse files Browse the repository at this point in the history
…meters for Processing API
  • Loading branch information
sinergise-anze committed May 5, 2020
1 parent 1b84c31 commit 8532c19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
9 changes: 8 additions & 1 deletion src/layer/AbstractSentinelHubV3WithCCLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import moment from 'moment';

import { BBox } from 'src/bbox';
import { PaginatedTiles, MosaickingOrder } from 'src/layer/const';
import { AbstractSentinelHubV3Layer } from './AbstractSentinelHubV3Layer';
import { AbstractSentinelHubV3Layer } from 'src/layer/AbstractSentinelHubV3Layer';
import { ProcessingPayload } from 'src/layer/processing';

interface ConstructorParameters {
instanceId?: string | null;
Expand Down Expand Up @@ -32,6 +33,12 @@ export class AbstractSentinelHubV3WithCCLayer extends AbstractSentinelHubV3Layer
};
}

protected async updateProcessingGetMapPayload(payload: ProcessingPayload): Promise<ProcessingPayload> {
payload = await super.updateProcessingGetMapPayload(payload);
payload.input.data[0].dataFilter.maxCloudCoverage = this.maxCloudCoverPercent;
return payload;
}

public async findTiles(
bbox: BBox,
fromTime: Date,
Expand Down
6 changes: 0 additions & 6 deletions src/layer/S2L1CLayer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { DATASET_S2L1C } from 'src/layer/dataset';
import { AbstractSentinelHubV3WithCCLayer } from './AbstractSentinelHubV3WithCCLayer';
import { ProcessingPayload } from 'src/layer/processing';

export class S2L1CLayer extends AbstractSentinelHubV3WithCCLayer {
public readonly dataset = DATASET_S2L1C;

protected async updateProcessingGetMapPayload(payload: ProcessingPayload): Promise<ProcessingPayload> {
payload.input.data[0].dataFilter.maxCloudCoverage = this.maxCloudCoverPercent;
return payload;
}
}
22 changes: 5 additions & 17 deletions src/layer/S3SLSTRLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import moment from 'moment';
import { BBox } from 'src/bbox';
import { PaginatedTiles, OrbitDirection } from 'src/layer/const';
import { DATASET_S3SLSTR } from 'src/layer/dataset';
import { AbstractSentinelHubV3Layer } from 'src/layer/AbstractSentinelHubV3Layer';
import { AbstractSentinelHubV3WithCCLayer } from 'src/layer/AbstractSentinelHubV3WithCCLayer';
import { ProcessingPayload } from 'src/layer/processing';

interface ConstructorParameters {
Expand All @@ -29,32 +29,20 @@ type S3SLSTRFindTilesDatasetParameters = {
view: S3SLSTRView;
};

export class S3SLSTRLayer extends AbstractSentinelHubV3Layer {
export class S3SLSTRLayer extends AbstractSentinelHubV3WithCCLayer {
public readonly dataset = DATASET_S3SLSTR;
public maxCloudCoverPercent: number;
public orbitDirection: OrbitDirection | null;
public view: S3SLSTRView;

public constructor({
instanceId = null,
layerId = null,
evalscript = null,
evalscriptUrl = null,
dataProduct = null,
title = null,
description = null,
maxCloudCoverPercent = 100,
view = S3SLSTRView.NADIR,
}: ConstructorParameters) {
super({ instanceId, layerId, evalscript, evalscriptUrl, dataProduct, title, description });
this.maxCloudCoverPercent = maxCloudCoverPercent;
public constructor({ view = S3SLSTRView.NADIR, ...rest }: ConstructorParameters) {
super(rest);
// images that are not DESCENDING appear empty:
this.orbitDirection = OrbitDirection.DESCENDING;
this.view = view;
}

protected async updateProcessingGetMapPayload(payload: ProcessingPayload): Promise<ProcessingPayload> {
payload.input.data[0].dataFilter.maxCloudCoverage = this.maxCloudCoverPercent;
payload = await super.updateProcessingGetMapPayload(payload);
payload.input.data[0].dataFilter.orbitDirection = this.orbitDirection;
payload.input.data[0].processing.view = this.view;
return payload;
Expand Down

0 comments on commit 8532c19

Please sign in to comment.