diff --git a/src/layer/S3OLCIL2CDASLayer.ts b/src/layer/S3OLCIL2CDASLayer.ts index 50ea2aab..39ee1c18 100644 --- a/src/layer/S3OLCIL2CDASLayer.ts +++ b/src/layer/S3OLCIL2CDASLayer.ts @@ -1,11 +1,75 @@ +import moment from 'moment'; + import { DATASET_CDAS_S3OLCIL2 } from './dataset'; -import { S3SLSTRCDASLayer } from './S3SLSTRCDASLayer'; +import { AbstractSentinelHubV3WithCCLayer } from './AbstractSentinelHubV3WithCCLayer'; +import { RequestConfiguration } from '../utils/cancelRequests'; + +import { PaginatedTiles, Link, LinkType, FindTilesAdditionalParameters } from './const'; -import { Link, LinkType } from './const'; +type S3OLCIL2FindTilesDatasetParameters = { + type?: string; +}; -export class S3OLCIL2CDASLayer extends S3SLSTRCDASLayer { +export class S3OLCIL2CDASLayer extends AbstractSentinelHubV3WithCCLayer { public readonly dataset = DATASET_CDAS_S3OLCIL2; + protected convertResponseFromSearchIndex(response: { + data: { tiles: any[]; hasMore: boolean }; + }): PaginatedTiles { + return { + tiles: response.data.tiles.map(tile => ({ + geometry: tile.dataGeometry, + sensingTime: moment.utc(tile.sensingTime).toDate(), + meta: this.extractFindTilesMeta(tile), + links: this.getTileLinks(tile), + })), + hasMore: response.data.hasMore, + }; + } + + protected getFindTilesAdditionalParameters(): FindTilesAdditionalParameters { + const findTilesDatasetParameters: S3OLCIL2FindTilesDatasetParameters = { + type: this.dataset.shProcessingApiDatasourceAbbreviation, + }; + + return { + maxCloudCoverPercent: this.maxCloudCoverPercent, + datasetParameters: findTilesDatasetParameters, + }; + } + + protected async getFindDatesUTCAdditionalParameters( + reqConfig: RequestConfiguration, // eslint-disable-line @typescript-eslint/no-unused-vars + ): Promise> { + const result: Record = { + datasetParameters: { + type: this.dataset.datasetParametersType, + }, + }; + + if (this.maxCloudCoverPercent !== null) { + result.maxCloudCoverage = this.maxCloudCoverPercent / 100; + } + + return result; + } + + protected getTileLinks(tile: Record): Link[] { + return [ + { + target: tile.originalId.replace('EODATA', '/eodata'), + type: LinkType.CREODIAS, + }, + { + target: `https://finder.creodias.eu/files${tile.originalId.replace( + 'EODATA', + '', + )}/${tile.productName.replace('.SEN3', '')}-ql.jpg`, + type: LinkType.PREVIEW, + }, + ]; + } + protected getTileLinksFromCatalog(feature: Record): Link[] { const { assets } = feature; let result: Link[] = super.getTileLinksFromCatalog(feature);