Skip to content

Commit 4962e88

Browse files
committed
Draft for equi7 support #301
1 parent dfc5e70 commit 4962e88

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

docs/geotiff.md

Lines changed: 1 addition & 1 deletion
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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"jsonlint-mod": "^1.7.6",
5959
"luxon": "^2.4.0",
6060
"node-polyfill-webpack-plugin": "^2.0.0",
61-
"ol": "^7.2.2",
61+
"ol": "^7.3.0",
6262
"ol-ext": "^4.0.4",
6363
"proj4": "^2.7.5",
6464
"splitpanes": "^2.3.6",

src/components/maps/projManager.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,29 @@ 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+
44+
// Get projection details from STAC Asset
45+
static async addFromStacAsset(asset) {
46+
return await this.addFromStacObject(asset, asset.href);
47+
}
48+
49+
// Get projection details from STAC Asset
50+
static async addFromStacObject(obj, id) {
51+
if (Utils.isObject(obj)) {
52+
if (obj['proj:epsg']) {
53+
return await ProjManager.get(obj['proj:epsg']);
54+
}
55+
else if (obj['equi7:proj']) {
56+
return ProjManager.add(id, obj['equi7:proj']);
4257
}
43-
else if (stac.properties['proj:wkt2']) {
44-
return ProjManager.add(stac.id, stac.properties['proj:wkt2']);
58+
else if (obj['proj:wkt2']) {
59+
return ProjManager.add(id, obj['proj:wkt2']);
4560
}
4661
}
4762
return null;

src/formats/geotiff.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ 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+
this.projection = await ProjManager.addFromStacAsset(this);
53+
if (!this.projection && this.stac.type === 'Feature') {
54+
this.projection = await ProjManager.addFromStacItem(this.stac);
55+
}
5356

5457
// Get nodata from STAC file:nodata
5558
if (Array.isArray(this['file:nodata']) && this['file:nodata'].length > 0) {
@@ -138,11 +141,11 @@ class GeoTIFF extends SupportedFormat {
138141
let code;
139142
if (!this.projection && this.img.geoKeys) {
140143
let { ProjectedCSTypeGeoKey, GeographicTypeGeoKey, ProjLinearUnitsGeoKey, GeogAngularUnitsGeoKey } = this.img.geoKeys;
141-
if (ProjectedCSTypeGeoKey) {
144+
if (ProjectedCSTypeGeoKey && ProjectedCSTypeGeoKey !== 32767) {
142145
code = 'EPSG:' + ProjectedCSTypeGeoKey;
143146
this.projection = await ProjManager.get(code);
144147
}
145-
if (!this.projection && GeographicTypeGeoKey) {
148+
if (!this.projection && GeographicTypeGeoKey && GeographicTypeGeoKey !== 32767) {
146149
code = 'EPSG:' + GeographicTypeGeoKey;
147150
this.projection = await ProjManager.get(code);
148151
}

0 commit comments

Comments
 (0)