import { DATASET_S2L2A } from './dataset' ; import { AbstractSentinelHubV3WithCCLayer } from './AbstractSentinelHubV3WithCCLayer' ; import { ProcessingPayload } from './processing' ; import { Link , LinkType } from './const' ; export class S2L2ALayer extends AbstractSentinelHubV3WithCCLayer { public readonly dataset = DATASET_S2L2A ; public async _updateProcessingGetMapPayload ( payload , datasetSeqNo = 0 ) { payload . input . data [ datasetSeqNo ] . dataFilter . maxCloudCoverage = this . maxCloudCoverPercent ; return payload ; } private createPreviewLinkFromDataUri ( dataUri ) { return { target : `https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles${ dataUri }preview.jpg` , type : LinkType . PREVIEW , } ; } protected getTileLinks ( tile ) { return [ { target : tile . dataUri , type : LinkType . AWS , } , this . createPreviewLinkFromDataUri ( `${ tile . dataUri . split ( 'tiles' ) [ 1 ] }/` ) , ] ; } protected getTileLinksFromCatalog ( feature ) { let result = super . getTileLinksFromCatalog ( feature ) ; if ( feature && feature . assets && feature . assets . data ) { const dataUri = feature . assets . data . href . split ( 'tiles' ) [ 1 ] ; result . push ( this . createPreviewLinkFromDataUri ( dataUri ) ) ; } return result ; } protected extractFindTilesMeta ( tile ) { return { ... super . extractFindTilesMeta ( tile ) , tileId : tile . id , MGRSLocation : tile . dataUri . split ( '/' ) . slice ( 4 , 7 ) . join ( '' ) , } ; } protected extractFindTilesMetaFromCatalog ( feature ) { let result = super . extractFindTilesMetaFromCatalog ( feature ) ; if ( feature . assets && feature . assets . data && feature . assets . data . href ) { result . MGRSLocation = feature . assets . data . href . split ( '/' ) . slice ( 4 , 7 ) . join ( '' ) ; } return result ; } }