Skip to content

Commit

Permalink
Rather extend new layer with abstract layer with CC instead of S3SLSTR
Browse files Browse the repository at this point in the history
  • Loading branch information
zansinergise committed Aug 20, 2024
1 parent 1bd4898 commit d985796
Showing 1 changed file with 67 additions and 3 deletions.
70 changes: 67 additions & 3 deletions src/layer/S3OLCIL2CDASLayer.ts
Original file line number Diff line number Diff line change
@@ -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 => ({

Check failure on line 20 in src/layer/S3OLCIL2CDASLayer.ts

View workflow job for this annotation

GitHub Actions / test (18)

Replace `tile` with `(tile)`

Check failure on line 20 in src/layer/S3OLCIL2CDASLayer.ts

View workflow job for this annotation

GitHub Actions / test (18)

Replace `tile` with `(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);
Expand Down

0 comments on commit d985796

Please sign in to comment.