Skip to content

Commit

Permalink
Merge pull request #84 from sentinel-hub/feature/tiles-extra-info
Browse files Browse the repository at this point in the history
Feature/tiles extra info
  • Loading branch information
Ardweaden authored May 12, 2020
2 parents f14b862 + c5f4d13 commit 0940b6a
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/layer/AbstractSentinelHubV1OrV2Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
HistogramType,
FisPayload,
MosaickingOrder,
Link,
} from 'src/layer/const';
import { wmsGetMapUrl } from 'src/layer/wms';
import { AbstractLayer } from 'src/layer/AbstractLayer';
Expand Down Expand Up @@ -138,6 +139,7 @@ export class AbstractSentinelHubV1OrV2Layer extends AbstractLayer {
geometry: tile.tileDrawRegionGeometry,
sensingTime: moment.utc(tile.sensingTime).toDate(),
meta: this.extractFindTilesMeta(tile),
links: this.getTileLinks(tile),
})),
hasMore: response.data.hasMore,
};
Expand All @@ -150,6 +152,10 @@ export class AbstractSentinelHubV1OrV2Layer extends AbstractLayer {
protected getStatsAdditionalParameters(): Record<string, any> {
return {};
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected getTileLinks(tile: Record<string, any>): Link[] {
return [];
}

public async findDatesUTC(bbox: BBox, fromTime: Date, toTime: Date): Promise<Date[]> {
if (!this.dataset.findDatesUTCUrl) {
Expand Down
12 changes: 11 additions & 1 deletion src/layer/AbstractSentinelHubV3Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
MosaickingOrder,
GetStatsParams,
Stats,
Link,
} from 'src/layer/const';
import { wmsGetMapUrl } from 'src/layer/wms';
import { processingGetMap, createProcessingPayload, ProcessingPayload } from 'src/layer/processing';
Expand Down Expand Up @@ -246,11 +247,20 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer {
tiles: response.data.tiles.map(tile => ({
geometry: tile.dataGeometry,
sensingTime: moment.utc(tile.sensingTime).toDate(),
meta: {},
meta: this.extractFindTilesMeta(tile),
links: this.getTileLinks(tile),
})),
hasMore: response.data.hasMore,
};
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected extractFindTilesMeta(tile: any): Record<string, any> {
return {};
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected getTileLinks(tile: Record<string, any>): Link[] {
return [];
}

protected fetchTiles(
searchIndexUrl: string,
Expand Down
12 changes: 9 additions & 3 deletions src/layer/AbstractSentinelHubV3WithCCLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ export class AbstractSentinelHubV3WithCCLayer extends AbstractSentinelHubV3Layer
tiles: response.data.tiles.map(tile => ({
geometry: tile.dataGeometry,
sensingTime: moment.utc(tile.sensingTime).toDate(),
meta: {
cloudCoverPercent: tile.cloudCoverPercentage,
},
meta: this.extractFindTilesMeta(tile),
links: this.getTileLinks(tile),
})),
hasMore: response.data.hasMore,
};
Expand All @@ -77,4 +76,11 @@ export class AbstractSentinelHubV3WithCCLayer extends AbstractSentinelHubV3Layer
maxcc: this.maxCloudCoverPercent,
};
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected extractFindTilesMeta(tile: any): Record<string, any> {
return {
...super.extractFindTilesMeta(tile),
cloudCoverPercent: tile.cloudCoverPercentage,
};
}
}
11 changes: 10 additions & 1 deletion src/layer/EnvisatMerisEOCloudLayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DATASET_EOCLOUD_ENVISAT_MERIS } from 'src/layer/dataset';

import { Link, LinkType } from 'src/layer/const';
import { AbstractSentinelHubV1OrV2Layer } from 'src/layer/AbstractSentinelHubV1OrV2Layer';

export class EnvisatMerisEOCloudLayer extends AbstractSentinelHubV1OrV2Layer {
Expand All @@ -23,4 +23,13 @@ export class EnvisatMerisEOCloudLayer extends AbstractSentinelHubV1OrV2Layer {
description,
});
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.pathFragment,
type: LinkType.EOCLOUD,
},
];
}
}
21 changes: 21 additions & 0 deletions src/layer/Landsat5EOCloudLayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DATASET_EOCLOUD_LANDSAT5 } from 'src/layer/dataset';
import { AbstractSentinelHubV1OrV2WithCCLayer } from 'src/layer/AbstractSentinelHubV1OrV2WithCCLayer';
import { Link, LinkType } from 'src/layer/const';

export class Landsat5EOCloudLayer extends AbstractSentinelHubV1OrV2WithCCLayer {
public readonly dataset = DATASET_EOCLOUD_LANDSAT5;
Expand All @@ -24,4 +25,24 @@ export class Landsat5EOCloudLayer extends AbstractSentinelHubV1OrV2WithCCLayer {
maxCloudCoverPercent,
});
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.pathFragment,
type: LinkType.EOCLOUD,
},
{
target: `${tile.previewUrl.replace('eocloud', 'creodias')}.JPG`,
type: LinkType.PREVIEW,
},
];
}

protected extractFindTilesMeta(tile: any): Record<string, any> {
return {
...super.extractFindTilesMeta(tile),
sunElevation: tile.sunElevation,
};
}
}
21 changes: 21 additions & 0 deletions src/layer/Landsat7EOCloudLayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DATASET_EOCLOUD_LANDSAT7 } from 'src/layer/dataset';
import { AbstractSentinelHubV1OrV2WithCCLayer } from 'src/layer/AbstractSentinelHubV1OrV2WithCCLayer';
import { Link, LinkType } from 'src/layer/const';

export class Landsat7EOCloudLayer extends AbstractSentinelHubV1OrV2WithCCLayer {
public readonly dataset = DATASET_EOCLOUD_LANDSAT7;
Expand All @@ -24,4 +25,24 @@ export class Landsat7EOCloudLayer extends AbstractSentinelHubV1OrV2WithCCLayer {
maxCloudCoverPercent,
});
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.pathFragment,
type: LinkType.EOCLOUD,
},
{
target: `${tile.previewUrl.replace('eocloud', 'creodias')}.JPG`,
type: LinkType.PREVIEW,
},
];
}

protected extractFindTilesMeta(tile: any): Record<string, any> {
return {
...super.extractFindTilesMeta(tile),
sunElevation: tile.sunElevation,
};
}
}
21 changes: 21 additions & 0 deletions src/layer/Landsat8AWSLayer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import { DATASET_AWS_L8L1C } from 'src/layer/dataset';
import { AbstractSentinelHubV3WithCCLayer } from './AbstractSentinelHubV3WithCCLayer';
import { Link, LinkType } from 'src/layer/const';

export class Landsat8AWSLayer extends AbstractSentinelHubV3WithCCLayer {
public readonly dataset = DATASET_AWS_L8L1C;

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.dataUri,
type: LinkType.AWS,
},
{
target: `${tile.dataUri}_thumb_small.jpg`,
type: LinkType.PREVIEW,
},
];
}

protected extractFindTilesMeta(tile: any): Record<string, any> {
return {
...super.extractFindTilesMeta(tile),
sunElevation: tile.sunElevation,
};
}
}
21 changes: 21 additions & 0 deletions src/layer/Landsat8EOCloudLayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DATASET_EOCLOUD_LANDSAT8 } from 'src/layer/dataset';
import { AbstractSentinelHubV1OrV2WithCCLayer } from 'src/layer/AbstractSentinelHubV1OrV2WithCCLayer';
import { Link, LinkType } from 'src/layer/const';

export class Landsat8EOCloudLayer extends AbstractSentinelHubV1OrV2WithCCLayer {
public readonly dataset = DATASET_EOCLOUD_LANDSAT8;
Expand All @@ -24,4 +25,24 @@ export class Landsat8EOCloudLayer extends AbstractSentinelHubV1OrV2WithCCLayer {
maxCloudCoverPercent,
});
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.pathFragment,
type: LinkType.EOCLOUD,
},
{
target: `https://finder.creodias.eu/files${tile.pathFragment.replace('/eodata', '')}.png`,
type: LinkType.PREVIEW,
},
];
}

protected extractFindTilesMeta(tile: any): Record<string, any> {
return {
...super.extractFindTilesMeta(tile),
sunElevation: tile.sunElevation,
};
}
}
12 changes: 11 additions & 1 deletion src/layer/S1GRDAWSEULayer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';

import { BBox } from 'src/bbox';
import { BackscatterCoeff, PaginatedTiles, OrbitDirection } from 'src/layer/const';
import { BackscatterCoeff, PaginatedTiles, OrbitDirection, Link, LinkType } from 'src/layer/const';
import { ProcessingPayload } from 'src/layer/processing';
import { DATASET_AWSEU_S1GRD } from 'src/layer/dataset';

Expand Down Expand Up @@ -157,6 +157,7 @@ export class S1GRDAWSEULayer extends AbstractSentinelHubV3Layer {
acquisitionMode: tile.acquisitionMode,
resolution: tile.resolution,
},
links: this.getTileLinks(tile),
})),
hasMore: response.data.hasMore,
};
Expand All @@ -176,4 +177,13 @@ export class S1GRDAWSEULayer extends AbstractSentinelHubV3Layer {
}
return result;
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.dataUri,
type: LinkType.AWS,
},
];
}
}
17 changes: 16 additions & 1 deletion src/layer/S1GRDEOCloudLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DATASET_EOCLOUD_S1GRD } from 'src/layer/dataset';

import { AbstractSentinelHubV1OrV2Layer } from 'src/layer/AbstractSentinelHubV1OrV2Layer';
import { AcquisitionMode, Polarization } from 'src/layer/S1GRDAWSEULayer';
import { OrbitDirection, MosaickingOrder } from 'src/layer/const';
import { OrbitDirection, MosaickingOrder, Link, LinkType } from 'src/layer/const';

/*
Note: the usual combinations are IW + DV/SV + HIGH and EW + DH/SH + MEDIUM.
Expand Down Expand Up @@ -131,4 +131,19 @@ export class S1GRDEOCloudLayer extends AbstractSentinelHubV1OrV2Layer {
}
return result;
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.pathFragment,
type: LinkType.EOCLOUD,
},
{
target: `https://finder.creodias.eu/files/${
tile.pathFragment.split('eodata')[1]
}/preview/quick-look.png`,
type: LinkType.PREVIEW,
},
];
}
}
27 changes: 27 additions & 0 deletions src/layer/S2L1CLayer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import { DATASET_S2L1C } from 'src/layer/dataset';
import { AbstractSentinelHubV3WithCCLayer } from './AbstractSentinelHubV3WithCCLayer';
import { Link, LinkType } from 'src/layer/const';

export class S2L1CLayer extends AbstractSentinelHubV3WithCCLayer {
public readonly dataset = DATASET_S2L1C;

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.dataUri,
type: LinkType.AWS,
},
{
target: `https://roda.sentinel-hub.com/sentinel-s2-l1c/tiles${
tile.dataUri.split('tiles')[1]
}/preview.jpg`,
type: LinkType.PREVIEW,
},
];
}

protected extractFindTilesMeta(tile: any): Record<string, any> {
return {
...super.extractFindTilesMeta(tile),
tileId: tile.id,
MGRSLocation: tile.dataUri
.split('/')
.slice(4, 7)
.join(''),
};
}
}
21 changes: 21 additions & 0 deletions src/layer/S2L2ALayer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DATASET_S2L2A } from 'src/layer/dataset';
import { AbstractSentinelHubV3WithCCLayer } from './AbstractSentinelHubV3WithCCLayer';
import { ProcessingPayload } from 'src/layer/processing';
import { Link, LinkType } from 'src/layer/const';

export class S2L2ALayer extends AbstractSentinelHubV3WithCCLayer {
public readonly dataset = DATASET_S2L2A;
Expand All @@ -9,4 +10,24 @@ export class S2L2ALayer extends AbstractSentinelHubV3WithCCLayer {
payload.input.data[0].dataFilter.maxCloudCoverage = this.maxCloudCoverPercent;
return payload;
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.dataUri,
type: LinkType.AWS,
},
];
}

protected extractFindTilesMeta(tile: any): Record<string, any> {
return {
...super.extractFindTilesMeta(tile),
tileId: tile.id,
MGRSLocation: tile.dataUri
.split('/')
.slice(4, 7)
.join(''),
};
}
}
19 changes: 18 additions & 1 deletion src/layer/S3OLCILayer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';

import { BBox } from 'src/bbox';
import { PaginatedTiles } from 'src/layer/const';
import { PaginatedTiles, Link, LinkType } from 'src/layer/const';
import { DATASET_S3OLCI } from 'src/layer/dataset';
import { AbstractSentinelHubV3Layer } from 'src/layer/AbstractSentinelHubV3Layer';

Expand All @@ -28,8 +28,25 @@ export class S3OLCILayer extends AbstractSentinelHubV3Layer {
geometry: tile.dataGeometry,
sensingTime: moment.utc(tile.sensingTime).toDate(),
meta: {},
links: this.getTileLinks(tile),
})),
hasMore: response.data.hasMore,
};
}

protected getTileLinks(tile: Record<string, any>): Link[] {
return [
{
target: tile.originalId.replace('EODATA', '/eodata'),
type: LinkType.CREODIAS,
},
{
target: `https://finder.creodias.eu/files${tile.originalId.replace(
'EODATA',
'',
)}/${tile.productName.replace('.SEN3', '')}-ql.jpg`,
type: LinkType.PREVIEW,
},
];
}
}
Loading

0 comments on commit 0940b6a

Please sign in to comment.