import { MosaickingOrder , DataProductId , FindTilesAdditionalParameters } from './const' ; import { AbstractSentinelHubV3Layer } from './AbstractSentinelHubV3Layer' ; import { ProcessingPayload } from './processing' ; import { RequestConfiguration } from '../utils/cancelRequests' ; interface ConstructorParameters { instanceId ? : string | null ; layerId ? : string | null ; evalscript ? : string | null ; evalscriptUrl ? : string | null ; dataProduct ? : DataProductId | null ; mosaickingOrder ? : MosaickingOrder | null ; title ? : string | null ; description ? : string | null ; legendUrl ? : string | null ; maxCloudCoverPercent ? : number | null ; } export class AbstractSentinelHubV3WithCCLayer extends AbstractSentinelHubV3Layer { public maxCloudCoverPercent : number ; public constructor ( { maxCloudCoverPercent = 100 , ... rest } ) { super ( rest ) ; this . maxCloudCoverPercent = maxCloudCoverPercent ; } protected getWmsGetMapUrlAdditionalParameters ( ) { return { ... super . getWmsGetMapUrlAdditionalParameters ( ) , maxcc : this . maxCloudCoverPercent , } ; } public async _updateProcessingGetMapPayload ( payload , datasetSeqNo = 0 ) { payload = await super . _updateProcessingGetMapPayload ( payload ) ; payload . input . data [ datasetSeqNo ] . dataFilter . maxCloudCoverage = this . maxCloudCoverPercent ; return payload ; } protected extractFindTilesMetaFromCatalog ( feature ) { let result = { } ; if ( ! feature ) { return result ; } result = { ... super . extractFindTilesMetaFromCatalog ( feature ) , cloudCoverPercent : feature . properties [ 'eo:cloud_cover' ] , } ; return result ; } protected async getFindDatesUTCAdditionalParameters ( reqConfig ) { return this . maxCloudCoverPercent !== null && this . maxCloudCoverPercent !== undefined ? { maxCloudCoverage : this . maxCloudCoverPercent / 100 , } : { } ; } protected getStatsAdditionalParameters ( ) { return { maxcc : this . maxCloudCoverPercent , } ; } protected extractFindTilesMeta ( tile ) { return { ... super . extractFindTilesMeta ( tile ) , cloudCoverPercent : tile . cloudCoverPercentage , } ; } protected createCatalogPayloadQuery ( maxCloudCoverPercent ? , datasetParameters ? ) { let result = { ... super . createCatalogPayloadQuery ( maxCloudCoverPercent , datasetParameters ) } ; if ( maxCloudCoverPercent !== null && maxCloudCoverPercent !== undefined ) { result [ 'eo:cloud_cover' ] = { lte : maxCloudCoverPercent , } ; } return result ; } protected getFindTilesAdditionalParameters ( ) { return { maxCloudCoverPercent : this . maxCloudCoverPercent , datasetParameters : null , } ; } }