From 9452e5c57c42492ed9c7f7c1a135a19f14575c43 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 13:49:08 +0200 Subject: [PATCH 01/11] remove AbstractSentinelHubV1OrV2Layer_ classes --- src/layer/AbstractSentinelHubV1OrV2Layer.ts | 283 ------------------ .../AbstractSentinelHubV1OrV2WithCCLayer.ts | 54 ---- src/statistics/Fis.ts | 21 +- 3 files changed, 1 insertion(+), 357 deletions(-) delete mode 100644 src/layer/AbstractSentinelHubV1OrV2Layer.ts delete mode 100644 src/layer/AbstractSentinelHubV1OrV2WithCCLayer.ts diff --git a/src/layer/AbstractSentinelHubV1OrV2Layer.ts b/src/layer/AbstractSentinelHubV1OrV2Layer.ts deleted file mode 100644 index 63ba48d1..00000000 --- a/src/layer/AbstractSentinelHubV1OrV2Layer.ts +++ /dev/null @@ -1,283 +0,0 @@ -import axios from 'axios'; -import moment from 'moment'; -import { stringify } from 'query-string'; - -import { BBox } from '../bbox'; -import { Fis } from '../statistics/Fis'; -import { CACHE_CONFIG_NOCACHE } from '../utils/cacheHandlers'; -import { getAxiosReqParams, RequestConfiguration } from '../utils/cancelRequests'; -import { ensureTimeout } from '../utils/ensureTimeout'; -import { AbstractLayer } from './AbstractLayer'; -import { - ApiType, - DEFAULT_FIND_TILES_MAX_COUNT_PARAMETER, - GetMapParams, - GetStatsParams, - Interpolator, - Link, - MosaickingOrder, - OgcServiceTypes, - PaginatedTiles, - Stats, -} from './const'; -import { fetchLayersFromGetCapabilitiesXml } from './utils'; -import { wmsGetMapUrl } from './wms'; -import { StatisticsProviderType } from '../statistics'; - -interface ConstructorParameters { - instanceId?: string | null; - layerId?: string | null; - evalscript?: string | null; - evalscriptUrl?: string | null; - mosaickingOrder?: MosaickingOrder | null; - title?: string | null; - description?: string | null; - upsampling?: Interpolator | null; - downsampling?: Interpolator | null; - legendUrl?: string | null; -} - -// this class provides any SHv1- or SHv2-specific (EO Cloud) functionality to the subclasses: -export class AbstractSentinelHubV1OrV2Layer extends AbstractLayer { - protected instanceId: string; - protected layerId: string; - protected evalscript: string | null; - protected evalscriptUrl: string | null; - protected mosaickingOrder: MosaickingOrder | null; - protected upsampling: Interpolator | null; - protected downsampling: Interpolator | null; - - public constructor({ - instanceId = null, - layerId = null, - evalscript = null, - evalscriptUrl = null, - mosaickingOrder = null, - title = null, - description = null, - upsampling = null, - downsampling = null, - legendUrl = null, - }: ConstructorParameters) { - super({ title, description, legendUrl }); - if (!layerId || !instanceId) { - throw new Error('Parameters instanceId and layerId must be specified!'); - } - this.instanceId = instanceId; - this.layerId = layerId; - this.evalscript = evalscript; - this.evalscriptUrl = evalscriptUrl; - this.mosaickingOrder = mosaickingOrder; - this.upsampling = upsampling; - this.downsampling = downsampling; - } - - public getEvalsource(): string { - // some subclasses (Sentinel 1 at EO Cloud) might want to return a different - // evalsource depending on their parameters - return this.dataset.shWmsEvalsource; - } - - public getLayerId(): string { - return this.layerId; - } - - public getEvalscript(): string { - return this.evalscript; - } - - public getInstanceId(): string { - return this.instanceId; - } - - protected getWmsGetMapUrlAdditionalParameters(): Record { - let additionalParameters: Record = {}; - if (this.mosaickingOrder) { - additionalParameters.priority = this.mosaickingOrder; - } - if (this.upsampling) { - additionalParameters.upsampling = this.upsampling; - } - if (this.downsampling) { - additionalParameters.downsampling = this.downsampling; - } - return additionalParameters; - } - - public getMapUrl(params: GetMapParams, api: ApiType): string { - if (api !== ApiType.WMS) { - throw new Error('Only WMS is supported on this layer'); - } - if (params.gain) { - throw new Error('Parameter gain is not supported in getMapUrl. Use getMap method instead.'); - } - if (params.gamma) { - throw new Error('Parameter gamma is not supported in getMapUrl. Use getMap method instead.'); - } - if (params.effects) { - throw new Error('Parameter effects is not supported in getMapUrl. Use getMap method instead.'); - } - const baseUrl = `${this.dataset.shServiceHostname}v1/wms/${this.instanceId}`; - return wmsGetMapUrl( - baseUrl, - this.layerId, - params, - this.evalscript, - this.evalscriptUrl, - this.getEvalsource(), - this.getWmsGetMapUrlAdditionalParameters(), - ); - } - - public setEvalscript(evalscript: string): void { - this.evalscript = evalscript; - } - - public setEvalscriptUrl(evalscriptUrl: string): void { - this.evalscriptUrl = evalscriptUrl; - } - - protected getFindTilesAdditionalParameters(): Record { - return {}; - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - protected extractFindTilesMeta(tile: any): Record { - return {}; - } - - protected async findTilesInner( - bbox: BBox, - fromTime: Date, - toTime: Date, - maxCount: number | null = null, - offset: number | null = null, - reqConfig?: RequestConfiguration, - ): Promise { - if (!this.dataset.searchIndexUrl) { - throw new Error('This dataset does not support searching for tiles'); - } - if (maxCount === null) { - maxCount = DEFAULT_FIND_TILES_MAX_COUNT_PARAMETER; - } - if (offset === null) { - offset = 0; - } - - const payload = bbox.toGeoJSON(); - const params = { - expand: 'true', - timefrom: fromTime.toISOString(), - timeto: toTime.toISOString(), - maxcount: maxCount, - offset: Number(offset), - ...this.getFindTilesAdditionalParameters(), - }; - - const url = `${this.dataset.searchIndexUrl}?${stringify(params, { sort: false })}`; - const response = await axios.post(url, payload, { - headers: { - 'Content-Type': 'application/json', - 'Accept-CRS': 'EPSG:4326', - }, - ...getAxiosReqParams(reqConfig, CACHE_CONFIG_NOCACHE), - }); - - const responseTiles: any[] = response.data.tiles; - return { - tiles: responseTiles.map((tile) => ({ - geometry: tile.tileDrawRegionGeometry, - sensingTime: moment.utc(tile.sensingTime).toDate(), - meta: this.extractFindTilesMeta(tile), - links: this.getTileLinks(tile), - })), - hasMore: response.data.hasMore, - }; - } - - protected async getFindDatesUTCAdditionalParameters( - reqConfig: RequestConfiguration, // eslint-disable-line @typescript-eslint/no-unused-vars - ): Promise> { - return {}; - } - - public getStatsAdditionalParameters(): Record { - return {}; - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - protected getTileLinks(tile: Record): Link[] { - return []; - } - - public async findDatesUTC( - bbox: BBox, - fromTime: Date, - toTime: Date, - reqConfig?: RequestConfiguration, - ): Promise { - const datesUTC = await ensureTimeout(async (innerReqConfig) => { - if (!this.dataset.findDatesUTCUrl) { - throw new Error('This dataset does not support searching for dates'); - } - const payload = bbox.toGeoJSON(); - const params = { - timefrom: fromTime.toISOString(), - timeto: toTime.toISOString(), - ...(await this.getFindDatesUTCAdditionalParameters(innerReqConfig)), - }; - - const url = `${this.dataset.findDatesUTCUrl}?${stringify(params, { sort: false })}`; - const response = await axios.post(url, payload, { - headers: { - 'Content-Type': 'application/json', - }, - ...getAxiosReqParams(innerReqConfig, CACHE_CONFIG_NOCACHE), - }); - - return response.data.map((date: string) => moment.utc(date).toDate()); - }, reqConfig); - return datesUTC; - } - - public async getStats( - params: GetStatsParams, - reqConfig: RequestConfiguration = {}, - statsProvider: StatisticsProviderType = StatisticsProviderType.FIS, - ): Promise { - const stats = await ensureTimeout(async (innerReqConfig) => { - if (statsProvider === StatisticsProviderType.FIS) { - return await new Fis().handleV1orV2(this, params, innerReqConfig); - } else { - throw new Error(`Unssuported statistics provider ${statsProvider}`); - } - }, reqConfig); - return stats; - } - - public async updateLayerFromServiceIfNeeded(reqConfig?: RequestConfiguration): Promise { - const legendUrl = await ensureTimeout(async (innerReqConfig) => { - if (this.instanceId === null || this.layerId === null) { - throw new Error( - "Additional data can't be fetched from service because instanceId and layerId are not defined", - ); - } - - const baseUrl = `${this.dataset.shServiceHostname}v1/wms/${this.instanceId}`; - const parsedLayers = await fetchLayersFromGetCapabilitiesXml( - baseUrl, - OgcServiceTypes.WMS, - innerReqConfig, - ); - const layer = parsedLayers.find((layerInfo) => this.layerId === layerInfo.Name[0]); - if (!layer) { - throw new Error('Layer not found'); - } - const legendUrl = - layer.Style && layer.Style[0].LegendURL - ? layer.Style[0].LegendURL[0].OnlineResource[0]['$']['xlink:href'] - : null; - return legendUrl; - }, reqConfig); - this.legendUrl = legendUrl; - } -} diff --git a/src/layer/AbstractSentinelHubV1OrV2WithCCLayer.ts b/src/layer/AbstractSentinelHubV1OrV2WithCCLayer.ts deleted file mode 100644 index eaac0250..00000000 --- a/src/layer/AbstractSentinelHubV1OrV2WithCCLayer.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { MosaickingOrder } from './const'; -import { AbstractSentinelHubV1OrV2Layer } from './AbstractSentinelHubV1OrV2Layer'; - -interface ConstructorParameters { - instanceId?: string | null; - layerId?: string | null; - evalscript?: string | null; - evalscriptUrl?: string | null; - title?: string | null; - description?: string | null; - maxCloudCoverPercent?: number | null; - mosaickingOrder?: MosaickingOrder | null; -} - -// same as AbstractSentinelHubV1OrV2Layer, but with maxCloudCoverPercent (useful for Landsat datasets) -export class AbstractSentinelHubV1OrV2WithCCLayer extends AbstractSentinelHubV1OrV2Layer { - public maxCloudCoverPercent: number; - - public constructor({ maxCloudCoverPercent = 100, ...rest }: ConstructorParameters) { - super(rest); - this.maxCloudCoverPercent = maxCloudCoverPercent; - } - - protected getWmsGetMapUrlAdditionalParameters(): Record { - return { - ...super.getWmsGetMapUrlAdditionalParameters(), - maxcc: this.maxCloudCoverPercent, - }; - } - - protected getFindTilesAdditionalParameters(): Record { - return { - maxcc: this.maxCloudCoverPercent / 100, - }; - } - - protected extractFindTilesMeta(tile: any): Record { - return { - cloudCoverPercent: tile.cloudCoverPercentage, - }; - } - - protected async getFindDatesUTCAdditionalParameters(): Promise> { - return { - maxcc: this.maxCloudCoverPercent / 100, - }; - } - - public getStatsAdditionalParameters(): Record { - return { - maxcc: this.maxCloudCoverPercent, - }; - } -} diff --git a/src/statistics/Fis.ts b/src/statistics/Fis.ts index 4551c20a..ceaf0dbe 100644 --- a/src/statistics/Fis.ts +++ b/src/statistics/Fis.ts @@ -3,7 +3,6 @@ import moment from 'moment'; import WKT from 'terraformer-wkt-parser'; import { CRS_EPSG4326, CRS_WGS84, findCrsFromUrn } from '../crs'; import type { AbstractLayer } from '../layer/AbstractLayer'; -import { AbstractSentinelHubV1OrV2Layer } from '../layer/AbstractSentinelHubV1OrV2Layer'; import type { AbstractSentinelHubV3Layer } from '../layer/AbstractSentinelHubV3Layer'; import { FisPayload, FisResponse, GetStatsParams, HistogramType } from '../layer/const'; import { CACHE_CONFIG_NOCACHE } from '../utils/cacheHandlers'; @@ -11,10 +10,7 @@ import { getAxiosReqParams, RequestConfiguration } from '../utils/cancelRequests import type { StatisticsProvider } from './StatisticsProvider'; export class Fis implements StatisticsProvider { - private createFISPayload( - layer: AbstractSentinelHubV3Layer | AbstractSentinelHubV1OrV2Layer, - params: GetStatsParams, - ): FisPayload { + private createFISPayload(layer: AbstractSentinelHubV3Layer, params: GetStatsParams): FisPayload { if (!params.geometry) { throw new Error('Parameter "geometry" needs to be provided'); } @@ -102,19 +98,4 @@ export class Fis implements StatisticsProvider { return this.convertFISResponse(data); } - - public async handleV1orV2( - layer: AbstractSentinelHubV1OrV2Layer, - params: GetStatsParams, - reqConfig?: RequestConfiguration, - ): Promise { - const payload: FisPayload = this.createFISPayload(layer, params); - - const { data } = await axios.get(layer.dataset.shServiceHostname + 'v1/fis/' + layer.getInstanceId(), { - params: payload, - ...getAxiosReqParams(reqConfig, CACHE_CONFIG_NOCACHE), - }); - - return this.convertFISResponse(data); - } } From b3b26591f8661b810860c16eb8d172cff2e7f382 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 15:45:42 +0200 Subject: [PATCH 02/11] remove findTilesUsingSearchIndex from AbstractSentinelHubV3Layer --- src/layer/AbstractSentinelHubV3Layer.ts | 57 +------------------------ 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/src/layer/AbstractSentinelHubV3Layer.ts b/src/layer/AbstractSentinelHubV3Layer.ts index 55de4023..a063419f 100644 --- a/src/layer/AbstractSentinelHubV3Layer.ts +++ b/src/layer/AbstractSentinelHubV3Layer.ts @@ -406,16 +406,7 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer { ); result = this.convertResponseFromCatalog(response); } else { - result = await this.findTilesUsingSearchIndex( - this.getSearchIndexUrl(), - bbox, - fromTime, - toTime, - maxCount, - offset, - reqConfig, - this.getFindTilesAdditionalParameters(), - ); + throw new Error('Please authenticate and provide collection id.'); } return result; } @@ -429,52 +420,6 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer { return []; } - protected async findTilesUsingSearchIndex( - searchIndexUrl: string, - bbox: BBox, - fromTime: Date, - toTime: Date, - maxCount: number | null = null, - offset: number | null = null, - reqConfig: RequestConfiguration, - findTilesAdditionalParameters: FindTilesAdditionalParameters, - ): Promise { - if (maxCount === null) { - maxCount = DEFAULT_FIND_TILES_MAX_COUNT_PARAMETER; - } - if (offset === null) { - offset = 0; - } - if (!searchIndexUrl) { - throw new Error('This dataset does not support searching for tiles'); - } - - const { maxCloudCoverPercent, datasetParameters } = findTilesAdditionalParameters; - - const bboxPolygon = bbox.toGeoJSON(); - // Note: we are requesting maxCloudCoverage as a number between 0 and 1, but in - // the tiles we get cloudCoverPercentage (0..100). - const payload: any = { - clipping: bboxPolygon, - maxcount: maxCount, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : null, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: offset, - }; - - if (datasetParameters) { - payload.datasetParameters = datasetParameters; - } - - const response = await axios.post( - searchIndexUrl, - payload, - this.createSearchIndexRequestConfig(reqConfig), - ); - return this.convertResponseFromSearchIndex(response); - } - protected createCatalogFilterQuery( maxCloudCoverPercent?: number | null, // eslint-disable-line @typescript-eslint/no-unused-vars datasetParameters?: Record | null, // eslint-disable-line @typescript-eslint/no-unused-vars From bddc656ea2fb380d06f0377bd8ad221d5997c8c3 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 15:48:27 +0200 Subject: [PATCH 03/11] remove findDatesUTCSearchIndex from AbstractSentinelHubV3Layer --- src/layer/AbstractSentinelHubV3Layer.ts | 39 +------------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/layer/AbstractSentinelHubV3Layer.ts b/src/layer/AbstractSentinelHubV3Layer.ts index a063419f..b41442fb 100644 --- a/src/layer/AbstractSentinelHubV3Layer.ts +++ b/src/layer/AbstractSentinelHubV3Layer.ts @@ -505,12 +505,6 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer { return {}; } - protected async getFindDatesUTCUrl( - reqConfig?: RequestConfiguration, // eslint-disable-line @typescript-eslint/no-unused-vars - ): Promise { - return this.dataset.findDatesUTCUrl; - } - public async findDatesUTC( bbox: BBox, fromTime: Date, @@ -523,43 +517,12 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer { if (canUseCatalog) { return await this.findDatesUTCCatalog(innerReqConfig, authToken, bbox, fromTime, toTime); } else { - return await this.findDatesUTCSearchIndex(innerReqConfig, bbox, fromTime, toTime); + throw new Error('Please authenticate and provide collection id.'); } }, reqConfig); return findDatesUTCValue; } - private async findDatesUTCSearchIndex( - innerReqConfig: RequestConfiguration, - bbox: BBox, - fromTime: Date, - toTime: Date, - ): Promise { - const findDatesUTCUrl = await this.getFindDatesUTCUrl(innerReqConfig); - if (!findDatesUTCUrl) { - throw new Error('This dataset does not support searching for dates'); - } - - const bboxPolygon = bbox.toGeoJSON(); - const payload: any = { - queryArea: bboxPolygon, - from: fromTime.toISOString(), - to: toTime.toISOString(), - ...(await this.getFindDatesUTCAdditionalParameters(innerReqConfig)), - }; - - const axiosReqConfig: AxiosRequestConfig = { - ...getAxiosReqParams(innerReqConfig, CACHE_CONFIG_30MIN), - }; - const response = await axios.post(findDatesUTCUrl, payload, axiosReqConfig); - const found: Moment[] = response.data.map((date: string) => moment.utc(date)); - - // S-5P, S-3 and possibly other datasets return the results in reverse order (leastRecent). - // Let's sort the data so that we always return most recent results first: - found.sort((a, b) => b.unix() - a.unix()); - return found.map((m) => m.toDate()); - } - protected async findDatesUTCCatalog( innerReqConfig: RequestConfiguration, authToken: string, From 2ca7f59a264d3fa76ccb18a70f219970fad3b8f9 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 15:49:12 +0200 Subject: [PATCH 04/11] remove unneded imports in AbstractSentinelHubV3Layer --- src/layer/AbstractSentinelHubV3Layer.ts | 3 +-- src/layer/const.ts | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/layer/AbstractSentinelHubV3Layer.ts b/src/layer/AbstractSentinelHubV3Layer.ts index b41442fb..1cfe3923 100644 --- a/src/layer/AbstractSentinelHubV3Layer.ts +++ b/src/layer/AbstractSentinelHubV3Layer.ts @@ -1,6 +1,6 @@ import { Geometry } from '@turf/helpers'; import axios, { AxiosRequestConfig } from 'axios'; -import moment, { Moment } from 'moment'; +import moment from 'moment'; import { getAuthToken } from '../auth'; import { BBox } from '../bbox'; @@ -11,7 +11,6 @@ import { ApiType, CATALOG_SEARCH_MAX_LIMIT, DataProductId, - DEFAULT_FIND_TILES_MAX_COUNT_PARAMETER, FindTilesAdditionalParameters, GetMapParams, GetStatsParams, diff --git a/src/layer/const.ts b/src/layer/const.ts index ef0873a4..a767433e 100644 --- a/src/layer/const.ts +++ b/src/layer/const.ts @@ -234,8 +234,6 @@ export type FisResponse = { export type Stats = FisResponse | StatisticalApiResponse; -export const DEFAULT_FIND_TILES_MAX_COUNT_PARAMETER = 50; - export type DataProductId = string; export const SUPPORTED_DATA_PRODUCTS_PROCESSING: DataProductId[] = [ From dded7f3d000a0b7fe71d437b12c50c6ba41f85d5 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 15:51:15 +0200 Subject: [PATCH 05/11] remove getSearchIndexUrl from and BYOCLayer --- src/layer/AbstractSentinelHubV3Layer.ts | 4 ---- src/layer/BYOCLayer.ts | 6 ------ 2 files changed, 10 deletions(-) diff --git a/src/layer/AbstractSentinelHubV3Layer.ts b/src/layer/AbstractSentinelHubV3Layer.ts index 1cfe3923..7f5c5f24 100644 --- a/src/layer/AbstractSentinelHubV3Layer.ts +++ b/src/layer/AbstractSentinelHubV3Layer.ts @@ -168,10 +168,6 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer { return this.dataset.catalogCollectionId; } - protected getSearchIndexUrl(): string { - return this.dataset.searchIndexUrl; - } - protected async fetchEvalscriptUrlIfNeeded(reqConfig: RequestConfiguration): Promise { if (this.evalscriptUrl && !this.evalscript) { const response = await axios.get(this.evalscriptUrl, { diff --git a/src/layer/BYOCLayer.ts b/src/layer/BYOCLayer.ts index 7a7acc63..1f6c6bcc 100644 --- a/src/layer/BYOCLayer.ts +++ b/src/layer/BYOCLayer.ts @@ -249,12 +249,6 @@ export class BYOCLayer extends AbstractSentinelHubV3Layer { return this.getTypeId(); } - protected getSearchIndexUrl(): string { - const rootUrl = this.getShServiceHostname(); - const searchIndexUrl = `${rootUrl}byoc/v3/collections/CUSTOM/searchIndex`; - return searchIndexUrl; - } - protected createSearchIndexRequestConfig(): AxiosRequestConfig { return {}; } From 76c773614370a0aa8c67bb4e1738fe114dd7d1ea Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 15:57:10 +0200 Subject: [PATCH 06/11] remove getFindDatesUTCUrl from BYOCLayer --- src/layer/BYOCLayer.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/layer/BYOCLayer.ts b/src/layer/BYOCLayer.ts index 1f6c6bcc..1a0a35e1 100644 --- a/src/layer/BYOCLayer.ts +++ b/src/layer/BYOCLayer.ts @@ -253,13 +253,6 @@ export class BYOCLayer extends AbstractSentinelHubV3Layer { return {}; } - protected async getFindDatesUTCUrl(reqConfig: RequestConfiguration): Promise { - await this.updateLayerFromServiceIfNeeded(reqConfig); - const rootUrl = SHV3_LOCATIONS_ROOT_URL[this.locationId]; - const findDatesUTCUrl = `${rootUrl}byoc/v3/collections/CUSTOM/findAvailableData`; - return findDatesUTCUrl; - } - protected async getFindDatesUTCAdditionalParameters( reqConfig: RequestConfiguration, ): Promise> { From 1275a4cdccf1ca501963ae390ead6bd43c7929f3 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 16:15:01 +0200 Subject: [PATCH 07/11] remove tests for findTiles and findDatesUTC using searchIndex --- src/layer/__tests__/BYOCLayer.ts | 79 +----- src/layer/__tests__/Landsat8AWSLayer.ts | 74 +---- src/layer/__tests__/MODISLayer.ts | 74 +---- src/layer/__tests__/S1GRDAWSLayer.ts | 215 +-------------- src/layer/__tests__/S2L1CCDASLayer.ts | 75 +---- src/layer/__tests__/S2L1CLayer.ts | 75 +---- src/layer/__tests__/S2L2ACDASLayer.ts | 75 +---- src/layer/__tests__/S2L2ACLayer.ts | 75 +---- src/layer/__tests__/S3OLCICDASLayer.ts | 75 +---- src/layer/__tests__/S3OLCILayer.ts | 75 +---- src/layer/__tests__/S3SLTRCDASLayer.ts | 78 +----- src/layer/__tests__/S3SLTRLayer.ts | 78 +----- src/layer/__tests__/S5PL2CDASLayer.ts | 78 +----- src/layer/__tests__/S5PL2Layer.ts | 78 +----- src/layer/__tests__/fixtures.BYOCLayer.ts | 136 +-------- .../__tests__/fixtures.Landsat8AWSLayer.ts | 151 +--------- src/layer/__tests__/fixtures.MODISLayer.ts | 109 +------- src/layer/__tests__/fixtures.S1GRDAWSLayer.ts | 230 +--------------- .../__tests__/fixtures.S2L1CCDASLayer.ts | 145 +--------- src/layer/__tests__/fixtures.S2L1CLayer.ts | 145 +--------- .../__tests__/fixtures.S2L2ACDASLayer.ts | 209 +------------- src/layer/__tests__/fixtures.S2L2ALayer.ts | 209 +------------- src/layer/__tests__/fixtures.S3OLCILayer.ts | 222 +-------------- src/layer/__tests__/fixtures.S3SLTRLayer.ts | 260 +----------------- src/layer/__tests__/fixtures.S5PL2Layer.ts | 191 +------------ src/layer/__tests__/fixtures.findDatesUTC.ts | 137 --------- 26 files changed, 62 insertions(+), 3286 deletions(-) diff --git a/src/layer/__tests__/BYOCLayer.ts b/src/layer/__tests__/BYOCLayer.ts index 6ee37803..725d1008 100644 --- a/src/layer/__tests__/BYOCLayer.ts +++ b/src/layer/__tests__/BYOCLayer.ts @@ -1,6 +1,6 @@ import { CRS_EPSG4326, setAuthToken, LocationIdSHv3, BYOCLayer, CRS_EPSG3857, BBox } from '../../index'; import { SHV3_LOCATIONS_ROOT_URL, BYOCSubTypes, SH_SERVICE_ROOT_URL } from '../const'; -import { constructFixtureFindTilesSearchIndex, constructFixtureFindTilesCatalog } from './fixtures.BYOCLayer'; +import { constructFixtureFindTilesCatalog } from './fixtures.BYOCLayer'; import { AUTH_TOKEN, @@ -16,14 +16,8 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; -const SEARCH_INDEX_URL = `${ - SHV3_LOCATIONS_ROOT_URL[LocationIdSHv3.awsEuCentral1] -}byoc/v3/collections/CUSTOM/searchIndex`; const CATALOG_URL = `${SHV3_LOCATIONS_ROOT_URL[LocationIdSHv3.awsEuCentral1]}api/v1/catalog/1.0.0/search`; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); @@ -49,26 +43,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -89,55 +63,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new BYOCLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - collectionId: 'mockCollectionId', - locationId: LocationIdSHv3.awsEuCentral1, - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - 'https://services.sentinel-hub.com/byoc/v3/collections/CUSTOM/findAvailableData', - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams && layerParams.collectionId) { - constructorParams.collectionId = layerParams.collectionId; - } - - if (layerParams && layerParams.locationId) { - constructorParams.locationId = layerParams.locationId; - } - - const layer = new BYOCLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new BYOCLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - collectionId: 'mockCollectionId', - locationId: LocationIdSHv3.awsEuCentral1, - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/Landsat8AWSLayer.ts b/src/layer/__tests__/Landsat8AWSLayer.ts index b5667fd8..5d825f20 100644 --- a/src/layer/__tests__/Landsat8AWSLayer.ts +++ b/src/layer/__tests__/Landsat8AWSLayer.ts @@ -1,8 +1,5 @@ -import { BBox, CRS_EPSG4326, setAuthToken, Landsat8AWSLayer, DATASET_AWS_L8L1C } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.Landsat8AWSLayer'; +import { BBox, CRS_EPSG4326, setAuthToken, Landsat8AWSLayer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.Landsat8AWSLayer'; import { AUTH_TOKEN, @@ -18,12 +15,8 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; -const SEARCH_INDEX_URL = 'https://services-uswest2.sentinel-hub.com/index/v3/collections/L8L1C/searchIndex'; const CATALOG_URL = 'https://services-uswest2.sentinel-hub.com/api/v1/catalog/1.0.0/search'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); @@ -57,26 +50,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -97,47 +70,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new Landsat8AWSLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_AWS_L8L1C.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new Landsat8AWSLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new Landsat8AWSLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/MODISLayer.ts b/src/layer/__tests__/MODISLayer.ts index bb332a8c..82605234 100644 --- a/src/layer/__tests__/MODISLayer.ts +++ b/src/layer/__tests__/MODISLayer.ts @@ -1,8 +1,5 @@ -import { BBox, CRS_EPSG4326, setAuthToken, MODISLayer, DATASET_MODIS } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.MODISLayer'; +import { BBox, CRS_EPSG4326, setAuthToken, MODISLayer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.MODISLayer'; import { AUTH_TOKEN, @@ -18,13 +15,9 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; const CATALOG_URL = 'https://services-uswest2.sentinel-hub.com/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://services-uswest2.sentinel-hub.com/index/v3/collections/MODIS/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -38,26 +31,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -78,47 +51,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new MODISLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_MODIS.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new MODISLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new MODISLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S1GRDAWSLayer.ts b/src/layer/__tests__/S1GRDAWSLayer.ts index b5cf5951..ad1a01be 100644 --- a/src/layer/__tests__/S1GRDAWSLayer.ts +++ b/src/layer/__tests__/S1GRDAWSLayer.ts @@ -6,15 +6,11 @@ import { Polarization, Resolution, OrbitDirection, - LinkType, setAuthToken, MosaickingOrder, } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S1GRDAWSLayer'; +import { constructFixtureFindTilesCatalog } from './fixtures.S1GRDAWSLayer'; import { AUTH_TOKEN, @@ -30,11 +26,7 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; -import { DATASET_AWSEU_S1GRD } from '../dataset'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; test('timezone should NOT be UTC', () => { // We are testing correctness in case of local timezones, so it doesn't make sense to @@ -67,125 +59,7 @@ test('constructor with mosaickingOrder parameter', () => { expect(layer.mosaickingOrder).toEqual(expectedMosaickingOrder); }); -test.each([ - [true, '2018-11-28T11:12:13Z', new Date(Date.UTC(2018, 11 - 1, 28, 11, 12, 13))], - [false, '2018-11-28T11:12:13Z', new Date(Date.UTC(2018, 11 - 1, 28, 11, 12, 13))], - [false, '2018-11-11T00:01:02Z', new Date(Date.UTC(2018, 11 - 1, 11, 0, 1, 2))], -])( - 'S1GRDLayer.findTiles returns correct data (%p, %p, %p)', - async (hasMoreFixture, sensingTimeFixture, expectedSensingTimeFixture) => { - const fromTime = new Date(Date.UTC(2018, 11 - 1, 22, 0, 0, 0)); - const toTime = new Date(Date.UTC(2018, 12 - 1, 22, 23, 59, 59)); - const bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21); - const layer = new S1GRDAWSEULayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - acquisitionMode: AcquisitionMode.IW, - polarization: Polarization.DV, - resolution: Resolution.HIGH, - }); - - // mock a single-tile response: - mockNetwork.reset(); - mockNetwork.onPost().replyOnce(200, { - tiles: [ - { - type: 'S1', - id: 1293846, - originalId: 'S1A_EW_GRDM_1SDH_20200202T180532_20200202T180632_031077_03921C_E6C8', - dataUri: - 's3://sentinel-s1-l1c/GRD/2020/2/2/EW/DH/S1A_EW_GRDM_1SDH_20200202T180532_20200202T180632_031077_03921C_E6C8', - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-28.958387727765576, 77.22089053106154], - [-28.454271377131395, 77.28385150034897], - [-27.718918346651687, 77.37243188785827], - [-26.974008583323926, 77.45890918854761], - [-26.217031402559755, 77.54352656462356], - [-25.447186512415197, 77.62630504330521], - [-24.667542862300945, 77.7068623880844], - [-28.958387727765576, 77.22089053106154], - ], - ], - ], - }, - sensingTime: sensingTimeFixture, - rasterWidth: 10459, - rasterHeight: 9992, - polarization: 'DV', - resolution: 'HIGH', - orbitDirection: 'ASCENDING', - acquisitionMode: 'IW', - timeliness: 'NRT3h', - additionalData: {}, - missionDatatakeId: 234012, - sliceNumber: 5, - }, - ], - hasMore: hasMoreFixture, - maxOrderKey: '2020-02-02T08:17:57Z;1295159', - }); - - const { tiles, hasMore } = await layer.findTiles(bbox, fromTime, toTime, 5, 0); - - expect(mockNetwork.history.post.length).toBe(1); - expect(hasMore).toBe(hasMoreFixture); - expect(tiles).toStrictEqual([ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-28.958387727765576, 77.22089053106154], - [-28.454271377131395, 77.28385150034897], - [-27.718918346651687, 77.37243188785827], - [-26.974008583323926, 77.45890918854761], - [-26.217031402559755, 77.54352656462356], - [-25.447186512415197, 77.62630504330521], - [-24.667542862300945, 77.7068623880844], - [-28.958387727765576, 77.22089053106154], - ], - ], - ], - }, - sensingTime: expectedSensingTimeFixture, - meta: { - acquisitionMode: AcquisitionMode.IW, - polarization: Polarization.DV, - resolution: Resolution.HIGH, - orbitDirection: OrbitDirection.ASCENDING, - tileId: 1293846, - }, - links: [ - { - target: - 's3://sentinel-s1-l1c/GRD/2020/2/2/EW/DH/S1A_EW_GRDM_1SDH_20200202T180532_20200202T180632_031077_03921C_E6C8', - type: LinkType.AWS, - }, - ], - }, - ]); - }, -); - const CATALOG_URL = 'https://services.sentinel-hub.com/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://services.sentinel-hub.com/index/v3/collections/S1GRD/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -230,26 +104,6 @@ const layerParamsArr: Record[] = [ })), ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -270,71 +124,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S1GRDAWSEULayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_AWSEU_S1GRD.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - - if (layerParams && layerParams.acquisitionMode) { - constructorParams.acquisitionMode = layerParams.acquisitionMode; - } - - if (layerParams && layerParams.orbitDirection) { - constructorParams.orbitDirection = layerParams.orbitDirection; - } - - if (layerParams && layerParams.polarization) { - constructorParams.polarization = layerParams.polarization; - } - - if (layerParams && layerParams.resolution) { - constructorParams.resolution = layerParams.resolution; - } - - const layer = new S1GRDAWSEULayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S1GRDAWSEULayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - acquisitionMode: AcquisitionMode.IW, - polarization: Polarization.DV, - resolution: Resolution.HIGH, - orbitDirection: OrbitDirection.ASCENDING, - }); - await checkResponseFindDatesUTC( - constructFixtureFindDatesUTCSearchIndex(layer, { - acquisitionMode: AcquisitionMode.IW, - polarization: Polarization.DV, - resolution: Resolution.HIGH, - orbitDirection: OrbitDirection.ASCENDING, - }), - ); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S2L1CCDASLayer.ts b/src/layer/__tests__/S2L1CCDASLayer.ts index 25f1e662..39353876 100644 --- a/src/layer/__tests__/S2L1CCDASLayer.ts +++ b/src/layer/__tests__/S2L1CCDASLayer.ts @@ -1,9 +1,6 @@ -import { DATASET_CDAS_S2L1C, S2L1CCDASLayer, setAuthToken } from '../../index'; +import { S2L1CCDASLayer, setAuthToken } from '../../index'; import { ApiType, BBox, CRS_EPSG4326 } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S2L1CCDASLayer'; +import { constructFixtureFindTilesCatalog } from './fixtures.S2L1CCDASLayer'; import { AUTH_TOKEN, @@ -20,14 +17,9 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; -const SEARCH_INDEX_URL = 'https://sh.dataspace.copernicus.eu/index/v3/collections/S2L1C/searchIndex'; - const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); const bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21); @@ -59,26 +51,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -103,47 +75,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S2L1CCDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_CDAS_S2L1C.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new S2L1CCDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S2L1CCDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S2L1CLayer.ts b/src/layer/__tests__/S2L1CLayer.ts index 8fb6d1c8..5b809d7f 100644 --- a/src/layer/__tests__/S2L1CLayer.ts +++ b/src/layer/__tests__/S2L1CLayer.ts @@ -1,9 +1,6 @@ import { setAuthToken } from '../../index'; -import { ApiType, BBox, CRS_EPSG4326, S2L1CLayer, DATASET_S2L1C } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S2L1CLayer'; +import { ApiType, BBox, CRS_EPSG4326, S2L1CLayer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S2L1CLayer'; import { AUTH_TOKEN, @@ -20,14 +17,9 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; -const SEARCH_INDEX_URL = 'https://services.sentinel-hub.com/index/v3/collections/S2L1C/searchIndex'; - const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); const bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21); @@ -59,26 +51,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -99,47 +71,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S2L1CLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_S2L1C.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new S2L1CLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S2L1CLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S2L2ACDASLayer.ts b/src/layer/__tests__/S2L2ACDASLayer.ts index 3bde9501..12f60712 100644 --- a/src/layer/__tests__/S2L2ACDASLayer.ts +++ b/src/layer/__tests__/S2L2ACDASLayer.ts @@ -1,9 +1,6 @@ -import { DATASET_CDAS_S2L2A, S2L2ACDASLayer, setAuthToken } from '../../index'; +import { S2L2ACDASLayer, setAuthToken } from '../../index'; import { BBox, CRS_EPSG4326 } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S2L2ACDASLayer'; +import { constructFixtureFindTilesCatalog } from './fixtures.S2L2ACDASLayer'; import { AUTH_TOKEN, @@ -20,14 +17,9 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; -const SEARCH_INDEX_URL = 'https://sh.dataspace.copernicus.eu/index/v3/collections/S2L2A/searchIndex'; - const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); const bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21); @@ -59,26 +51,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -103,47 +75,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S2L2ACDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_CDAS_S2L2A.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new S2L2ACDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S2L2ACDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S2L2ACLayer.ts b/src/layer/__tests__/S2L2ACLayer.ts index 11957554..a36d3de1 100644 --- a/src/layer/__tests__/S2L2ACLayer.ts +++ b/src/layer/__tests__/S2L2ACLayer.ts @@ -1,9 +1,6 @@ import { setAuthToken } from '../../index'; -import { BBox, CRS_EPSG4326, S2L2ALayer, DATASET_S2L2A } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S2L2ALayer'; +import { BBox, CRS_EPSG4326, S2L2ALayer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S2L2ALayer'; import { AUTH_TOKEN, @@ -20,14 +17,9 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; -const SEARCH_INDEX_URL = 'https://services.sentinel-hub.com/index/v3/collections/S2L2A/searchIndex'; - const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); const bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21); @@ -59,26 +51,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed(null, constructFixtureFindTilesSearchIndex({}), SEARCH_INDEX_URL); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex({})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -99,47 +71,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S2L2ALayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_S2L2A.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new S2L2ALayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S2L2ALayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S3OLCICDASLayer.ts b/src/layer/__tests__/S3OLCICDASLayer.ts index cefd5137..45bae94b 100644 --- a/src/layer/__tests__/S3OLCICDASLayer.ts +++ b/src/layer/__tests__/S3OLCICDASLayer.ts @@ -1,8 +1,5 @@ -import { BBox, CRS_EPSG4326, S3OLCICDASLayer, setAuthToken, DATASET_CDAS_S3OLCI } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S3OLCILayer'; +import { BBox, CRS_EPSG4326, S3OLCICDASLayer, setAuthToken } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S3OLCILayer'; import { AUTH_TOKEN, @@ -18,14 +15,10 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; const CATALOG_URL = 'https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3OLCI/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -39,30 +32,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed( - null, - constructFixtureFindTilesSearchIndex(S3OLCICDASLayer, {}), - SEARCH_INDEX_URL, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(S3OLCICDASLayer, layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex(S3OLCICDASLayer, {})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -87,44 +56,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S3OLCICDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_CDAS_S3OLCI.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - - const layer = new S3OLCICDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S3OLCICDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S3OLCILayer.ts b/src/layer/__tests__/S3OLCILayer.ts index 86138463..012fe61a 100644 --- a/src/layer/__tests__/S3OLCILayer.ts +++ b/src/layer/__tests__/S3OLCILayer.ts @@ -1,8 +1,5 @@ -import { BBox, CRS_EPSG4326, S3OLCILayer, setAuthToken, DATASET_S3OLCI } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S3OLCILayer'; +import { BBox, CRS_EPSG4326, S3OLCILayer, setAuthToken } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S3OLCILayer'; import { AUTH_TOKEN, @@ -18,14 +15,10 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; const CATALOG_URL = 'https://creodias.sentinel-hub.com/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://creodias.sentinel-hub.com/index/v3/collections/S3OLCI/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -39,30 +32,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed( - null, - constructFixtureFindTilesSearchIndex(S3OLCILayer, {}), - SEARCH_INDEX_URL, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(S3OLCILayer, layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex(S3OLCILayer, {})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -87,44 +56,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S3OLCILayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_S3OLCI.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - - const layer = new S3OLCILayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S3OLCILayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S3SLTRCDASLayer.ts b/src/layer/__tests__/S3SLTRCDASLayer.ts index ff9e5540..03f28b36 100644 --- a/src/layer/__tests__/S3SLTRCDASLayer.ts +++ b/src/layer/__tests__/S3SLTRCDASLayer.ts @@ -1,9 +1,6 @@ import { setAuthToken } from '../../index'; -import { BBox, CRS_EPSG4326, S3SLSTRCDASLayer, DATASET_CDAS_S3SLSTR } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S3SLTRLayer'; +import { BBox, CRS_EPSG4326, S3SLSTRCDASLayer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S3SLTRLayer'; import { AUTH_TOKEN, @@ -19,14 +16,10 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; const CATALOG_URL = 'https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3SLSTR/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -59,30 +52,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed( - null, - constructFixtureFindTilesSearchIndex(S3SLSTRCDASLayer, {}), - SEARCH_INDEX_URL, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(S3SLSTRCDASLayer, layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex(S3SLSTRCDASLayer, {})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -107,47 +76,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S3SLSTRCDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_CDAS_S3SLSTR.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new S3SLSTRCDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S3SLSTRCDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S3SLTRLayer.ts b/src/layer/__tests__/S3SLTRLayer.ts index 4d2e32a9..d83bc7a3 100644 --- a/src/layer/__tests__/S3SLTRLayer.ts +++ b/src/layer/__tests__/S3SLTRLayer.ts @@ -1,9 +1,6 @@ import { setAuthToken } from '../../index'; -import { BBox, CRS_EPSG4326, S3SLSTRLayer, DATASET_S3SLSTR } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S3SLTRLayer'; +import { BBox, CRS_EPSG4326, S3SLSTRLayer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S3SLTRLayer'; import { AUTH_TOKEN, @@ -19,14 +16,10 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { checkLayersParamsEndpoint } from './testUtils.layers'; const CATALOG_URL = 'https://creodias.sentinel-hub.com/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://creodias.sentinel-hub.com/index/v3/collections/S3SLSTR/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -59,30 +52,6 @@ const layerParamsArr: Record[] = [ }, ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed( - null, - constructFixtureFindTilesSearchIndex(S3SLSTRLayer, {}), - SEARCH_INDEX_URL, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(S3SLSTRLayer, layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex(S3SLSTRLayer, {})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -107,47 +76,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S3SLSTRLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_S3SLSTR.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams.maxCloudCoverPercent !== null && layerParams.maxCloudCoverPercent !== undefined) { - constructorParams.maxCloudCoverPercent = layerParams.maxCloudCoverPercent; - } - - const layer = new S3SLSTRLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S3SLSTRLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S5PL2CDASLayer.ts b/src/layer/__tests__/S5PL2CDASLayer.ts index 48e28533..70549ef9 100644 --- a/src/layer/__tests__/S5PL2CDASLayer.ts +++ b/src/layer/__tests__/S5PL2CDASLayer.ts @@ -1,8 +1,5 @@ -import { BBox, CRS_EPSG4326, DATASET_CDAS_S5PL2, setAuthToken, S5PL2CDASLayer } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S5PL2Layer'; +import { BBox, CRS_EPSG4326, setAuthToken, S5PL2CDASLayer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S5PL2Layer'; import { AUTH_TOKEN, @@ -18,16 +15,12 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { ProductType } from '../S5PL2Layer'; import { checkLayersParamsEndpoint } from './testUtils.layers'; const CATALOG_URL = 'https://sh.dataspace.copernicus.eu/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://sh.dataspace.copernicus.eu/index/v3/collections/S5PL2/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -47,30 +40,6 @@ const layerParamsArr: Record[] = [ })), ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed( - null, - constructFixtureFindTilesSearchIndex(S5PL2CDASLayer, {}), - SEARCH_INDEX_URL, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(S5PL2CDASLayer, layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex(S5PL2CDASLayer, {})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -95,47 +64,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S5PL2CDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_CDAS_S5PL2.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams && layerParams.productType) { - constructorParams.productType = layerParams.productType; - } - - const layer = new S5PL2CDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S5PL2CDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/S5PL2Layer.ts b/src/layer/__tests__/S5PL2Layer.ts index b91ceef2..b681bdd6 100644 --- a/src/layer/__tests__/S5PL2Layer.ts +++ b/src/layer/__tests__/S5PL2Layer.ts @@ -1,9 +1,6 @@ import { setAuthToken } from '../../index'; -import { BBox, CRS_EPSG4326, S5PL2Layer, DATASET_S5PL2 } from '../../index'; -import { - constructFixtureFindTilesSearchIndex, - constructFixtureFindTilesCatalog, -} from './fixtures.S5PL2Layer'; +import { BBox, CRS_EPSG4326, S5PL2Layer } from '../../index'; +import { constructFixtureFindTilesCatalog } from './fixtures.S5PL2Layer'; import { AUTH_TOKEN, @@ -19,16 +16,12 @@ import { checkResponseFindDatesUTC, } from './testUtils.findDatesUTC'; -import { - constructFixtureFindDatesUTCSearchIndex, - constructFixtureFindDatesUTCCatalog, -} from './fixtures.findDatesUTC'; +import { constructFixtureFindDatesUTCCatalog } from './fixtures.findDatesUTC'; import { ProductType } from '../S5PL2Layer'; import { checkLayersParamsEndpoint } from './testUtils.layers'; const CATALOG_URL = 'https://creodias.sentinel-hub.com/api/v1/catalog/1.0.0/search'; -const SEARCH_INDEX_URL = 'https://creodias.sentinel-hub.com/index/v3/collections/S5PL2/searchIndex'; const fromTime: Date = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)); const toTime: Date = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)); @@ -48,30 +41,6 @@ const layerParamsArr: Record[] = [ })), ]; -describe('Test findTiles using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('searchIndex is used if token is not set', async () => { - await checkIfCorrectEndpointIsUsed( - null, - constructFixtureFindTilesSearchIndex(S5PL2Layer, {}), - SEARCH_INDEX_URL, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - const fixtures = constructFixtureFindTilesSearchIndex(S5PL2Layer, layerParams); - await checkRequestFindTiles(fixtures); - }); - - test('response from searchIndex', async () => { - await checkResponseFindTiles(constructFixtureFindTilesSearchIndex(S5PL2Layer, {})); - }); -}); - describe('Test findTiles using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); @@ -96,47 +65,6 @@ describe('Test findTiles using catalog', () => { }); }); -describe('Test findDatesUTC using searchIndex', () => { - beforeEach(async () => { - setAuthToken(null); - mockNetwork.reset(); - }); - - test('findAvailableData is used if token is not set', async () => { - const layer = new S5PL2Layer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkIfCorrectEndpointIsUsedFindDatesUTC( - null, - constructFixtureFindDatesUTCSearchIndex(layer, {}), - DATASET_S5PL2.findDatesUTCUrl, - ); - }); - - test.each(layerParamsArr)('check if correct request is constructed', async (layerParams) => { - let constructorParams: Record = {}; - if (layerParams && layerParams.productType) { - constructorParams.productType = layerParams.productType; - } - - const layer = new S5PL2Layer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - ...constructorParams, - }); - const fixtures = constructFixtureFindDatesUTCSearchIndex(layer, layerParams); - await checkRequestFindDatesUTC(fixtures); - }); - - test('response from service', async () => { - const layer = new S5PL2Layer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - await checkResponseFindDatesUTC(constructFixtureFindDatesUTCSearchIndex(layer, {})); - }); -}); describe('Test findDatesUTC using catalog', () => { beforeEach(async () => { setAuthToken(AUTH_TOKEN); diff --git a/src/layer/__tests__/fixtures.BYOCLayer.ts b/src/layer/__tests__/fixtures.BYOCLayer.ts index 6d076a06..a60a7ccb 100644 --- a/src/layer/__tests__/fixtures.BYOCLayer.ts +++ b/src/layer/__tests__/fixtures.BYOCLayer.ts @@ -2,136 +2,6 @@ import moment from 'moment'; import { BYOCLayer, BBox, CRS_EPSG4326, LocationIdSHv3, BYOCSubTypes } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-04T10:19:39.900Z', - hasMore = false, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - collectionId = 'fafb9454-80ea-431d-b36f-a127faa929c7', - locationId = LocationIdSHv3.awsEuCentral1, -}): Record { - const layer = new BYOCLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - collectionId: collectionId, - locationId: locationId, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxCloudCoverage: null as any, - maxcount: 5, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - datasetParameters: { type: 'BYOC', collectionId: collectionId }, - }; - - const mockedResponse = { - tiles: [ - { - type: 'BYOC', - id: 118402, - originalId: 'a6e798fe-550c-4e5b-beb0-6bb22b37dd75', - dataUri: - 's3://sh.tpdi.byoc.eu-central-1/42f086c7-d327-4e93-ac15-48008abf24b2/c9320284-761f-4d7c-a78c-83f77bf1c585/PHR1B_202004041019399_ORT_6ae5fb8f_R1C1/(BAND).tiff', - tileEnvelope: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::32633' } }, - coordinates: [ - [ - [267100.0, 4637458.0], - [274984.0, 4637458.0], - [274984.0, 4627238.0], - [267100.0, 4627238.0], - [267100.0, 4637458.0], - ], - ], - }, - dataGeometry: { - type: 'MultiPolygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::32633' } }, - coordinates: [ - [ - [ - [273582.9992657101, 4637457.000306206], - [270732.7491996665, 4636314.750305427], - [267100.9991082235, 4634861.0003044875], - [268873.1909535045, 4627238.000299189], - [269848.98796083464, 4627773.219263511], - [274983.9993020628, 4630595.112849303], - [274983.82442607975, 4630600.773689148], - [274216.6154533472, 4634370.86926318], - [273590.2492658865, 4637441.750306196], - [273587.22117591917, 4637455.593002837], - [273582.9992657101, 4637457.000306206], - ], - ], - ], - }, - sensingTime: '2020-04-04T10:19:39.900Z', - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-02-08T10:00:00.300Z;147290', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::32633', - }, - }, - coordinates: [ - [ - [ - [273582.9992657101, 4637457.000306206], - [270732.7491996665, 4636314.750305427], - [267100.9991082235, 4634861.0003044875], - [268873.1909535045, 4627238.000299189], - [269848.98796083464, 4627773.219263511], - [274983.9993020628, 4630595.112849303], - [274983.82442607975, 4630600.773689148], - [274216.6154533472, 4634370.86926318], - [273590.2492658865, 4637441.750306196], - [273587.22117591917, 4637455.593002837], - [273582.9992657101, 4637457.000306206], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: {}, - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-04-04T10:19:39Z', hasMore = false, @@ -215,14 +85,12 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://services.sentinel-hub.com/api/v1/catalog/collections/3c4daecf-09f3-451c-8c3c-90e356cbd673/items/a6e798fe-550c-4e5b-beb0-6bb22b37dd75', + href: 'https://services.sentinel-hub.com/api/v1/catalog/collections/3c4daecf-09f3-451c-8c3c-90e356cbd673/items/a6e798fe-550c-4e5b-beb0-6bb22b37dd75', rel: 'self', type: 'application/json', }, { - href: - 'https://services.sentinel-hub.com/api/v1/catalog/collections/3c4daecf-09f3-451c-8c3c-90e356cbd673', + href: 'https://services.sentinel-hub.com/api/v1/catalog/collections/3c4daecf-09f3-451c-8c3c-90e356cbd673', rel: 'parent', }, ], diff --git a/src/layer/__tests__/fixtures.Landsat8AWSLayer.ts b/src/layer/__tests__/fixtures.Landsat8AWSLayer.ts index 6234bb28..b411efd0 100644 --- a/src/layer/__tests__/fixtures.Landsat8AWSLayer.ts +++ b/src/layer/__tests__/fixtures.Landsat8AWSLayer.ts @@ -2,151 +2,6 @@ import moment from 'moment'; import { LinkType, Landsat8AWSLayer, BBox, CRS_EPSG4326 } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-30T10:12:11.382Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - maxCloudCoverPercent = 20, -}): Record { - const layer = new Landsat8AWSLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - maxCloudCoverPercent: maxCloudCoverPercent, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxcount: 5, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : null, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'L8', - id: 2772179, - originalId: 'LC08_L1GT_194033_20200430_20200430_01_RT', - dataUri: - 'http://landsat-pds.s3.amazonaws.com/c1/L8/194/033/LC08_L1GT_194033_20200430_20200430_01_RT/LC08_L1GT_194033_20200430_20200430_01_RT', - tileEnvelope: { - type: 'Polygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::32632', - }, - }, - coordinates: [ - [ - [167700.0, 4428300.0], - [403500.0, 4428300.0], - [403500.0, 4188900.0], - [167700.0, 4188900.0], - [167700.0, 4428300.0], - ], - ], - }, - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [5.7109842887919795, 39.95644578064385], - [7.874160902782947, 39.55384061139758], - [7.320511752401974, 37.837324852768496], - [5.209153948559947, 38.23794189547658], - [5.7110101707432115, 39.95590608087613], - [5.7109842887919795, 39.95644578064385], - ], - ], - ], - }, - cloudCoverPercentage: 36.66, - sensingTime: '2020-04-30T10:12:11.382Z', - area: 3.740229045e10, - sunElevation: 60.455486, - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [5.7109842887919795, 39.95644578064385], - [7.874160902782947, 39.55384061139758], - [7.320511752401974, 37.837324852768496], - [5.209153948559947, 38.23794189547658], - [5.7110101707432115, 39.95590608087613], - [5.7109842887919795, 39.95644578064385], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: { - cloudCoverPercent: 36.66, - sunElevation: 60.455486, - }, - links: [ - { - target: - 'http://landsat-pds.s3.amazonaws.com/c1/L8/194/033/LC08_L1GT_194033_20200430_20200430_01_RT/LC08_L1GT_194033_20200430_20200430_01_RT', - type: LinkType.AWS, - }, - { - target: - 'http://landsat-pds.s3.amazonaws.com/c1/L8/194/033/LC08_L1GT_194033_20200430_20200430_01_RT/LC08_L1GT_194033_20200430_20200430_01_RT_thumb_small.jpg', - type: 'preview', - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-04-30T10:12:11Z', hasMore = false, @@ -241,8 +96,7 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://services-uswest2.sentinel-hub.com/api/v1/catalog/collections/landsat-8-l1c/items/LC08_L1GT_194033_20200430_20200430_01_RT', + href: 'https://services-uswest2.sentinel-hub.com/api/v1/catalog/collections/landsat-8-l1c/items/LC08_L1GT_194033_20200430_20200430_01_RT', rel: 'self', type: 'application/json', }, @@ -258,8 +112,7 @@ export function constructFixtureFindTilesCatalog({ ], assets: { data: { - href: - 'http://landsat-pds.s3.amazonaws.com/c1/L8/194/033/LC08_L1GT_194033_20200430_20200430_01_RT/index.html', + href: 'http://landsat-pds.s3.amazonaws.com/c1/L8/194/033/LC08_L1GT_194033_20200430_20200430_01_RT/index.html', title: 's3', type: 'text/html', }, diff --git a/src/layer/__tests__/fixtures.MODISLayer.ts b/src/layer/__tests__/fixtures.MODISLayer.ts index 79104401..1f555b5c 100644 --- a/src/layer/__tests__/fixtures.MODISLayer.ts +++ b/src/layer/__tests__/fixtures.MODISLayer.ts @@ -2,112 +2,6 @@ import moment from 'moment'; import { LinkType, MODISLayer, BBox, CRS_EPSG4326 } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-30T12:00:00.000Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), -}): Record { - const layer = new MODISLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxCloudCoverage: null as any, - maxcount: 5, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'SI', - id: 2268454, - dataUri: 'MCD43A4.006/18/05/2020121/MCD43A4.A2020121.h18v05.006.2020130042701', - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [0.0, 30.000000000000014], - [0.0, 39.99999999999999], - [13.054072893322799, 39.99999999999999], - [11.54700538379253, 30.000000000000014], - [0.0, 30.000000000000014], - ], - ], - ], - }, - cloudCoverPercentage: 0.0, - sensingTime: '2020-04-30T12:00:00Z', - area: 0.0, - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [0.0, 30.000000000000014], - [0.0, 39.99999999999999], - [13.054072893322799, 39.99999999999999], - [11.54700538379253, 30.000000000000014], - [0.0, 30.000000000000014], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: {}, - links: [] as any, - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-04-30T12:00:00.000Z', hasMore = false, @@ -169,8 +63,7 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://services-uswest2.sentinel-hub.com/api/v1/catalog/collections/modis/items/MCD43A4.006/18/08/2020121/MCD43A4.A2020121.h18v08.006.2020130042056', + href: 'https://services-uswest2.sentinel-hub.com/api/v1/catalog/collections/modis/items/MCD43A4.006/18/08/2020121/MCD43A4.A2020121.h18v08.006.2020130042056', rel: 'self', type: 'application/json', }, diff --git a/src/layer/__tests__/fixtures.S1GRDAWSLayer.ts b/src/layer/__tests__/fixtures.S1GRDAWSLayer.ts index 14f49dbe..67da928f 100644 --- a/src/layer/__tests__/fixtures.S1GRDAWSLayer.ts +++ b/src/layer/__tests__/fixtures.S1GRDAWSLayer.ts @@ -11,230 +11,6 @@ import { OrbitDirection, } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-27T16:57:29Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - acquisitionMode = AcquisitionMode.IW, - polarization = Polarization.DV, - resolution = Resolution.HIGH, - orbitDirection = OrbitDirection.ASCENDING, -}): Record { - const layer = new S1GRDAWSEULayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - acquisitionMode: acquisitionMode, - polarization: polarization, - resolution: resolution, - orbitDirection: orbitDirection, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxCloudCoverage: null as any, - maxcount: 5, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - datasetParameters: { - acquisitionMode: acquisitionMode, - orbitDirection: orbitDirection, - polarization: polarization, - resolution: resolution, - type: 'S1GRD', - }, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S1', - id: 1418183, - originalId: 'S1A_IW_GRDH_1SDV_20200427T165729_20200427T165754_032316_03BD58_7BA8', - dataUri: - 's3://sentinel-s1-l1c/GRD/2020/4/27/IW/DV/S1A_IW_GRDH_1SDV_20200427T165729_20200427T165754_032316_03BD58_7BA8', - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [13.244148485697472, 40.727978937583835], - [13.665130955713822, 40.7887080080302], - [13.96883196519702, 40.83148641241739], - [14.427787275368955, 40.894514849407045], - [14.743235009183755, 40.93670012931676], - [15.041280914581412, 40.9757382388334], - [15.501180093324484, 41.034364584113554], - [15.802122514327156, 41.0716897173304], - [16.180695129845954, 41.117435028171066], - [16.138804800255237, 41.29699717296195], - [16.100155728943736, 41.47703317060471], - [16.06443532301079, 41.65741086345029], - [16.031720247363854, 41.83813747031465], - [15.990893023821858, 42.01791706562311], - [15.953915811908542, 42.198141717667795], - [15.874375511513158, 42.55793916374937], - [15.862263336458655, 42.61760785070261], - [15.475062481943887, 42.57224602159183], - [15.161388040260345, 42.53446837015743], - [14.848044918446945, 42.49582850512836], - [14.378651678478029, 42.43625369222487], - [14.068680537607882, 42.395794574064126], - [13.613875065133012, 42.33481090349227], - [13.306280454938168, 42.29248330605636], - [12.863290469314197, 42.229968128908546], - [12.886340007453795, 42.17140915132595], - [12.927219211307504, 41.99039759381334], - [12.970641849762204, 41.80975492934773], - [13.025015928403883, 41.630687345589905], - [13.059133307843451, 41.448720236051386], - [13.244148485697472, 40.727978937583835], - ], - ], - ], - }, - sensingTime: '2020-04-27T16:57:29Z', - rasterWidth: 26057, - rasterHeight: 16689, - polarization: 'DV', - resolution: 'HIGH', - orbitDirection: 'ASCENDING', - acquisitionMode: 'IW', - timeliness: 'NRT3h', - additionalData: { - pixelEnvelope: { - type: 'Polygon', - coordinates: [ - [ - [287.0, 0.0], - [287.0, 16689.0], - [25369.0, 16689.0], - [25369.0, 0.0], - [287.0, 0.0], - ], - ], - }, - latCoefficients: { - maxError: 7.904702186584473, - avgError: 6.42719324695726, - values: [ - -1.27721e7, -192442.625, 979014.75, 2013.244140625, 8288.5888671875, -24927.73828125, - -18.91802418231964, -28.011183738708496, -90.58196258544922, 210.29583740234375, - ], - }, - lonCoefficients: { - maxError: 122.6166763305664, - avgError: 28.628678227637373, - values: [ - -411181.0, -3723.796875, 12074.0, 25.157806396484375, 18.8876953125, -49.203125, - 0.0731879323720932, 0.3701629638671875, 0.17145538330078125, 0.4320831298828125, - ], - }, - }, - missionDatatakeId: 245080, - sliceNumber: 0, - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [13.244148485697472, 40.727978937583835], - [13.665130955713822, 40.7887080080302], - [13.96883196519702, 40.83148641241739], - [14.427787275368955, 40.894514849407045], - [14.743235009183755, 40.93670012931676], - [15.041280914581412, 40.9757382388334], - [15.501180093324484, 41.034364584113554], - [15.802122514327156, 41.0716897173304], - [16.180695129845954, 41.117435028171066], - [16.138804800255237, 41.29699717296195], - [16.100155728943736, 41.47703317060471], - [16.06443532301079, 41.65741086345029], - [16.031720247363854, 41.83813747031465], - [15.990893023821858, 42.01791706562311], - [15.953915811908542, 42.198141717667795], - [15.874375511513158, 42.55793916374937], - [15.862263336458655, 42.61760785070261], - [15.475062481943887, 42.57224602159183], - [15.161388040260345, 42.53446837015743], - [14.848044918446945, 42.49582850512836], - [14.378651678478029, 42.43625369222487], - [14.068680537607882, 42.395794574064126], - [13.613875065133012, 42.33481090349227], - [13.306280454938168, 42.29248330605636], - [12.863290469314197, 42.229968128908546], - [12.886340007453795, 42.17140915132595], - [12.927219211307504, 41.99039759381334], - [12.970641849762204, 41.80975492934773], - [13.025015928403883, 41.630687345589905], - [13.059133307843451, 41.448720236051386], - [13.244148485697472, 40.727978937583835], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: { - acquisitionMode: acquisitionMode, - polarization: polarization, - resolution: resolution, - orbitDirection: orbitDirection, - tileId: 1418183, - }, - links: [ - { - target: - 's3://sentinel-s1-l1c/GRD/2020/4/27/IW/DV/S1A_IW_GRDH_1SDV_20200427T165729_20200427T165754_032316_03BD58_7BA8', - type: LinkType.AWS, - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-04-27T16:57:29Z', hasMore = false, @@ -352,8 +128,7 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://services.sentinel-hub.com/api/v1/catalog/collections/sentinel-1-grd/items/S1A_IW_GRDH_1SDV_20200427T165729_20200427T165754_032316_03BD58_7BA8', + href: 'https://services.sentinel-hub.com/api/v1/catalog/collections/sentinel-1-grd/items/S1A_IW_GRDH_1SDV_20200427T165729_20200427T165754_032316_03BD58_7BA8', rel: 'self', type: 'application/json', }, @@ -364,8 +139,7 @@ export function constructFixtureFindTilesCatalog({ ], assets: { s3: { - href: - 's3://sentinel-s1-l1c/GRD/2020/4/27/IW/DV/S1A_IW_GRDH_1SDV_20200427T165729_20200427T165754_032316_03BD58_7BA8/', + href: 's3://sentinel-s1-l1c/GRD/2020/4/27/IW/DV/S1A_IW_GRDH_1SDV_20200427T165729_20200427T165754_032316_03BD58_7BA8/', title: 's3', type: 'inode/directory', }, diff --git a/src/layer/__tests__/fixtures.S2L1CCDASLayer.ts b/src/layer/__tests__/fixtures.S2L1CCDASLayer.ts index fb97f71f..761eae38 100644 --- a/src/layer/__tests__/fixtures.S2L1CCDASLayer.ts +++ b/src/layer/__tests__/fixtures.S2L1CCDASLayer.ts @@ -2,145 +2,6 @@ import moment from 'moment'; import { LinkType, BBox, CRS_EPSG4326, S2L1CCDASLayer } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-30T10:09:25Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - maxCloudCoverPercent = 20, -}): Record { - const layer = new S2L1CCDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - maxCloudCoverPercent: maxCloudCoverPercent, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxcount: 5, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : null, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S2', - id: 12649990, - originalId: 'S2B_OPER_MSI_L1C_TL_MPS__20200430T120945_A016450_T32TPL_N02.09', - dataUri: 's3://sentinel-s2-l1c/tiles/32/T/PL/2020/4/30/0', - dataIndexUri: 's3://sentinel-s2-l1c-index/tiles/32/T/PL/2020/4/30/0', - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.024700825907713, 41.534007903511316], - [10.721014448523226, 40.549938780257456], - [11.47718665727451, 40.53619478067447], - [11.514526068721082, 41.5243359587925], - [11.024700825907713, 41.534007903511316], - ], - ], - ], - }, - cloudCoverPercentage: 0.95, - sensingTime: '2020-04-30T10:09:25Z', - unitsPerPixel: 10.0, - area: 5.762832997652008e9, - hasLowQuantification: false, - dos1: { - B01: -1175, - B02: -759, - B03: -370, - B04: -158, - B05: -127, - B06: -97, - B07: -79, - B08: -36, - B09: 0, - B10: 0, - B11: 0, - B12: 0, - B8A: -38, - }, - productId: 'S2B_MSIL1C_20200430T100019_N0209_R122_T32TPL_20200430T120945', - copernicusHubProductId: '08103dec-7cbd-4080-b996-13a373b2b5b9', - l1cPath: 'tiles/32/T/PL/2020/4/30/0', - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.024700825907713, 41.534007903511316], - [10.721014448523226, 40.549938780257456], - [11.47718665727451, 40.53619478067447], - [11.514526068721082, 41.5243359587925], - [11.024700825907713, 41.534007903511316], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: { MGRSLocation: '32TPL', cloudCoverPercent: 0.95, tileId: 12649990 }, - links: [ - { - target: 's3://sentinel-s2-l1c/tiles/32/T/PL/2020/4/30/0', - type: LinkType.AWS, - }, - { - target: 'https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles/32/T/PL/2020/4/30/0/preview.jpg', - type: 'preview', - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-08-23T10:09:17Z', hasMore = false, @@ -233,8 +94,7 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://creodias.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l1c/items/S2A_MSIL1C_20200823T100031_N0209_R122_T32TQM_20200823T121427', + href: 'https://creodias.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l1c/items/S2A_MSIL1C_20200823T100031_N0209_R122_T32TQM_20200823T121427', rel: 'self', type: 'application/json', }, @@ -243,8 +103,7 @@ export function constructFixtureFindTilesCatalog({ rel: 'parent', }, { - href: - "https://scihub.copernicus.eu/dhus/odata/v1/Products('966aba13-b34f-4563-85ae-356503fb6c7b')/$value", + href: "https://scihub.copernicus.eu/dhus/odata/v1/Products('966aba13-b34f-4563-85ae-356503fb6c7b')/$value", rel: 'derived_from', title: 'scihub download', }, diff --git a/src/layer/__tests__/fixtures.S2L1CLayer.ts b/src/layer/__tests__/fixtures.S2L1CLayer.ts index f963500c..df223920 100644 --- a/src/layer/__tests__/fixtures.S2L1CLayer.ts +++ b/src/layer/__tests__/fixtures.S2L1CLayer.ts @@ -2,145 +2,6 @@ import moment from 'moment'; import { LinkType, S2L1CLayer, BBox, CRS_EPSG4326 } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-30T10:09:25Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - maxCloudCoverPercent = 20, -}): Record { - const layer = new S2L1CLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - maxCloudCoverPercent: maxCloudCoverPercent, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxcount: 5, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : null, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S2', - id: 12649990, - originalId: 'S2B_OPER_MSI_L1C_TL_MPS__20200430T120945_A016450_T32TPL_N02.09', - dataUri: 's3://sentinel-s2-l1c/tiles/32/T/PL/2020/4/30/0', - dataIndexUri: 's3://sentinel-s2-l1c-index/tiles/32/T/PL/2020/4/30/0', - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.024700825907713, 41.534007903511316], - [10.721014448523226, 40.549938780257456], - [11.47718665727451, 40.53619478067447], - [11.514526068721082, 41.5243359587925], - [11.024700825907713, 41.534007903511316], - ], - ], - ], - }, - cloudCoverPercentage: 0.95, - sensingTime: '2020-04-30T10:09:25Z', - unitsPerPixel: 10.0, - area: 5.762832997652008e9, - hasLowQuantification: false, - dos1: { - B01: -1175, - B02: -759, - B03: -370, - B04: -158, - B05: -127, - B06: -97, - B07: -79, - B08: -36, - B09: 0, - B10: 0, - B11: 0, - B12: 0, - B8A: -38, - }, - productId: 'S2B_MSIL1C_20200430T100019_N0209_R122_T32TPL_20200430T120945', - copernicusHubProductId: '08103dec-7cbd-4080-b996-13a373b2b5b9', - l1cPath: 'tiles/32/T/PL/2020/4/30/0', - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.024700825907713, 41.534007903511316], - [10.721014448523226, 40.549938780257456], - [11.47718665727451, 40.53619478067447], - [11.514526068721082, 41.5243359587925], - [11.024700825907713, 41.534007903511316], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: { MGRSLocation: '32TPL', cloudCoverPercent: 0.95, tileId: 12649990 }, - links: [ - { - target: 's3://sentinel-s2-l1c/tiles/32/T/PL/2020/4/30/0', - type: LinkType.AWS, - }, - { - target: 'https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles/32/T/PL/2020/4/30/0/preview.jpg', - type: 'preview', - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-08-23T10:09:17Z', hasMore = false, @@ -233,8 +94,7 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://services.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l1c/items/S2A_MSIL1C_20200823T100031_N0209_R122_T32TQM_20200823T121427', + href: 'https://services.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l1c/items/S2A_MSIL1C_20200823T100031_N0209_R122_T32TQM_20200823T121427', rel: 'self', type: 'application/json', }, @@ -243,8 +103,7 @@ export function constructFixtureFindTilesCatalog({ rel: 'parent', }, { - href: - "https://scihub.copernicus.eu/dhus/odata/v1/Products('966aba13-b34f-4563-85ae-356503fb6c7b')/$value", + href: "https://scihub.copernicus.eu/dhus/odata/v1/Products('966aba13-b34f-4563-85ae-356503fb6c7b')/$value", rel: 'derived_from', title: 'scihub download', }, diff --git a/src/layer/__tests__/fixtures.S2L2ACDASLayer.ts b/src/layer/__tests__/fixtures.S2L2ACDASLayer.ts index bd214cd8..f0076400 100644 --- a/src/layer/__tests__/fixtures.S2L2ACDASLayer.ts +++ b/src/layer/__tests__/fixtures.S2L2ACDASLayer.ts @@ -2,209 +2,6 @@ import moment from 'moment'; import { LinkType, BBox, CRS_EPSG4326, S2L2ACDASLayer } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-30T10:09:22Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - maxCloudCoverPercent = 20, -}): Record { - const layer = new S2L2ACDASLayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - maxCloudCoverPercent: maxCloudCoverPercent, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxcount: 5, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : null, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S2', - id: 9299470, - originalId: 'S2B_OPER_MSI_L2A_TL_MPS__20200430T131222_A016450_T32TQL_N02.14', - dataUri: 's3://sentinel-s2-l2a/tiles/32/T/QL/2020/4/30/0', - dataIndexUri: 's3://sentinel-s2-l2a-index/tiles/32/T/QL/2020/4/30/0', - tileEnvelope: { - type: 'Polygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::32632', - }, - }, - coordinates: [ - [ - [699960.0, 4600020.0], - [809760.0, 4600020.0], - [809760.0, 4490220.0], - [699960.0, 4490220.0], - [699960.0, 4600020.0], - ], - ], - }, - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.396715230122707, 41.52685304084347], - [11.361121157317946, 40.53862626065115], - [12.655543739210799, 40.504895198570296], - [12.71056219697988, 41.49193502979004], - [11.396715230122707, 41.52685304084347], - ], - ], - ], - }, - cloudCoverPercentage: 6.89, - sensingTime: '2020-04-30T10:09:22Z', - unitsPerPixel: 10.0, - area: 1.2055600804e10, - hasLowQuantification: false, - dos1: { - B01: -1172, - B02: -774, - B03: -383, - B04: -170, - B05: -132, - B06: -104, - B07: -87, - B08: -48, - B09: 0, - B10: 0, - B11: 0, - B12: 0, - B8A: -45, - }, - processingData: { - availableData: { - R10m: { - bandCombinations: ['AOT', 'B02', 'B03', 'B04', 'B08', 'WVP'], - }, - R20m: { - bandCombinations: [ - 'AOT', - 'B02', - 'B03', - 'B04', - 'B05', - 'B06', - 'B07', - 'B08', - 'B11', - 'B12', - 'B8A', - 'SCL', - 'WVP', - ], - }, - R60m: { - bandCombinations: [ - 'AOT', - 'B01', - 'B02', - 'B03', - 'B04', - 'B05', - 'B06', - 'B07', - 'B08', - 'B09', - 'B11', - 'B12', - 'B8A', - 'SCL', - 'WVP', - ], - }, - }, - url: 's3://sentinel-s2-l2a/tiles/32/T/QL/2020/4/30/0', - jp2Format: 'N0209', - }, - productId: 'S2B_MSIL2A_20200430T100019_N0214_R122_T32TQL_20200430T131222', - copernicusHubProductId: '6159c4bc-2871-470b-a13f-c45da49c75a2', - orbitId: 41129, - l1cPath: 'tiles/32/T/QL/2020/4/30/0', - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.396715230122707, 41.52685304084347], - [11.361121157317946, 40.53862626065115], - [12.655543739210799, 40.504895198570296], - [12.71056219697988, 41.49193502979004], - [11.396715230122707, 41.52685304084347], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: { MGRSLocation: '32TQL', cloudCoverPercent: 6.89, tileId: 9299470 }, - links: [ - { - target: 's3://sentinel-s2-l2a/tiles/32/T/QL/2020/4/30/0', - type: LinkType.AWS, - }, - { - target: 'https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles/32/T/QL/2020/4/30/0/preview.jpg', - type: LinkType.PREVIEW, - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-04-30T10:09:22Z', hasMore = false, @@ -296,8 +93,7 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://creodias.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l2a/items/S2B_MSIL2A_20200430T100019_N0214_R122_T33TTF_20200430T131222', + href: 'https://creodias.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l2a/items/S2B_MSIL2A_20200430T100019_N0214_R122_T33TTF_20200430T131222', rel: 'self', type: 'application/json', }, @@ -306,8 +102,7 @@ export function constructFixtureFindTilesCatalog({ rel: 'parent', }, { - href: - "https://scihub.copernicus.eu/dhus/odata/v1/Products('72a034ef-cb01-4081-821d-c493ac3fdb0b')/$value", + href: "https://scihub.copernicus.eu/dhus/odata/v1/Products('72a034ef-cb01-4081-821d-c493ac3fdb0b')/$value", rel: 'derived_from', title: 'scihub download', }, diff --git a/src/layer/__tests__/fixtures.S2L2ALayer.ts b/src/layer/__tests__/fixtures.S2L2ALayer.ts index 0c842d16..d6a7c916 100644 --- a/src/layer/__tests__/fixtures.S2L2ALayer.ts +++ b/src/layer/__tests__/fixtures.S2L2ALayer.ts @@ -2,209 +2,6 @@ import moment from 'moment'; import { LinkType, S2L2ALayer, BBox, CRS_EPSG4326 } from '../../index'; -export function constructFixtureFindTilesSearchIndex({ - sensingTime = '2020-04-30T10:09:22Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - maxCloudCoverPercent = 20, -}): Record { - const layer = new S2L2ALayer({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - maxCloudCoverPercent: maxCloudCoverPercent, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxcount: 5, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : null, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S2', - id: 9299470, - originalId: 'S2B_OPER_MSI_L2A_TL_MPS__20200430T131222_A016450_T32TQL_N02.14', - dataUri: 's3://sentinel-s2-l2a/tiles/32/T/QL/2020/4/30/0', - dataIndexUri: 's3://sentinel-s2-l2a-index/tiles/32/T/QL/2020/4/30/0', - tileEnvelope: { - type: 'Polygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::32632', - }, - }, - coordinates: [ - [ - [699960.0, 4600020.0], - [809760.0, 4600020.0], - [809760.0, 4490220.0], - [699960.0, 4490220.0], - [699960.0, 4600020.0], - ], - ], - }, - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.396715230122707, 41.52685304084347], - [11.361121157317946, 40.53862626065115], - [12.655543739210799, 40.504895198570296], - [12.71056219697988, 41.49193502979004], - [11.396715230122707, 41.52685304084347], - ], - ], - ], - }, - cloudCoverPercentage: 6.89, - sensingTime: '2020-04-30T10:09:22Z', - unitsPerPixel: 10.0, - area: 1.2055600804e10, - hasLowQuantification: false, - dos1: { - B01: -1172, - B02: -774, - B03: -383, - B04: -170, - B05: -132, - B06: -104, - B07: -87, - B08: -48, - B09: 0, - B10: 0, - B11: 0, - B12: 0, - B8A: -45, - }, - processingData: { - availableData: { - R10m: { - bandCombinations: ['AOT', 'B02', 'B03', 'B04', 'B08', 'WVP'], - }, - R20m: { - bandCombinations: [ - 'AOT', - 'B02', - 'B03', - 'B04', - 'B05', - 'B06', - 'B07', - 'B08', - 'B11', - 'B12', - 'B8A', - 'SCL', - 'WVP', - ], - }, - R60m: { - bandCombinations: [ - 'AOT', - 'B01', - 'B02', - 'B03', - 'B04', - 'B05', - 'B06', - 'B07', - 'B08', - 'B09', - 'B11', - 'B12', - 'B8A', - 'SCL', - 'WVP', - ], - }, - }, - url: 's3://sentinel-s2-l2a/tiles/32/T/QL/2020/4/30/0', - jp2Format: 'N0209', - }, - productId: 'S2B_MSIL2A_20200430T100019_N0214_R122_T32TQL_20200430T131222', - copernicusHubProductId: '6159c4bc-2871-470b-a13f-c45da49c75a2', - orbitId: 41129, - l1cPath: 'tiles/32/T/QL/2020/4/30/0', - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [11.396715230122707, 41.52685304084347], - [11.361121157317946, 40.53862626065115], - [12.655543739210799, 40.504895198570296], - [12.71056219697988, 41.49193502979004], - [11.396715230122707, 41.52685304084347], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: { MGRSLocation: '32TQL', cloudCoverPercent: 6.89, tileId: 9299470 }, - links: [ - { - target: 's3://sentinel-s2-l2a/tiles/32/T/QL/2020/4/30/0', - type: LinkType.AWS, - }, - { - target: 'https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles/32/T/QL/2020/4/30/0/preview.jpg', - type: LinkType.PREVIEW, - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog({ sensingTime = '2020-04-30T10:09:22Z', hasMore = false, @@ -296,8 +93,7 @@ export function constructFixtureFindTilesCatalog({ }, links: [ { - href: - 'https://services.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l2a/items/S2B_MSIL2A_20200430T100019_N0214_R122_T33TTF_20200430T131222', + href: 'https://services.sentinel-hub.com/api/v1/catalog/collections/sentinel-2-l2a/items/S2B_MSIL2A_20200430T100019_N0214_R122_T33TTF_20200430T131222', rel: 'self', type: 'application/json', }, @@ -306,8 +102,7 @@ export function constructFixtureFindTilesCatalog({ rel: 'parent', }, { - href: - "https://scihub.copernicus.eu/dhus/odata/v1/Products('72a034ef-cb01-4081-821d-c493ac3fdb0b')/$value", + href: "https://scihub.copernicus.eu/dhus/odata/v1/Products('72a034ef-cb01-4081-821d-c493ac3fdb0b')/$value", rel: 'derived_from', title: 'scihub download', }, diff --git a/src/layer/__tests__/fixtures.S3OLCILayer.ts b/src/layer/__tests__/fixtures.S3OLCILayer.ts index 79fa65f0..6768cb84 100644 --- a/src/layer/__tests__/fixtures.S3OLCILayer.ts +++ b/src/layer/__tests__/fixtures.S3OLCILayer.ts @@ -3,219 +3,6 @@ import moment from 'moment'; import { LinkType, BBox, CRS_EPSG4326 } from '../../index'; -export function constructFixtureFindTilesSearchIndex( - layerClass: typeof AbstractSentinelHubV3Layer, - { - sensingTime = '2020-04-30T09:58:12Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - }, -): Record { - const layer = new layerClass({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - }); - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxCloudCoverage: null as any, - maxcount: 5, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S3', - id: 1248462, - originalId: - 'EODATA/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', - dataUri: - 'http://data.cloudferro.com/EODATA/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-2.097644, 52.417860999999995], - [-2.172493, 51.979997999999995], - [-2.183793, 51.978117], - [-2.561625, 49.603713], - [-2.572228, 49.601855], - [-3.073191, 46.495608], - [-3.0831899999999997, 46.493795999999996], - [-3.504053, 43.885569], - [-3.513627, 43.883797], - [-3.607164, 43.27735], - [-3.6074219999999997, 43.154911999999996], - [-3.6361869999999996, 43.053247999999996], - [-3.817099, 41.927941], - [-1.938081, 41.73704], - [-0.057815, 41.51406], - [1.7088379999999999, 41.275048], - [3.7856549999999998, 40.961298], - [5.530151, 40.664483], - [7.28933, 40.330644], - [9.088379, 39.959548999999996], - [10.778061, 39.583197], - [11.383687, 41.110478], - [12.133628999999999, 42.931393], - [12.531452, 43.846731999999996], - [13.640557999999999, 46.288629], - [14.369261999999999, 47.770258], - [15.192131, 49.350468], - [15.507169, 49.926114999999996], - [13.496939999999999, 50.363264], - [11.372238, 50.781327999999995], - [9.271621999999999, 51.15164], - [7.152584999999999, 51.476853], - [4.709772, 51.797017], - [2.512508, 52.042319], - [0.224742, 52.251915999999994], - [-2.097644, 52.417860999999995], - ], - ], - ], - }, - sensingTime: '2020-04-30T09:58:12Z', - productName: - 'S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', - cycle: 57, - relativeOrbit: 350, - frame: 2160, - timeliness: 'NR', - additionalData: { - pixelEnvelope: { - type: 'Polygon', - coordinates: [ - [ - [145.0, 0.0], - [145.0, 4090.0], - [4821.0, 4090.0], - [4821.0, 0.0], - [145.0, 0.0], - ], - ], - }, - errorEstimates: [10.12398400734969, 1.543008548245325, 0.606379343100804, 0.3931914366197954], - xCoefficients: [ - 4596.2055587768555, 430.72991293668747, -74.63191604614258, -0.623042234336026, - -1.3956050127744675, -0.42653124034404755, -0.006992724314841325, 0.007913307377748424, - -0.039211956842336804, 0.008093118842225522, - ], - yCoefficients: [ - 19320.13011932373, -95.66507685184479, -358.415894985199, -1.6208207387244329, 0.7785560581833124, - -0.17121314257383347, -0.0013507152152669732, 0.0025232208136003464, 0.009004542836919427, - -8.248505182564259e-4, - ], - }, - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-2.097644, 52.417860999999995], - [-2.172493, 51.979997999999995], - [-2.183793, 51.978117], - [-2.561625, 49.603713], - [-2.572228, 49.601855], - [-3.073191, 46.495608], - [-3.0831899999999997, 46.493795999999996], - [-3.504053, 43.885569], - [-3.513627, 43.883797], - [-3.607164, 43.27735], - [-3.6074219999999997, 43.154911999999996], - [-3.6361869999999996, 43.053247999999996], - [-3.817099, 41.927941], - [-1.938081, 41.73704], - [-0.057815, 41.51406], - [1.7088379999999999, 41.275048], - [3.7856549999999998, 40.961298], - [5.530151, 40.664483], - [7.28933, 40.330644], - [9.088379, 39.959548999999996], - [10.778061, 39.583197], - [11.383687, 41.110478], - [12.133628999999999, 42.931393], - [12.531452, 43.846731999999996], - [13.640557999999999, 46.288629], - [14.369261999999999, 47.770258], - [15.192131, 49.350468], - [15.507169, 49.926114999999996], - [13.496939999999999, 50.363264], - [11.372238, 50.781327999999995], - [9.271621999999999, 51.15164], - [7.152584999999999, 51.476853], - [4.709772, 51.797017], - [2.512508, 52.042319], - [0.224742, 52.251915999999994], - [-2.097644, 52.417860999999995], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: {}, - links: [ - { - target: - '/eodata/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', - type: LinkType.CREODIAS, - }, - { - target: - 'https://finder.creodias.eu/files/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002-ql.jpg', - type: 'preview', - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog( layerClass: typeof AbstractSentinelHubV3Layer, { @@ -243,8 +30,7 @@ export function constructFixtureFindTilesCatalog( features: [ { stac_version: '0.9.0', - id: - 'S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', + id: 'S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', geometry: { type: 'MultiPolygon', crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:OGC::CRS84' } }, @@ -336,14 +122,12 @@ export function constructFixtureFindTilesCatalog( ], assets: { thumbnail: { - href: - 'https://finder.creodias.eu/files/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002-ql.jpg', + href: 'https://finder.creodias.eu/files/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002-ql.jpg', title: 'thumbnail', type: 'image/jpeg', }, data: { - href: - 's3://DIAS/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', + href: 's3://DIAS/Sentinel-3/OLCI/OL_1_EFR/2020/04/30/S3A_OL_1_EFR____20200430T095812_20200430T100112_20200430T114934_0180_057_350_2160_LN1_O_NR_002.SEN3', title: 's3', type: 'inode/directory', }, diff --git a/src/layer/__tests__/fixtures.S3SLTRLayer.ts b/src/layer/__tests__/fixtures.S3SLTRLayer.ts index aa77bc52..3e6d8125 100644 --- a/src/layer/__tests__/fixtures.S3SLTRLayer.ts +++ b/src/layer/__tests__/fixtures.S3SLTRLayer.ts @@ -3,257 +3,6 @@ import moment from 'moment'; import { LinkType, BBox, CRS_EPSG4326 } from '../../index'; -export function constructFixtureFindTilesSearchIndex( - layerClass: typeof AbstractSentinelHubV3WithCCLayer, - { - sensingTime = '2020-04-30T09:58:11.882Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - maxCloudCoverPercent = 20, - }, -): Record { - const layer = new layerClass({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - maxCloudCoverPercent: maxCloudCoverPercent, - }); - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - datasetParameters: { - orbitDirection: 'DESCENDING', - type: 'S3SLSTR', - view: 'NADIR', - }, - maxcount: 5, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : null, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S3SLSTR', - id: 1921861, - originalId: - 'EODATA/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T095812_20200430T100112_20200430T115741_0180_057_350_2160_LN2_O_NR_004.SEN3', - dataUri: - 'http://data.cloudferro.com/EODATA/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T095812_20200430T100112_20200430T115741_0180_057_350_2160_LN2_O_NR_004.SEN3', - dataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-2.468773967874798, 52.46678839557069], - [-4.1413650701609726, 41.9345339746374], - [0.059320398363811325, 41.476215786822635], - [4.362892567760172, 40.838592561744825], - [8.39370764618624, 40.08134499195091], - [12.536144992401084, 39.135714708889715], - [14.988578839454325, 44.60573941226634], - [16.248574468491988, 47.064395459565326], - [17.592085799369745, 49.45365353239512], - [12.698508289476116, 50.55155487771758], - [7.868328680774166, 51.39458645753124], - [2.65032535072137, 52.05548315635147], - [-2.468773967874798, 52.46678839557069], - ], - ], - ], - }, - cloudCoverPercentage: 70.80023956298828, - sensingTime: '2020-04-30T09:58:11.882Z', - productName: - 'S3A_SL_1_RBT____20200430T095812_20200430T100112_20200430T115741_0180_057_350_2160_LN2_O_NR_004.SEN3', - obliqueDataGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [5.597816666651402, 51.7136045420516], - [4.032431232042233, 46.733169493587944], - [2.4754737665950723, 41.14477319059084], - [7.12255172282423, 40.34188599414061], - [11.725934173318402, 39.339246555720706], - [14.111334729011466, 44.82103189709212], - [15.336136976006143, 47.288448224561805], - [16.641395282132677, 49.687417491757934], - [11.18078257981423, 50.841386540037426], - [5.597816666651402, 51.7136045420516], - ], - ], - ], - }, - cycle: 57, - relativeOrbit: 350, - frame: 2160, - timeliness: 'NR', - additionalData: { - pixelEnvelope: { - type: 'Polygon', - coordinates: [ - [ - [78.0, 0.0], - [78.0, 2400.0], - [2959.0, 2400.0], - [2959.0, 0.0], - [78.0, 0.0], - ], - ], - }, - errorEstimates: [0.13876327902880803, 0.6201986401138129, 0.02667770719220408, 0.09159002148806844], - pixelEnvelopeOblique: { - type: 'Polygon', - coordinates: [ - [ - [100.0, 0.0], - [100.0, 2399.0], - [1716.0, 2399.0], - [1716.0, 0.0], - [100.0, 0.0], - ], - ], - }, - offsets: { - tiePoint: { - start: 14458, - track: 64, - }, - nadir1km: { - start: 14458, - track: 998, - }, - oblique1km: { - start: 14458, - track: 450, - }, - nadir500m: { - start: 28916, - track: 1996, - }, - oblique500m: { - start: 28916, - track: 900, - }, - nadirF1: { - start: 14458, - track: 998, - }, - obliqueF1: { - start: 14458, - track: 450, - }, - }, - solarIrradiance: [ - 1810.5114211358484, 1498.1347247211947, 942.9690427820371, 360.4406990393776, 241.74631419529769, - 76.30583273560039, - ], - xCoefficients: [ - 2641.2015953063965, 226.60192400217056, -46.84138464927673, -0.2546079733874649, - -0.5248879659920931, -0.10691561549901962, -0.0038675773961358573, 0.002465897716319887, - -0.023322941473452374, 0.0035957663785666227, - ], - yCoefficients: [ - 11427.666122436523, -54.66822412610054, -216.39408373832703, -0.9036153573542833, - 0.38148084841668606, 0.03461052104830742, 6.809589317526843e-4, 1.050975697580725e-7, - 0.006229528837138787, -0.001475233817473054, - ], - }, - orbitDirection: 'DESCENDING', - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-30T09:18:38.148Z;1924015,48.99588394165039', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-2.468773967874798, 52.46678839557069], - [-4.1413650701609726, 41.9345339746374], - [0.059320398363811325, 41.476215786822635], - [4.362892567760172, 40.838592561744825], - [8.39370764618624, 40.08134499195091], - [12.536144992401084, 39.135714708889715], - [14.988578839454325, 44.60573941226634], - [16.248574468491988, 47.064395459565326], - [17.592085799369745, 49.45365353239512], - [12.698508289476116, 50.55155487771758], - [7.868328680774166, 51.39458645753124], - [2.65032535072137, 52.05548315635147], - [-2.468773967874798, 52.46678839557069], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: { - cloudCoverPercent: 70.80023956298828, - orbitDirection: 'DESCENDING', - }, - links: [ - { - target: - '/eodata/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T095812_20200430T100112_20200430T115741_0180_057_350_2160_LN2_O_NR_004.SEN3', - - type: LinkType.CREODIAS, - }, - { - target: - 'https://finder.creodias.eu/files/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T095812_20200430T100112_20200430T115741_0180_057_350_2160_LN2_O_NR_004.SEN3/S3A_SL_1_RBT____20200430T095812_20200430T100112_20200430T115741_0180_057_350_2160_LN2_O_NR_004-ql.jpg', - type: 'preview', - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog( layerClass: typeof AbstractSentinelHubV3WithCCLayer, { @@ -288,8 +37,7 @@ export function constructFixtureFindTilesCatalog( features: [ { stac_version: '0.9.0', - id: - 'S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004.SEN3', + id: 'S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004.SEN3', geometry: { type: 'MultiPolygon', crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:OGC::CRS84' } }, @@ -345,14 +93,12 @@ export function constructFixtureFindTilesCatalog( ], assets: { thumbnail: { - href: - 'https://finder.creodias.eu/files/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004.SEN3/S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004-ql.jpg', + href: 'https://finder.creodias.eu/files/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004.SEN3/S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004-ql.jpg', title: 'thumbnail', type: 'image/jpeg', }, data: { - href: - 's3://EODATA/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004.SEN3', + href: 's3://EODATA/Sentinel-3/SLSTR/SL_1_RBT/2020/04/30/S3A_SL_1_RBT____20200430T211807_20200430T212107_20200430T233757_0179_057_357_0540_LN2_O_NR_004.SEN3', title: 's3', type: 'inode/directory', }, diff --git a/src/layer/__tests__/fixtures.S5PL2Layer.ts b/src/layer/__tests__/fixtures.S5PL2Layer.ts index 7b0169ea..1c2bfbf6 100644 --- a/src/layer/__tests__/fixtures.S5PL2Layer.ts +++ b/src/layer/__tests__/fixtures.S5PL2Layer.ts @@ -3,194 +3,6 @@ import moment from 'moment'; import { LinkType, S5PL2Layer, BBox, CRS_EPSG4326 } from '../../index'; import { ProductType } from '../S5PL2Layer'; -export function constructFixtureFindTilesSearchIndex( - layerClass: typeof S5PL2Layer, - { - sensingTime = '2020-04-30T12:59:48Z', - hasMore = true, - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 0)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - productType = ProductType.SO2, - }, -): Record { - const layer = new layerClass({ - instanceId: 'INSTANCE_ID', - layerId: 'LAYER_ID', - productType: productType, - }); - - const expectedRequest = { - clipping: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxcount: 5, - maxCloudCoverage: 1, - timeFrom: fromTime.toISOString(), - timeTo: toTime.toISOString(), - offset: 0, - datasetParameters: { type: 'S5PL2', productType: productType }, - }; - - const mockedResponse = { - tiles: [ - { - type: 'S5P', - id: 4776187, - originalId: - 'EODATA/Sentinel-5P/TROPOMI/L2__SO2___/2020/04/30/S5P_NRTI_L2__SO2____20200430T125948_20200430T130448_13196_01_010108_20200430T134425/S5P_NRTI_L2__SO2____20200430T125948_20200430T130448_13196_01_010108_20200430T134425.nc', - dataUri: - 'http://data.cloudferro.com/EODATA/Sentinel-5P/TROPOMI/L2__SO2___/2020/04/30/S5P_NRTI_L2__SO2____20200430T125948_20200430T130448_13196_01_010108_20200430T134425/S5P_NRTI_L2__SO2____20200430T125948_20200430T130448_13196_01_010108_20200430T134425.nc', - sensingTime: '2020-04-30T12:59:48Z', - productName: 'S5P_NRTI_L2__SO2____20200430T125948_20200430T130448_13196_01_010108_20200430T134425.nc', - tileDrawRegionGeometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-12.876374192400508, 32.138784748245996], - [-9.050998815287903, 33.92122264449279], - [-5.5759570140793615, 35.31781658143877], - [-2.3514207072764193, 36.36568597148261], - [0.8233509202245249, 37.13241728752964], - [4.105998947252946, 37.65916973772451], - [7.5952806048754, 37.957712805035015], - [11.49789946309938, 38.0486375934873], - [16.019676363525456, 37.930654414117136], - [15.213178714221847, 47.17286426154503], - [14.91690018023924, 55.12711145454758], - [9.008341253486973, 55.45662932464365], - [3.630199287989029, 55.458880993156015], - [-1.3542448962729945, 55.142769050138284], - [-6.00826126987976, 54.49785799948327], - [-10.358929485901971, 53.532801978865116], - [-14.601394105378953, 52.2070885120343], - [-18.944144346210685, 50.44416074073832], - [-23.33600548578315, 48.262909246838596], - [-20.448516504344223, 44.77324353095672], - [-17.77978488965107, 40.97798792495399], - [-15.24324507465063, 36.7474414180249], - [-12.876374192400508, 32.138784748245996], - ], - ], - ], - }, - timeliness: 'NRTI', - productType: productType, - additionalData: { - pixelEnvelope: { - type: 'Polygon', - coordinates: [ - [ - [0.0, 0.0], - [0.0, 357.0], - [450.0, 357.0], - [450.0, 0.0], - [0.0, 0.0], - ], - ], - }, - latCoefficients: [ - -128.7241382598877, -6.670354038476944, 14.10818612575531, 2.272536104544997, 1.995137795805931, - -0.25244469568133354, -0.06694354171554551, -0.0860297123726923, -0.042259250330971554, - 0.004244219802785665, -9.098381532357536e-5, 9.618848745063246e-4, 7.369346951122679e-4, - 2.3342767030953837e-4, -2.9172913855290972e-5, - ], - lonCoefficients: [ - -666.6268177032471, -6.694219172000885, 16.76114547252655, 0.07781993190292269, - -0.07211521919816732, 0.04499359801411629, 0.004179233268814642, 0.007114302828995278, - 0.005323755729477853, -3.749761963263154e-4, -6.959126637262614e-5, -9.75983120490298e-5, - -1.0776068401696648e-4, -4.205959567116224e-5, 2.518156861697207e-6, - ], - errorEstimates: [20.664674256106764, 1.4269664134399136, 4.231102505172432, 0.13135785058428665], - }, - orbitId: 13196, - sensingEnd: '2020-04-30T13:04:48Z', - processorVersion: 10108, - }, - ], - hasMore: hasMore, - maxOrderKey: '2020-04-12T09:59:24Z;4.997170846080444E9;12425636;13.99', - }; - const expectedResultTiles = [ - { - geometry: { - type: 'MultiPolygon', - crs: { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::4326', - }, - }, - coordinates: [ - [ - [ - [-12.876374192400508, 32.138784748245996], - [-9.050998815287903, 33.92122264449279], - [-5.5759570140793615, 35.31781658143877], - [-2.3514207072764193, 36.36568597148261], - [0.8233509202245249, 37.13241728752964], - [4.105998947252946, 37.65916973772451], - [7.5952806048754, 37.957712805035015], - [11.49789946309938, 38.0486375934873], - [16.019676363525456, 37.930654414117136], - [15.213178714221847, 47.17286426154503], - [14.91690018023924, 55.12711145454758], - [9.008341253486973, 55.45662932464365], - [3.630199287989029, 55.458880993156015], - [-1.3542448962729945, 55.142769050138284], - [-6.00826126987976, 54.49785799948327], - [-10.358929485901971, 53.532801978865116], - [-14.601394105378953, 52.2070885120343], - [-18.944144346210685, 50.44416074073832], - [-23.33600548578315, 48.262909246838596], - [-20.448516504344223, 44.77324353095672], - [-17.77978488965107, 40.97798792495399], - [-15.24324507465063, 36.7474414180249], - [-12.876374192400508, 32.138784748245996], - ], - ], - ], - }, - sensingTime: moment.utc(sensingTime).toDate(), - meta: {}, - links: [ - { - target: - '/eodata/Sentinel-5P/TROPOMI/L2__SO2___/2020/04/30/S5P_NRTI_L2__SO2____20200430T125948_20200430T130448_13196_01_010108_20200430T134425/S5P_NRTI_L2__SO2____20200430T125948_20200430T130448_13196_01_010108_20200430T134425.nc', - type: LinkType.CREODIAS, - }, - ], - }, - ]; - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResultTiles: expectedResultTiles, - expectedResultHasMore: hasMore, - }; -} - export function constructFixtureFindTilesCatalog( layerClass: typeof S5PL2Layer, { @@ -286,8 +98,7 @@ export function constructFixtureFindTilesCatalog( ], assets: { data: { - href: - 's3://EODATA/Sentinel-5P/TROPOMI/L2__SO2___/2020/04/30/S5P_OFFL_L2__SO2____20200430T120356_20200430T134526_13196_01_010108_20200502T144627/S5P_OFFL_L2__SO2____20200430T120356_20200430T134526_13196_01_010108_20200502T144627.nc', + href: 's3://EODATA/Sentinel-5P/TROPOMI/L2__SO2___/2020/04/30/S5P_OFFL_L2__SO2____20200430T120356_20200430T134526_13196_01_010108_20200502T144627/S5P_OFFL_L2__SO2____20200430T120356_20200430T134526_13196_01_010108_20200502T144627.nc', title: 's3', type: 'inode/directory', }, diff --git a/src/layer/__tests__/fixtures.findDatesUTC.ts b/src/layer/__tests__/fixtures.findDatesUTC.ts index d2f9a215..8e7dfff6 100644 --- a/src/layer/__tests__/fixtures.findDatesUTC.ts +++ b/src/layer/__tests__/fixtures.findDatesUTC.ts @@ -7,149 +7,12 @@ import { Polarization, Resolution, S1GRDAWSEULayer, - S3SLSTRLayer, S5PL2Layer, } from '../../index'; import { AbstractSentinelHubV3Layer } from '../AbstractSentinelHubV3Layer'; import { AbstractSentinelHubV3WithCCLayer } from '../AbstractSentinelHubV3WithCCLayer'; import { CATALOG_SEARCH_MAX_LIMIT, BYOCSubTypes } from '../const'; -export function constructFixtureFindDatesUTCSearchIndex( - layer: AbstractSentinelHubV3Layer, - { - fromTime = new Date(Date.UTC(2020, 4 - 1, 1, 0, 0, 0, 0)), - toTime = new Date(Date.UTC(2020, 5 - 1, 1, 23, 59, 59, 999)), - bbox = new BBox(CRS_EPSG4326, 19, 20, 20, 21), - maxCloudCoverPercent = null as number, - productType = null as string, - collectionId = 'mockCollectionId', - acquisitionMode = null as AcquisitionMode, - polarization = null as Polarization.DV, - resolution = null as Resolution.HIGH, - orbitDirection = null as OrbitDirection.ASCENDING, - }, -): Record { - const expectedRequest: Record = { - queryArea: { - type: 'Polygon', - crs: { type: 'name', properties: { name: 'urn:ogc:def:crs:EPSG::4326' } }, - coordinates: [ - [ - [bbox.minX, bbox.minY], - [bbox.maxX, bbox.minY], - [bbox.maxX, bbox.maxY], - [bbox.minX, bbox.maxY], - [bbox.minX, bbox.minY], - ], - ], - }, - maxCloudCoverage: maxCloudCoverPercent !== null ? maxCloudCoverPercent / 100 : 1, - from: fromTime.toISOString(), - to: toTime.toISOString(), - }; - - if (layer instanceof S1GRDAWSEULayer) { - expectedRequest.datasetParameters = { type: 'S1GRD' }; - } - if (layer instanceof S1GRDAWSEULayer && acquisitionMode) { - expectedRequest.datasetParameters['acquisitionMode'] = acquisitionMode; - } - - if (layer instanceof S1GRDAWSEULayer && orbitDirection) { - expectedRequest.datasetParameters['orbitDirection'] = orbitDirection; - } - - if (layer instanceof S1GRDAWSEULayer && polarization) { - expectedRequest.datasetParameters['polarization'] = polarization; - } - - if (layer instanceof S1GRDAWSEULayer && resolution) { - expectedRequest.datasetParameters['resolution'] = resolution; - } - - if (layer instanceof S3SLSTRLayer) { - expectedRequest.datasetParameters = { - orbitDirection: 'DESCENDING', - type: 'S3SLSTR', - view: 'NADIR', - }; - } - - if (layer instanceof S5PL2Layer) { - if (productType) { - expectedRequest.datasetParameters = { - productType: productType, - type: 'S5PL2', - }; - } else { - expectedRequest.datasetParameters = { - type: 'S5PL2', - }; - } - } - - if (layer instanceof BYOCLayer && collectionId) { - expectedRequest.datasetParameters = { - collectionId: collectionId, - type: 'BYOC', - }; - } - /* - if (layer instanceof BYOCLayer && locationId) { - expectedRequest.datasetParameters = { - locationId: locationId, - }; - } -*/ - if ( - !(layer instanceof AbstractSentinelHubV3WithCCLayer || layer instanceof S5PL2Layer) && - (maxCloudCoverPercent === null || maxCloudCoverPercent === undefined) - ) { - delete expectedRequest['maxCloudCoverage']; - } - - const mockedResponse = [ - '2020-04-30', - '2020-04-28', - '2020-04-26', - '2020-04-23', - '2020-04-21', - '2020-04-18', - '2020-04-16', - '2020-04-13', - '2020-04-11', - '2020-04-08', - '2020-04-06', - '2020-04-03', - '2020-04-01', - ]; - - const expectedResult = [ - '2020-04-30', - '2020-04-28', - '2020-04-26', - '2020-04-23', - '2020-04-21', - '2020-04-18', - '2020-04-16', - '2020-04-13', - '2020-04-11', - '2020-04-08', - '2020-04-06', - '2020-04-03', - '2020-04-01', - ].map((d) => new Date(d)); - return { - fromTime: fromTime, - toTime: toTime, - bbox: bbox, - layer: layer, - mockedResponse: mockedResponse, - expectedRequest: expectedRequest, - expectedResult: expectedResult, - }; -} - export function constructFixtureFindDatesUTCCatalog( layer: AbstractSentinelHubV3Layer, { From 6ae65474d25badc07aaec0aea4e8f698a9dcf689 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 16:22:23 +0200 Subject: [PATCH 08/11] remove searchIndexUrl and findDatesUTCUrl from dataset.ts --- src/layer/dataset.ts | 76 -------------------------------------------- 1 file changed, 76 deletions(-) diff --git a/src/layer/dataset.ts b/src/layer/dataset.ts index d874c4cb..ea6ca676 100644 --- a/src/layer/dataset.ts +++ b/src/layer/dataset.ts @@ -5,8 +5,6 @@ export type Dataset = { shProcessingApiDatasourceAbbreviation: string; datasetParametersType: string | null; shServiceHostname: string; - searchIndexUrl: string; - findDatesUTCUrl: string; orbitTimeMinutes: number; minDate: Date | null; maxDate: Date | null; @@ -20,8 +18,6 @@ export const DATASET_AWSEU_S1GRD: Dataset = { shProcessingApiDatasourceAbbreviation: 'S1GRD', datasetParametersType: 'S1GRD', shServiceHostname: 'https://services.sentinel-hub.com/', - searchIndexUrl: 'https://services.sentinel-hub.com/index/v3/collections/S1GRD/searchIndex', - findDatesUTCUrl: 'https://services.sentinel-hub.com/index/v3/collections/S1GRD/findAvailableData', orbitTimeMinutes: 49.3, minDate: new Date(Date.UTC(2014, 10 - 1, 3, 0, 47, 14)), // 2014-10-03T00:47:14Z maxDate: null, @@ -35,8 +31,6 @@ export const DATASET_CDAS_S1GRD: Dataset = { shProcessingApiDatasourceAbbreviation: 'S1GRD', datasetParametersType: 'S1GRD', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S1GRD/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S1GRD/findAvailableData', orbitTimeMinutes: 49.3, minDate: new Date(Date.UTC(2014, 10 - 1, 3, 0, 47, 14)), // 2014-10-03T00:47:14Z maxDate: null, @@ -50,8 +44,6 @@ export const DATASET_CDAS_OTC_S1GRD: Dataset = { shProcessingApiDatasourceAbbreviation: 'S1GRD', datasetParametersType: 'S1GRD', shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S1GRD/searchIndex', - findDatesUTCUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S1GRD/findAvailableData', orbitTimeMinutes: 49.3, minDate: new Date(Date.UTC(2014, 10 - 1, 3, 0, 47, 14)), // 2014-10-03T00:47:14Z maxDate: null, @@ -65,8 +57,6 @@ export const DATASET_S2L2A: Dataset = { shProcessingApiDatasourceAbbreviation: 'S2L2A', datasetParametersType: 'S2', shServiceHostname: 'https://services.sentinel-hub.com/', - searchIndexUrl: 'https://services.sentinel-hub.com/index/v3/collections/S2L2A/searchIndex', - findDatesUTCUrl: 'https://services.sentinel-hub.com/index/v3/collections/S2L2A/findAvailableData', orbitTimeMinutes: 50.3, minDate: new Date(Date.UTC(2016, 10 - 1, 20, 8, 9, 58)), // 2016-10-20T08:09:58Z maxDate: null, @@ -80,8 +70,6 @@ export const DATASET_S2L1C: Dataset = { shProcessingApiDatasourceAbbreviation: 'S2L1C', datasetParametersType: 'S2', shServiceHostname: 'https://services.sentinel-hub.com/', - searchIndexUrl: 'https://services.sentinel-hub.com/index/v3/collections/S2L1C/searchIndex', - findDatesUTCUrl: 'https://services.sentinel-hub.com/index/v3/collections/S2L1C/findAvailableData', orbitTimeMinutes: 50.3, minDate: new Date(Date.UTC(2015, 6 - 1, 27, 10, 25, 31)), // 2015-06-27T10:25:31 maxDate: null, @@ -95,8 +83,6 @@ export const DATASET_CDAS_S2L2A: Dataset = { shProcessingApiDatasourceAbbreviation: 'S2L2A', datasetParametersType: 'S2', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S2L2A/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S2L2A/findAvailableData', orbitTimeMinutes: 50.3, minDate: new Date(Date.UTC(2016, 10 - 1, 20, 8, 9, 58)), // 2016-10-20T08:09:58Z maxDate: null, @@ -110,8 +96,6 @@ export const DATASET_CDAS_OTC_S2L2A: Dataset = { shProcessingApiDatasourceAbbreviation: 'S2L2A', datasetParametersType: 'S2', shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S2L2A/searchIndex', - findDatesUTCUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S2L2A/findAvailableData', orbitTimeMinutes: 50.3, minDate: new Date(Date.UTC(2016, 10 - 1, 20, 8, 9, 58)), // 2016-10-20T08:09:58Z maxDate: null, @@ -125,8 +109,6 @@ export const DATASET_CDAS_S2L1C: Dataset = { shProcessingApiDatasourceAbbreviation: 'S2L1C', datasetParametersType: 'S2', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S2L1C/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S2L1C/findAvailableData', orbitTimeMinutes: 50.3, minDate: new Date(Date.UTC(2015, 6 - 1, 27, 10, 25, 31)), // 2015-06-27T10:25:31 maxDate: null, @@ -140,8 +122,6 @@ export const DATASET_CDAS_OTC_S2L1C: Dataset = { shProcessingApiDatasourceAbbreviation: 'S2L1C', datasetParametersType: 'S2', shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S2L1C/searchIndex', - findDatesUTCUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S2L1C/findAvailableData', orbitTimeMinutes: 50.3, minDate: new Date(Date.UTC(2015, 6 - 1, 27, 10, 25, 31)), // 2015-06-27T10:25:31 maxDate: null, @@ -155,8 +135,6 @@ export const DATASET_S3SLSTR: Dataset = { shProcessingApiDatasourceAbbreviation: 'S3SLSTR', datasetParametersType: 'S3SLSTR', shServiceHostname: 'https://creodias.sentinel-hub.com/', - searchIndexUrl: 'https://creodias.sentinel-hub.com/index/v3/collections/S3SLSTR/searchIndex', - findDatesUTCUrl: 'https://creodias.sentinel-hub.com/index/v3/collections/S3SLSTR/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 19, 0, 46, 32)), // 2016-04-19T00:46:32.578 maxDate: null, @@ -170,8 +148,6 @@ export const DATASET_CDAS_S3SLSTR: Dataset = { shProcessingApiDatasourceAbbreviation: 'S3SLSTR', datasetParametersType: 'S3SLSTR', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3SLSTR/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3SLSTR/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 19, 0, 46, 32)), // 2016-04-19T00:46:32.578 maxDate: null, @@ -185,8 +161,6 @@ export const DATASET_CDAS_OTC_S3SLSTR: Dataset = { shProcessingApiDatasourceAbbreviation: 'S3SLSTR', datasetParametersType: 'S3SLSTR', shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S3SLSTR/searchIndex', - findDatesUTCUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S3SLSTR/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 19, 0, 46, 32)), // 2016-04-19T00:46:32.578 maxDate: null, @@ -200,8 +174,6 @@ export const DATASET_S3OLCI: Dataset = { shProcessingApiDatasourceAbbreviation: 'S3OLCI', datasetParametersType: 'S3', shServiceHostname: 'https://creodias.sentinel-hub.com/', - searchIndexUrl: 'https://creodias.sentinel-hub.com/index/v3/collections/S3OLCI/searchIndex', - findDatesUTCUrl: 'https://creodias.sentinel-hub.com/index/v3/collections/S3OLCI/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 25, 11, 33, 14)), // 2016-04-25T11:33:14 maxDate: null, @@ -215,8 +187,6 @@ export const DATASET_CDAS_S3OLCI: Dataset = { shProcessingApiDatasourceAbbreviation: 'S3OLCI', datasetParametersType: 'S3', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3OLCI/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3OLCI/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 25, 11, 33, 14)), // 2016-04-25T11:33:14 maxDate: null, @@ -230,8 +200,6 @@ export const DATASET_CDAS_S3OLCIL2: Dataset = { shProcessingApiDatasourceAbbreviation: 'sentinel-3-olci-l2', datasetParametersType: 'S3', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3OLCIL2/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3OLCIL2/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 25, 11, 33, 14)), // 2016-04-25T11:33:14 maxDate: null, @@ -245,8 +213,6 @@ export const DATASET_CDAS_S3SYNERGYL2: Dataset = { shProcessingApiDatasourceAbbreviation: 'sentinel-3-synergy-l2', datasetParametersType: 'S3', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3SYNL2/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S3SYNL2/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 25, 11, 33, 14)), // 2016-04-25T11:33:14 maxDate: null, @@ -260,8 +226,6 @@ export const DATASET_CDAS_OTC_S3OLCI: Dataset = { shProcessingApiDatasourceAbbreviation: 'S3OLCI', datasetParametersType: 'S3', shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S3OLCI/searchIndex', - findDatesUTCUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S3OLCI/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 25, 11, 33, 14)), // 2016-04-25T11:33:14 maxDate: null, @@ -275,8 +239,6 @@ export const DATASET_CDAS_OTC_S3OLCIL2: Dataset = { shProcessingApiDatasourceAbbreviation: 'sentinel-3-olci-l2', datasetParametersType: 'S3', shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S3OLCIL2/searchIndex', - findDatesUTCUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S3OLCIL2/findAvailableData', orbitTimeMinutes: 50.495, minDate: new Date(Date.UTC(2016, 4 - 1, 25, 11, 33, 14)), // 2016-04-25T11:33:14 maxDate: null, @@ -290,8 +252,6 @@ export const DATASET_S5PL2: Dataset = { shProcessingApiDatasourceAbbreviation: 'S5PL2', datasetParametersType: 'S5PL2', shServiceHostname: 'https://creodias.sentinel-hub.com/', - searchIndexUrl: 'https://creodias.sentinel-hub.com/index/v3/collections/S5PL2/searchIndex', - findDatesUTCUrl: 'https://creodias.sentinel-hub.com/index/v3/collections/S5PL2/findAvailableData', orbitTimeMinutes: 101, minDate: new Date(Date.UTC(2018, 4 - 1, 30, 0, 18, 51)), // 2018-04-30T00:18:51 maxDate: null, @@ -305,8 +265,6 @@ export const DATASET_CDAS_S5PL2: Dataset = { shProcessingApiDatasourceAbbreviation: 'S5PL2', datasetParametersType: 'S5PL2', shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S5PL2/searchIndex', - findDatesUTCUrl: 'https://sh.dataspace.copernicus.eu/index/v3/collections/S5PL2/findAvailableData', orbitTimeMinutes: 101, minDate: new Date(Date.UTC(2018, 4 - 1, 30, 0, 18, 51)), // 2018-04-30T00:18:51 maxDate: null, @@ -320,8 +278,6 @@ export const DATASET_CDAS_OTC_S5PL2: Dataset = { shProcessingApiDatasourceAbbreviation: 'S5PL2', datasetParametersType: 'S5PL2', shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S5PL2/searchIndex', - findDatesUTCUrl: 'https://sh-otc.dataspace.copernicus.eu/index/v3/collections/S5PL2/findAvailableData', orbitTimeMinutes: 101, minDate: new Date(Date.UTC(2018, 4 - 1, 30, 0, 18, 51)), // 2018-04-30T00:18:51 maxDate: null, @@ -335,8 +291,6 @@ export const DATASET_AWS_L8L1C: Dataset = { shProcessingApiDatasourceAbbreviation: 'L8L1C', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/L8L1C/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/L8L1C/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(2013, 3 - 1, 18, 15, 59, 2)), // 2013-03-18T15:59:02.334 maxDate: null, @@ -350,8 +304,6 @@ export const DATASET_AWS_LOTL1: Dataset = { shProcessingApiDatasourceAbbreviation: 'LOTL1', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LOTL1/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LOTL1/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(2013, 3 - 1, 18, 15, 58, 14)), // 2013-03-18T15:58:14Z maxDate: null, @@ -365,8 +317,6 @@ export const DATASET_AWS_LOTL2: Dataset = { shProcessingApiDatasourceAbbreviation: 'LOTL2', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LOTL2/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LOTL2/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(2013, 3 - 1, 18, 15, 58, 14)), // 2013-03-18T15:58:14Z maxDate: null, @@ -380,8 +330,6 @@ export const DATASET_AWS_LTML1: Dataset = { shProcessingApiDatasourceAbbreviation: 'LTML1', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LTML1/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LTML1/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(1982, 8 - 1, 22, 14, 18, 20)), // 1982-08-22 14:18:20 UTC maxDate: new Date(Date.UTC(2012, 5 - 1, 5, 17, 54, 6)), // 2012-05-05 17:54:06 UTC @@ -395,8 +343,6 @@ export const DATASET_AWS_LTML2: Dataset = { shProcessingApiDatasourceAbbreviation: 'LTML2', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LTML2/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LTML2/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(1982, 8 - 1, 22, 14, 18, 20)), // 1982-08-22 14:18:20 UTC maxDate: new Date(Date.UTC(2012, 5 - 1, 5, 17, 54, 6)), // 2012-05-05 17:54:06 UTC @@ -410,8 +356,6 @@ export const DATASET_AWS_LMSSL1: Dataset = { shProcessingApiDatasourceAbbreviation: 'LMSSL1', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LMSSL1/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LMSSL1/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(1972, 7 - 1, 1, 0, 0, 0)), maxDate: new Date(Date.UTC(2013, 1 - 1, 31, 23, 59, 59)), @@ -425,8 +369,6 @@ export const DATASET_AWS_LETML1: Dataset = { shProcessingApiDatasourceAbbreviation: 'LETML1', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LETML1/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LETML1/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(1999, 4 - 1, 1, 0, 0, 0)), maxDate: null, @@ -440,8 +382,6 @@ export const DATASET_AWS_LETML2: Dataset = { shProcessingApiDatasourceAbbreviation: 'LETML2', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LETML2/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/LETML2/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(1999, 4 - 1, 1, 0, 0, 0)), maxDate: null, @@ -455,8 +395,6 @@ export const DATASET_AWS_HLS: Dataset = { shProcessingApiDatasourceAbbreviation: 'HLS', datasetParametersType: 'HLS', shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/HLS/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/HLS/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(2013, 4 - 1, 1, 0, 25, 55)), // 2013-04-01T00:25:55.457 maxDate: null, @@ -470,8 +408,6 @@ export const DATASET_MODIS: Dataset = { shProcessingApiDatasourceAbbreviation: 'MODIS', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/MODIS/searchIndex', - findDatesUTCUrl: 'https://services-uswest2.sentinel-hub.com/index/v3/collections/MODIS/findAvailableData', orbitTimeMinutes: 99, minDate: new Date(Date.UTC(2000, 2 - 1, 24, 12, 0, 0)), // 2000-02-24T12:00:00 maxDate: new Date(Date.UTC(2023, 2 - 1, 10, 12, 0, 0)), // 2023-02-10T12:00:00 @@ -485,8 +421,6 @@ export const DATASET_AWS_DEM: Dataset = { shProcessingApiDatasourceAbbreviation: 'DEM', datasetParametersType: null, shServiceHostname: 'https://services.sentinel-hub.com/', - searchIndexUrl: null, - findDatesUTCUrl: null, orbitTimeMinutes: null, minDate: null, maxDate: null, @@ -499,8 +433,6 @@ export const DATASET_AWSUS_DEM: Dataset = { shProcessingApiDatasourceAbbreviation: 'DEM', datasetParametersType: null, shServiceHostname: 'https://services-uswest2.sentinel-hub.com/', - searchIndexUrl: null, - findDatesUTCUrl: null, orbitTimeMinutes: null, minDate: null, maxDate: null, @@ -513,8 +445,6 @@ export const DATASET_CDAS_DEM: Dataset = { shProcessingApiDatasourceAbbreviation: 'DEM', datasetParametersType: null, shServiceHostname: 'https://sh.dataspace.copernicus.eu/', - searchIndexUrl: null, - findDatesUTCUrl: null, orbitTimeMinutes: null, minDate: null, maxDate: null, @@ -527,8 +457,6 @@ export const DATASET_CDAS_OTC_DEM: Dataset = { shProcessingApiDatasourceAbbreviation: 'DEM', datasetParametersType: null, shServiceHostname: 'https://sh-otc.dataspace.copernicus.eu/', - searchIndexUrl: null, - findDatesUTCUrl: null, orbitTimeMinutes: null, minDate: null, maxDate: null, @@ -541,8 +469,6 @@ export const DATASET_BYOC: Dataset = { shProcessingApiDatasourceAbbreviation: 'CUSTOM', datasetParametersType: 'BYOC', shServiceHostname: null, // depends on location, for example: https://services.sentinel-hub.com/ - searchIndexUrl: null, // depends on location, for example: https://services.sentinel-hub.com/byoc/v3/collections/CUSTOM/searchIndex - findDatesUTCUrl: null, // depends on location, for example: https://services.sentinel-hub.com/byoc/v3/collections/CUSTOM/findAvailableData orbitTimeMinutes: null, minDate: null, maxDate: null, @@ -556,8 +482,6 @@ export const DATASET_PLANET_NICFI: Dataset = { shProcessingApiDatasourceAbbreviation: null, datasetParametersType: null, shServiceHostname: null, - searchIndexUrl: null, - findDatesUTCUrl: null, orbitTimeMinutes: null, minDate: new Date(Date.UTC(2016, 6 - 1, 31, 12, 0, 0)), // '2016-05-31', maxDate: null, From 2fa44254a04dce39eee568810b8fad7f40cfab51 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 17:45:26 +0200 Subject: [PATCH 09/11] change cache test to mock catalog api instead of index service --- src/layer/__tests__/cache.ts | 79 ++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/src/layer/__tests__/cache.ts b/src/layer/__tests__/cache.ts index 81c7e46a..fa33e173 100644 --- a/src/layer/__tests__/cache.ts +++ b/src/layer/__tests__/cache.ts @@ -1,8 +1,6 @@ /** * @jest-environment jsdom */ -import axios from 'axios'; -import MockAdapter from 'axios-mock-adapter'; import makeServiceWorkerEnv from 'service-worker-mock'; import fetch from 'node-fetch'; @@ -10,24 +8,21 @@ import { ApiType, setAuthToken, invalidateCaches, CacheTarget } from '../../inde import { cacheStillValid, EXPIRY_HEADER_KEY } from '../../utils/cacheHandlers'; import '../../../jest-setup'; -import { constructFixtureFindTiles } from './fixtures.findTiles'; +import { AUTH_TOKEN, mockNetwork } from './testUtils.findTiles'; +import { constructFixtureFindTilesCatalog } from './fixtures.S1GRDAWSLayer'; import { constructFixtureGetMap } from './fixtures.getMap'; import { constructFixtureUpdateLayerFromServiceIfNeeded } from './fixtures.BYOCLayer'; -const mockNetwork = new MockAdapter(axios); - -const EXAMPLE_TOKEN = 'TOKEN111'; - describe('Testing caching', () => { beforeEach(async () => { Object.assign(global, makeServiceWorkerEnv(), fetch); // adds these functions to the global object await invalidateCaches(); - setAuthToken(undefined); + setAuthToken(AUTH_TOKEN); }); it('should fetch a request and cache it, where 2nd request is served from the cache', async () => { const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles, expectedResultHasMore } = - constructFixtureFindTiles({}); + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -47,7 +42,7 @@ describe('Testing caching', () => { it('should make a 2nd request after the cache has expired', async () => { const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles, expectedResultHasMore } = - constructFixtureFindTiles({}); + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 1, @@ -86,12 +81,19 @@ describe('Testing caching', () => { }); it('test that no responses are cached', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse } = constructFixtureFindTiles({}); + const { fromTime, toTime, bbox, layer, mockedResponse } = constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(200, mockedResponse); mockNetwork.onPost().replyOnce(200, mockedResponse); - await layer.findTiles(bbox, fromTime, toTime); + // findTilesUsingCatalog have a 30-minute cache by default + const requestsConfig = { + cache: { + expiresIn: 0, + }, + }; + + await layer.findTiles(bbox, fromTime, toTime, null, null, requestsConfig); await layer.findTiles(bbox, fromTime, toTime); expect(mockNetwork.history.post.length).toBe(2); @@ -101,7 +103,6 @@ describe('Testing caching', () => { // arrayBuffer needs to be used, and removing this will cause getMap to fetch a blob, as window.Blob was created with jsdom window.Blob = undefined; const { layer, getMapParams, mockedResponse } = constructFixtureGetMap(); - setAuthToken(EXAMPLE_TOKEN); mockNetwork.reset(); mockNetwork.onPost().replyOnce(200, mockedResponse); mockNetwork.onPost().replyOnce(200, mockedResponse); @@ -121,7 +122,6 @@ describe('Testing caching', () => { }, }; const { layer, getMapParams, mockedResponse } = constructFixtureGetMap(); - setAuthToken(EXAMPLE_TOKEN); mockNetwork.reset(); mockNetwork.onPost().replyOnce(200, mockedResponse); mockNetwork.onPost().replyOnce(200, mockedResponse); @@ -153,7 +153,6 @@ describe('Testing caching', () => { }, }; - setAuthToken(EXAMPLE_TOKEN); mockNetwork.reset(); mockNetwork.onPost().reply(mockedResponse); mockNetwork.onPost().replyOnce(200, mockedResponse); @@ -169,13 +168,12 @@ describe('Testing cache targets', () => { beforeEach(async () => { Object.assign(global, makeServiceWorkerEnv(), fetch); // adds these functions to the global object await invalidateCaches(); - setAuthToken(undefined); + setAuthToken(AUTH_TOKEN); }); it('should cache to cache api', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -200,9 +198,8 @@ describe('Testing cache targets', () => { }); it('should cache to memory', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -234,9 +231,8 @@ describe('Testing cache targets', () => { }); it('should default to caching to cache_api', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -261,9 +257,8 @@ describe('Testing cache targets', () => { }); it('should invalidate caches', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const reqConfigCacheApi = { cache: { expiresIn: 1, @@ -337,13 +332,12 @@ describe('Testing cache targets when cache_api is not available', () => { beforeEach(async () => { Object.assign(global, { caches: undefined }, fetch); // adds these functions to the global object and removes caches from global object await invalidateCaches(); - setAuthToken(undefined); + setAuthToken(AUTH_TOKEN); }); it('should default to memory if window.caches is undefined and no targets were defined', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -376,9 +370,8 @@ describe('Testing cache targets when cache_api is not available', () => { }); it('should not use cache if cache-api is specified as target', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -411,13 +404,12 @@ describe('Reading from cache twice', () => { beforeEach(async () => { Object.assign(global, makeServiceWorkerEnv(), fetch); // adds these functions to the global object and removes caches from global object await invalidateCaches(); - setAuthToken(undefined); + setAuthToken(AUTH_TOKEN); }); it('should read from cache-api twice', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -442,9 +434,8 @@ describe('Reading from cache twice', () => { }); it('should read from memory cache twice', async () => { - const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = constructFixtureFindTiles( - {}, - ); + const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles } = + constructFixtureFindTilesCatalog({}); const requestsConfig = { cache: { expiresIn: 60, @@ -491,7 +482,7 @@ describe('Unit test for aux request caching', () => { beforeEach(async () => { Object.assign(global, makeServiceWorkerEnv(), fetch); // adds these functions to the global object await invalidateCaches(); - setAuthToken(undefined); + setAuthToken(AUTH_TOKEN); }); const listOfRequstConfigs = [ @@ -532,7 +523,6 @@ describe('Unit test for aux request caching', () => { it.each([...listOfRequstConfigs])( 'It should be cache aux request to memory by default', async (requestConfig) => { - setAuthToken(EXAMPLE_TOKEN); const { layer, mockedResponse, expectedLayerParams } = constructFixtureUpdateLayerFromServiceIfNeeded( {}, ); @@ -555,7 +545,6 @@ describe('Unit test for aux request caching', () => { }, ); it('It should not cache aux request when cache is disabled', async () => { - setAuthToken(EXAMPLE_TOKEN); const { layer, mockedResponse, expectedLayerParams } = constructFixtureUpdateLayerFromServiceIfNeeded({}); const requestsConfig = { cache: { From d5a09cb195a59530ee57db96b143e0d21a94c2da Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 17:57:02 +0200 Subject: [PATCH 10/11] change retries test to mock catalog api instead of index service --- src/layer/__tests__/retries.ts | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/layer/__tests__/retries.ts b/src/layer/__tests__/retries.ts index 28381fdb..e31011de 100644 --- a/src/layer/__tests__/retries.ts +++ b/src/layer/__tests__/retries.ts @@ -1,23 +1,20 @@ -import axios from 'axios'; -import MockAdapter from 'axios-mock-adapter'; - -import { invalidateCaches } from '../../index'; +import { setAuthToken, invalidateCaches } from '../../index'; import '../../../jest-setup'; -import { constructFixtureFindTiles } from './fixtures.findTiles'; +import { constructFixtureFindTilesCatalog } from './fixtures.S1GRDAWSLayer'; import { CACHE_CONFIG_30MIN } from '../../utils/cacheHandlers'; - -const mockNetwork = new MockAdapter(axios); +import { AUTH_TOKEN, mockNetwork } from './testUtils.findTiles'; beforeEach(async () => { await invalidateCaches(); + setAuthToken(AUTH_TOKEN); }); test('Retries correctly on network errors', async () => { // we need to adjust jest timeout until we have support for setting the delay when retrying, // otherwise the test will time out: const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles, expectedResultHasMore } = - constructFixtureFindTiles({}); + constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(500); @@ -33,7 +30,7 @@ test('Retries correctly on network errors', async () => { test("Doesn't retry if not needed", async () => { const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles, expectedResultHasMore } = - constructFixtureFindTiles({}); + constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(200, mockedResponse); @@ -48,7 +45,7 @@ test("Doesn't retry if not needed", async () => { test( 'Fails if max. retries (default == 2) was exceeded', async () => { - const { fromTime, toTime, bbox, layer } = constructFixtureFindTiles({}); + const { fromTime, toTime, bbox, layer } = constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(500); @@ -65,7 +62,7 @@ test( test( 'Fails if max. retries (explicitly set) was exceeded', async () => { - const { fromTime, toTime, bbox, layer } = constructFixtureFindTiles({}); + const { fromTime, toTime, bbox, layer } = constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(500); @@ -81,7 +78,7 @@ test( ); test("Doesn't retry if retrying is disabled", async () => { - const { fromTime, toTime, bbox, layer } = constructFixtureFindTiles({}); + const { fromTime, toTime, bbox, layer } = constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(500); @@ -92,7 +89,7 @@ test("Doesn't retry if retrying is disabled", async () => { test( 'Uses default number of retries (2) if null is set', async () => { - const { fromTime, toTime, bbox, layer } = constructFixtureFindTiles({}); + const { fromTime, toTime, bbox, layer } = constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(500); mockNetwork.onPost().replyOnce(500); @@ -108,7 +105,7 @@ test( 'Retries correctly when caching is enabled', async () => { const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles, expectedResultHasMore } = - constructFixtureFindTiles({}); + constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(500); @@ -140,7 +137,7 @@ test( 'Retries concurrent requests when caching is enabled', async () => { const { fromTime, toTime, bbox, layer, mockedResponse, expectedResultTiles, expectedResultHasMore } = - constructFixtureFindTiles({}); + constructFixtureFindTilesCatalog({}); //first request will fail, all other will succeed mockNetwork.reset(); @@ -176,7 +173,7 @@ test( test( 'Compare payload is the same on retry', async () => { - const { fromTime, toTime, bbox, layer } = constructFixtureFindTiles({}); + const { fromTime, toTime, bbox, layer } = constructFixtureFindTilesCatalog({}); mockNetwork.reset(); mockNetwork.onPost().replyOnce(500); mockNetwork.onPost().replyOnce(500); From abfbb5311fd3fdbe061ea44a2caeed37a22b0f3e Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Tue, 5 Aug 2025 18:01:47 +0200 Subject: [PATCH 11/11] change cancelToken test to mock catalog api instead of index service --- src/layer/__tests__/cancelToken.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/layer/__tests__/cancelToken.ts b/src/layer/__tests__/cancelToken.ts index 2b480137..b32ecf5b 100644 --- a/src/layer/__tests__/cancelToken.ts +++ b/src/layer/__tests__/cancelToken.ts @@ -7,12 +7,13 @@ import { setAuthToken, invalidateCaches, CacheTarget, CancelToken, isCancelled, import { cacheableRequestsInProgress } from '../../utils/cacheHandlers'; import '../../../jest-setup'; -import { constructFixtureFindTiles } from './fixtures.findTiles'; +import { constructFixtureFindTilesCatalog } from './fixtures.S1GRDAWSLayer'; import { RequestConfiguration } from '../../utils/cancelRequests'; import { constructFixtureGetMap } from './fixtures.getMap'; +import { AUTH_TOKEN } from './testUtils.findTiles'; const createRequestPromise = (useCache = true, setRequestError: (err: any) => void): any => { - const { fromTime, toTime, bbox, layer, mockedResponse } = constructFixtureFindTiles({}); + const { fromTime, toTime, bbox, layer, mockedResponse } = constructFixtureFindTilesCatalog({}); let cancelToken = new CancelToken(); const requestsConfig: RequestConfiguration = { cancelToken: cancelToken, @@ -49,7 +50,7 @@ describe('Handling cancelled requests', () => { beforeEach(async () => { Object.assign(global, makeServiceWorkerEnv(), fetch); // adds these functions to the global object await invalidateCaches(); - setAuthToken(undefined); + setAuthToken(AUTH_TOKEN); mockNetwork.reset(); cacheableRequestsInProgress.clear(); }); @@ -130,8 +131,6 @@ describe('Handling cancelled requests', () => { mockNetwork.onPost().replyOnce(200, mockedResponse); mockNetwork.onPost().replyOnce(200, mockedResponse2); - setAuthToken('EXAMPLE_TOKEN'); - await Promise.all([ requestPromise, layer