Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - S3 OLCI L2 extends layer with CC #275

Merged
merged 7 commits into from
Aug 20, 2024
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;
}
}