Skip to content

Commit

Permalink
Merge pull request #275 from sentinel-hub/fix/let_s3_olci_l2_use_clou…
Browse files Browse the repository at this point in the history
…d_cover

Fix - S3 OLCI L2 extends layer with CC
  • Loading branch information
zansinergise authored Aug 20, 2024
2 parents 6789a24 + b7928f5 commit 37eb8e9
Showing 1 changed file with 78 additions and 2 deletions.
80 changes: 78 additions & 2 deletions src/layer/S3OLCIL2CDASLayer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,82 @@
import moment from 'moment';

import { DATASET_CDAS_S3OLCIL2 } from './dataset';
import { S3OLCILayer } from './S3OLCILayer';
import { AbstractSentinelHubV3WithCCLayer } from './AbstractSentinelHubV3WithCCLayer';
import { RequestConfiguration } from '../utils/cancelRequests';

import { PaginatedTiles, Link, LinkType, FindTilesAdditionalParameters } from './const';

type S3OLCIL2FindTilesDatasetParameters = {
type?: string;
};

export class S3OLCIL2CDASLayer extends S3OLCILayer {
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<Record<string, any>> {
const result: Record<string, any> = {
datasetParameters: {
type: this.dataset.datasetParametersType,
},
};

if (this.maxCloudCoverPercent !== null) {
result.maxCloudCoverage = this.maxCloudCoverPercent / 100;
}

return result;
}

protected getTileLinks(tile: Record<string, any>): 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<string, any>): Link[] {
const { assets } = feature;
let result: Link[] = super.getTileLinksFromCatalog(feature);

if (assets.data && assets.data.href) {
result.push({ target: assets.data.href.replace('s3://DIAS', '/dias'), type: LinkType.CREODIAS });
}
return result;
}
}

0 comments on commit 37eb8e9

Please sign in to comment.