Skip to content

Commit 5c67bf7

Browse files
committed
Draft for equi7 support #301
1 parent dfc5e70 commit 5c67bf7

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

docs/geotiff.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ What is required by back-ends to give users an ideal experience with GeoTiff ima
1919
1. The no-data value either in `file:nodata` (deprecated) or in `nodata` in `raster:bands`
2020
2. The `minimum` and `maximum` values per band in the `statistics` object in `raster:bands`
2121
3. A band `name` either in `raster:bands` (unspecified) or `eo:bands`
22-
4. The projection in `proj:epsg` (recommended), `proj:wkt2` (not well suported by OpenLayers) or `proj:proj4` (deprecated by STAC)
22+
4. The projection in `proj:epsg` (recommended), `proj:wkt2` (not suported by OpenLayers), or `equi7:proj` (proprietary).
2323
5. The `type` must be set to the corresponding media type (see below)
2424
8. For synchronous execution, the `Content-Type` in the header of the response must be set to the corresponding media type (see below)
2525

src/components/maps/projManager.js

+29-7
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,36 @@ export default class ProjManager {
3434
}
3535
}
3636

37-
// Get projection details from STAC (todo: add collection support)
38-
static async addFromStac(stac) {
39-
if (Utils.isObject(stac) && Utils.isObject(stac.properties)) {
40-
if (stac.properties['proj:epsg']) {
41-
return await ProjManager.get(stac.properties['proj:epsg']);
37+
static async addFromStacItem(stac) {
38+
if (Utils.isObject(stac)) {
39+
return await this.addFromStacObject(stac.properties, stac.id);
40+
}
41+
return null;
42+
}
43+
static async addFromStacCollection(stac) {
44+
if (Utils.isObject(stac)) {
45+
// Todo: Handle arrays in summaries...
46+
// return await this.addFromStacObject(stac.summaries, stac.id);
47+
}
48+
return null;
49+
}
50+
51+
// Get projection details from STAC Asset
52+
static async addFromStacAsset(asset) {
53+
return await this.addFromStacObject(asset, asset.href);
54+
}
55+
56+
// Get projection details from STAC Asset
57+
static async addFromStacObject(obj, id) {
58+
if (Utils.isObject(obj)) {
59+
if (obj['proj:epsg']) {
60+
return await ProjManager.get(obj['proj:epsg']);
61+
}
62+
else if (obj['equi7:proj']) {
63+
return ProjManager.add(id, obj['equi7:proj']);
4264
}
43-
else if (stac.properties['proj:wkt2']) {
44-
return ProjManager.add(stac.id, stac.properties['proj:wkt2']);
65+
else if (obj['proj:wkt2']) {
66+
return ProjManager.add(id, obj['proj:wkt2']);
4567
}
4668
}
4769
return null;

src/formats/geotiff.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ class GeoTIFF extends SupportedFormat {
4949
let stacHasExtent = this.stac && (this.stac.geometry || this.stac.extent);
5050

5151
// Get projection from STAC
52-
this.projection = await ProjManager.addFromStac(this.stac);
52+
if (this.stac.type === 'Feature') {
53+
this.projection = await ProjManager.addFromStacItem(this.stac);
54+
}
55+
else if (this.stac.type === 'Collection') {
56+
this.projection = await ProjManager.addFromStacCollection(this.stac);
57+
}
58+
else {
59+
this.projection = await ProjManager.addFromStacAsset(this.stac);
60+
}
5361

5462
// Get nodata from STAC file:nodata
5563
if (Array.isArray(this['file:nodata']) && this['file:nodata'].length > 0) {

0 commit comments

Comments
 (0)