Skip to content

Commit

Permalink
fixup! Change AbstractSentinelHubV3Layer to receive evalscript value …
Browse files Browse the repository at this point in the history
…from dataProduct endpoint
  • Loading branch information
Jan Kumer committed Sep 6, 2024
1 parent 89e7ff7 commit a5ac104
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
18 changes: 6 additions & 12 deletions src/layer/AbstractSentinelHubV3Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
MosaickingOrder,
PaginatedTiles,
Stats,
SUPPORTED_DATA_PRODUCTS_PROCESSING,
} from './const';
import { createProcessingPayload, processingGetMap, ProcessingPayload } from './processing';
import { wmsGetMapUrl } from './wms';
Expand Down Expand Up @@ -128,15 +127,11 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer {
throw new Error('Layer params could not be found');
}

const dataProductUrl = layerParams['dataProduct'];

if (!this.evalscript && dataProductUrl) {
const response = await fetchDataProduct(dataProductUrl, reqConfig);
if (!layerParams['evalscript'] && layerParams['dataProduct']) {
const response = await fetchDataProduct(layerParams['dataProduct'], reqConfig);
const evalScript = response?.data?.evalScript;
if (evalScript) {
this.evalscript = evalScript;
// now that evalscript here, dataProduct=null will make rest of logic use ApiType.PROCESSING
this.dataProduct = null;
layerParams['evalscript'] = evalScript;
}
}

Expand Down Expand Up @@ -249,9 +244,6 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer {
}

public supportsApiType(api: ApiType): boolean {
if (this.dataProduct && !SUPPORTED_DATA_PRODUCTS_PROCESSING.includes(this.dataProduct)) {
return api === ApiType.WMS;
}
return api === ApiType.WMS || (api === ApiType.PROCESSING && !!this.dataset);
}

Expand Down Expand Up @@ -683,7 +675,6 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer {
if (!this.evalscript) {
this.evalscript = layerParams['evalscript'] ? layerParams['evalscript'] : null;
}

if (!this.mosaickingOrder && layerParams.mosaickingOrder) {
this.mosaickingOrder = layerParams.mosaickingOrder;
}
Expand All @@ -693,6 +684,9 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer {
if (!this.downsampling && layerParams.downsampling) {
this.downsampling = layerParams.downsampling;
}

// now that evalscript here, dataProduct=null will make rest of logic use ApiType.PROCESSING
this.dataProduct = layerParams['evalscript'] ? layerParams['evalscript'] : this.dataProduct;
}, reqConfig);
}

Expand Down
4 changes: 0 additions & 4 deletions src/layer/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ export const DEFAULT_FIND_TILES_MAX_COUNT_PARAMETER = 50;

export type DataProductId = string;

export const SUPPORTED_DATA_PRODUCTS_PROCESSING: DataProductId[] = [
'https://services.sentinel-hub.com/configuration/v1/datasets/S2L1C/dataproducts/643',
];

export type BYOCBand = {
name: string;
sampleType: string;
Expand Down

0 comments on commit a5ac104

Please sign in to comment.