diff --git a/docs/geotiff.md b/docs/geotiff.md index 625abb82c..26ce28050 100644 --- a/docs/geotiff.md +++ b/docs/geotiff.md @@ -19,7 +19,7 @@ What is required by back-ends to give users an ideal experience with GeoTiff ima 1. The no-data value either in `file:nodata` (deprecated) or in `nodata` in `raster:bands` 2. The `minimum` and `maximum` values per band in the `statistics` object in `raster:bands` 3. A band `name` either in `raster:bands` (unspecified) or `eo:bands` - 4. The projection in `proj:epsg` (recommended), `proj:wkt2` (not well suported by OpenLayers) or `proj:proj4` (deprecated by STAC) + 4. The projection in `proj:epsg` (recommended), `proj:wkt2` (not suported by OpenLayers), or `equi7:proj` (proprietary). 5. The `type` must be set to the corresponding media type (see below) 8. For synchronous execution, the `Content-Type` in the header of the response must be set to the corresponding media type (see below) diff --git a/package.json b/package.json index 3ac3b494d..b8b1b3e04 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "jsonlint-mod": "^1.7.6", "luxon": "^2.4.0", "node-polyfill-webpack-plugin": "^2.0.0", - "ol": "^7.2.2", + "ol": "^7.3.0", "ol-ext": "^4.0.4", "proj4": "^2.7.5", "splitpanes": "^2.3.6", diff --git a/src/components/maps/projManager.js b/src/components/maps/projManager.js index 684fc3dc6..d12427d47 100644 --- a/src/components/maps/projManager.js +++ b/src/components/maps/projManager.js @@ -34,14 +34,29 @@ export default class ProjManager { } } - // Get projection details from STAC (todo: add collection support) - static async addFromStac(stac) { - if (Utils.isObject(stac) && Utils.isObject(stac.properties)) { - if (stac.properties['proj:epsg']) { - return await ProjManager.get(stac.properties['proj:epsg']); + static async addFromStacItem(stac) { + if (Utils.isObject(stac)) { + return await this.addFromStacObject(stac.properties, stac.id); + } + return null; + } + + // Get projection details from STAC Asset + static async addFromStacAsset(asset) { + return await this.addFromStacObject(asset, asset.href); + } + + // Get projection details from STAC Asset + static async addFromStacObject(obj, id) { + if (Utils.isObject(obj)) { + if (obj['proj:epsg']) { + return await ProjManager.get(obj['proj:epsg']); + } + else if (obj['equi7:proj']) { + return ProjManager.add(id, obj['equi7:proj']); } - else if (stac.properties['proj:wkt2']) { - return ProjManager.add(stac.id, stac.properties['proj:wkt2']); + else if (obj['proj:wkt2']) { + return ProjManager.add(id, obj['proj:wkt2']); } } return null; diff --git a/src/formats/geotiff.js b/src/formats/geotiff.js index 4602252c4..1c811c021 100644 --- a/src/formats/geotiff.js +++ b/src/formats/geotiff.js @@ -49,7 +49,10 @@ class GeoTIFF extends SupportedFormat { let stacHasExtent = this.stac && (this.stac.geometry || this.stac.extent); // Get projection from STAC - this.projection = await ProjManager.addFromStac(this.stac); + this.projection = await ProjManager.addFromStacAsset(this); + if (!this.projection && this.stac.type === 'Feature') { + this.projection = await ProjManager.addFromStacItem(this.stac); + } // Get nodata from STAC file:nodata if (Array.isArray(this['file:nodata']) && this['file:nodata'].length > 0) { @@ -138,11 +141,11 @@ class GeoTIFF extends SupportedFormat { let code; if (!this.projection && this.img.geoKeys) { let { ProjectedCSTypeGeoKey, GeographicTypeGeoKey, ProjLinearUnitsGeoKey, GeogAngularUnitsGeoKey } = this.img.geoKeys; - if (ProjectedCSTypeGeoKey) { + if (ProjectedCSTypeGeoKey && ProjectedCSTypeGeoKey !== 32767) { code = 'EPSG:' + ProjectedCSTypeGeoKey; this.projection = await ProjManager.get(code); } - if (!this.projection && GeographicTypeGeoKey) { + if (!this.projection && GeographicTypeGeoKey && GeographicTypeGeoKey !== 32767) { code = 'EPSG:' + GeographicTypeGeoKey; this.projection = await ProjManager.get(code); }