-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from sentinel-hub/fix/let_s3_olci_l2_use_clou…
…d_cover Fix - S3 OLCI L2 extends layer with CC
- Loading branch information
Showing
1 changed file
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |