Skip to content

Commit

Permalink
Merge pull request #13 from sentinel-hub/feature/s-5
Browse files Browse the repository at this point in the history
Feature/s 5
  • Loading branch information
sinergise-anze authored Feb 11, 2020
2 parents 53320b4 + 341a5c7 commit 1222577
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ S1GRDEW_LAYER_ID=
S2L2A_LAYER_ID=
S3SLSTR_LAYER_ID=
S3OLCI_LAYER_ID=
S5PL2_LAYER_ID=
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { S2L2ALayer } from 'src/layer/S2L2ALayer';
import { S2L1CLayer } from 'src/layer/S2L1CLayer';
import { S3SLSTRLayer } from 'src/layer/S3SLSTRLayer';
import { S3OLCILayer } from 'src/layer/S3OLCILayer';
import { S5PL2Layer } from 'src/layer/S5PL2Layer';
import { MODISLayer } from 'src/layer/MODISLayer';
import { DEMLayer } from 'src/layer/DEMLayer';
import { Landsat8AWSLayer } from 'src/layer/Landsat8AWSLayer';
Expand All @@ -40,6 +41,7 @@ export {
S2L1CLayer,
S3SLSTRLayer,
S3OLCILayer,
S5PL2Layer,
MODISLayer,
DEMLayer,
Landsat8AWSLayer,
Expand Down
4 changes: 4 additions & 0 deletions src/layer/LayersFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DATASET_AWSEU_S1GRD,
DATASET_S3SLSTR,
DATASET_S3OLCI,
DATASET_S5PL2,
} from 'src/layer/dataset';
import { AbstractLayer } from 'src/layer/AbstractLayer';
import { WmsLayer } from 'src/layer/WmsLayer';
Expand All @@ -19,6 +20,7 @@ import { S2L2ALayer } from 'src/layer/S2L2ALayer';
import { S2L1CLayer } from 'src/layer/S2L1CLayer';
import { S3SLSTRLayer } from 'src/layer/S3SLSTRLayer';
import { S3OLCILayer } from 'src/layer/S3OLCILayer';
import { S5PL2Layer } from 'src/layer/S5PL2Layer';
import { MODISLayer } from 'src/layer/MODISLayer';
import { DEMLayer } from 'src/layer/DEMLayer';
import { Landsat8AWSLayer } from 'src/layer/Landsat8AWSLayer';
Expand Down Expand Up @@ -63,6 +65,7 @@ export class LayersFactory {
[DATASET_S2L1C.shJsonGetCapabilitiesDataset]: DATASET_S2L1C,
[DATASET_S3SLSTR.shJsonGetCapabilitiesDataset]: DATASET_S3SLSTR,
[DATASET_S3OLCI.shJsonGetCapabilitiesDataset]: DATASET_S3OLCI,
[DATASET_S5PL2.shJsonGetCapabilitiesDataset]: DATASET_S5PL2,
[DATASET_AWS_L8L1C.shJsonGetCapabilitiesDataset]: DATASET_AWS_L8L1C,
[DATASET_MODIS.shJsonGetCapabilitiesDataset]: DATASET_MODIS,
[DATASET_AWS_DEM.shJsonGetCapabilitiesDataset]: DATASET_AWS_DEM,
Expand All @@ -74,6 +77,7 @@ export class LayersFactory {
[DATASET_S2L1C.id]: S2L1CLayer,
[DATASET_S3SLSTR.id]: S3SLSTRLayer,
[DATASET_S3OLCI.id]: S3OLCILayer,
[DATASET_S5PL2.id]: S5PL2Layer,
[DATASET_AWS_L8L1C.id]: Landsat8AWSLayer,
[DATASET_MODIS.id]: MODISLayer,
[DATASET_AWS_DEM.id]: DEMLayer,
Expand Down
63 changes: 63 additions & 0 deletions src/layer/S5PL2Layer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { BBox } from 'src/bbox';
import { PaginatedTiles } from 'src/layer/const';
import { DATASET_S5PL2 } from 'src/layer/dataset';
import { AbstractSentinelHubV3Layer } from 'src/layer/AbstractSentinelHubV3Layer';

/*
S-5P is a bit special in that we need to supply productType when searching
for tiles, but we don't need it for getMap() (it is determined automatically
from the evalscript).
*/

export enum ProductType {
AER_AI = 'AER_AI',
CLOUD = 'CLOUD',
CO = 'CO',
HCHO = 'HCHO',
NO2 = 'NO2',
O3 = 'O3',
SO2 = 'SO2',
CH4 = 'CH4',
}

type S5PL2FindTilesDatasetParameters = {
type: string;
productType: ProductType;
};

export class S5PL2Layer extends AbstractSentinelHubV3Layer {
public readonly dataset = DATASET_S5PL2;

public async findTiles(
bbox: BBox,
fromTime: Date,
toTime: Date,
maxCount?: number,
offset?: number,
productType?: ProductType,
): Promise<PaginatedTiles> {
const findTilesDatasetParameters: S5PL2FindTilesDatasetParameters = {
type: this.dataset.shProcessingApiDatasourceAbbreviation,
productType: productType,
};
const response = await this.fetchTiles(
bbox,
fromTime,
toTime,
maxCount,
offset,
null,
findTilesDatasetParameters,
);
return {
tiles: response.data.tiles.map(tile => {
return {
geometry: tile.tileDrawRegionGeometry,
sensingTime: tile.sensingTime,
meta: {},
};
}),
hasMore: response.data.hasMore,
};
}
}
9 changes: 9 additions & 0 deletions src/layer/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ export const DATASET_S3OLCI: Dataset = {
orbitTimeMinutes: 50.495,
};

export const DATASET_S5PL2: Dataset = {
id: 'CRE_S5PL2',
shJsonGetCapabilitiesDataset: 'S5PL2',
shWmsEvalsource: 'S5P_L2',
shProcessingApiDatasourceAbbreviation: 'S5PL2',
shServiceHostname: 'https://creodias.sentinel-hub.com/',
searchIndexUrl: 'https://creodias.sentinel-hub.com/index/v3/collections/S5PL2/searchIndex',
};

export const DATASET_AWS_L8L1C: Dataset = {
id: 'AWS_L8L1C',
shJsonGetCapabilitiesDataset: 'L8L1C',
Expand Down
2 changes: 1 addition & 1 deletion src/layer/wms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function wmsGetMapUrl(
}

if (evalscript) {
queryParams.evalscript = evalscript;
queryParams.evalscript = btoa(evalscript);
}
if (evalscriptUrl) {
queryParams.evalscripturl = evalscriptUrl;
Expand Down
2 changes: 1 addition & 1 deletion src/legacyCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function legacyGetMapFromParams(
`Evalsource ${evalsource} is not valid on this layer (was expecting ${expectedEvalsource})`,
);
}
layer.setEvalscript(evalscript);
layer.setEvalscript(decodedEvalscript);
} else if (evalscriptUrl) {
// Processing API doesn't support evalscriptUrl, bail out:
throw new Error('Parameter evalscriptUrl is not supported with Processing API');
Expand Down
Loading

0 comments on commit 1222577

Please sign in to comment.