import { DATASET_EOCLOUD_S1GRD } from './dataset' ; import { AbstractSentinelHubV1OrV2Layer } from './AbstractSentinelHubV1OrV2Layer' ; import { AcquisitionMode , Polarization } from './S1GRDAWSEULayer' ; import { OrbitDirection , MosaickingOrder , Link , LinkType } from './const' ; import { RequestConfiguration } from '../utils/cancelRequests' ; interface ConstructorParameters { instanceId ? : string | null ; layerId ? : string | null ; evalscript ? : string | null ; evalscriptUrl ? : string | null ; mosaickingOrder ? : MosaickingOrder | null ; title ? : string | null ; description ? : string | null ; acquisitionMode ? : AcquisitionMode | null ; polarization ? : Polarization | null ; orbitDirection ? : OrbitDirection | null ; } export class S1GRDEOCloudLayer extends AbstractSentinelHubV1OrV2Layer { public readonly dataset = DATASET_EOCLOUD_S1GRD ; public acquisitionMode : AcquisitionMode ; public polarization : Polarization ; public orbitDirection : OrbitDirection | null = null ; public constructor ( { instanceId = null , layerId = null , evalscript = null , evalscriptUrl = null , mosaickingOrder = null , title = null , description = null , acquisitionMode = null , polarization = null , orbitDirection = null , } ) { super ( { instanceId , layerId , evalscript , evalscriptUrl , mosaickingOrder , title , description } ) ; if ( ( evalscript || evalscriptUrl ) && ( ! acquisitionMode || ! polarization ) ) { throw new Error ( 'Parameters acquisitionMode and polarization are mandatory when using evalscript' ) ; } this . acquisitionMode = acquisitionMode ; this . polarization = polarization ; this . orbitDirection = orbitDirection ; } public static makeLayer ( layerInfo , instanceId , layerId , evalscript , evalscriptUrl , title , description ) { let acquisitionMode = null ; let polarization = null ; switch ( layerInfo . settings . datasourceName ) { case 'S1' : acquisitionMode = AcquisitionMode . IW ; polarization = Polarization . DV ; break ; case 'S1_EW' : acquisitionMode = AcquisitionMode . EW ; polarization = Polarization . DH ; break ; case 'S1_EW_SH' : acquisitionMode = AcquisitionMode . EW ; polarization = Polarization . SH ; break ; default : throw new Error ( `Unknown datasourceName (${ layerInfo . settings . datasourceName })` ) ; } return new S1GRDEOCloudLayer ( { instanceId , layerId , evalscript , evalscriptUrl , title , description , acquisitionMode , polarization , orbitDirection : null , } ) ; } protected getEvalsource ( ) { if ( this . acquisitionMode === AcquisitionMode . IW && this . polarization === Polarization . DV ) { return 'S1' ; } if ( this . acquisitionMode === AcquisitionMode . EW && this . polarization === Polarization . DH ) { return 'S1_EW' ; } if ( this . acquisitionMode === AcquisitionMode . EW && this . polarization === Polarization . SH ) { return 'S1_EW_SH' ; } throw new Error ( `This combination of acquisition mode and polarization (${ this . acquisitionMode } / ${ this . polarization }) is not available on EO Cloud` ) ; } protected getFindTilesAdditionalParameters ( ) { const result = { productType : 'GRD' , acquisitionMode : this . acquisitionMode , polarization : this . polarization , } ; if ( this . orbitDirection !== null ) { result . orbitDirection = this . orbitDirection ; } return result ; } protected async getFindDatesUTCAdditionalParameters ( reqConfig ) { const result = { productType : 'GRD' , acquisitionMode : this . acquisitionMode , polarization : this . polarization , } ; if ( this . orbitDirection !== null ) { result . orbitDirection = this . orbitDirection ; } return result ; } protected getTileLinks ( tile ) { return [ { target : tile . pathFragment , type : LinkType . EOCLOUD , } , { target : `https://finder.creodias.eu/files/${ tile . pathFragment . split ( 'eodata' ) [ 1 ] }/preview/quick-look.png` , type : LinkType . PREVIEW , } , ] ; } }