Skip to content

Commit

Permalink
Draft for equi7 support #301
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Apr 12, 2023
1 parent dfc5e70 commit ecc1d66
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/geotiff.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
29 changes: 22 additions & 7 deletions src/components/maps/projManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion src/formats/geotiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ 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) {
if (this.stac.type === 'Feature') {
this.projection = await ProjManager.addFromStacItem(this.stac);
}
else if (this.stac.type === 'Collection') {
this.projection = await ProjManager.addFromStacCollection(this.stac);
}
}

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

0 comments on commit ecc1d66

Please sign in to comment.