Skip to content

Commit d1d2410

Browse files
committed
Implement support for the new storage version extension #550
1 parent 09e1deb commit d1d2410

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"dependencies": {
4040
"@apidevtools/json-schema-ref-parser": "^10.1.0",
4141
"@musement/iso-duration": "^1.0.0",
42-
"@radiantearth/stac-fields": "1.5.1",
43-
"@radiantearth/stac-migrate": "2.0.0",
42+
"@radiantearth/stac-fields": "~1.5.2",
43+
"@radiantearth/stac-migrate": "~2.0.0",
4444
"ajv-i18n": "^4.2.0",
4545
"axios": "^1.2.0",
4646
"bootstrap-vue": "^2.21.2",

src/components/AssetAlternative.vue

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<b-card-text class="mt-4" v-if="asset.description">
66
<Description :description="asset.description" compact />
77
</b-card-text>
8-
<Metadata class="mt-4" :data="asset" :context="context" :ignoreFields="ignore" title="" type="Asset" />
8+
<Metadata class="mt-4" :data="resolvedAsset" :context="context" :ignoreFields="ignore" title="" type="Asset" />
99
</component>
1010
</template>
1111

@@ -16,6 +16,8 @@ import Description from './Description.vue';
1616
import HrefActions from './HrefActions.vue';
1717
import StacFieldsMixin from './StacFieldsMixin';
1818
import AuthUtils from './auth/utils';
19+
import Utils from '../utils';
20+
import STAC from '../models/stac';
1921
2022
export default {
2123
name: 'AssetAlternative',
@@ -61,8 +63,9 @@ export default {
6163
'table:storage_options',
6264
'xarray:open_kwargs',
6365
'xarray:storage_options',
64-
// Special handling for auth
66+
// Special handling for auth and storage
6567
'auth:refs',
68+
'storage:refs',
6669
// Alternative Assets are displayed separately
6770
'alternate',
6871
'alternate:name',
@@ -71,6 +74,15 @@ export default {
7174
},
7275
computed: {
7376
...mapState(['buildTileUrlTemplate', 'useTileLayerAsFallback']),
77+
resolvedAsset() {
78+
if (Array.isArray(this.asset['storage:refs'])) {
79+
const storage = this.resolveStorage(this.asset, this.context);
80+
const asset = Object.assign({}, this.asset);
81+
asset['storage:schemes'] = storage;
82+
return asset;
83+
}
84+
return this.asset;
85+
},
7486
component() {
7587
return this.hasAlternatives ? 'div' : 'b-card-body';
7688
},
@@ -93,6 +105,22 @@ export default {
93105
}
94106
},
95107
methods: {
108+
resolveStorage(obj, context) {
109+
if (context instanceof STAC && Utils.size(obj['storage:refs']) > 0) {
110+
const scheme = context.getMetadata('storage:schemes');
111+
if (Utils.size(scheme) > 0) {
112+
const schemes = {};
113+
for (const key in scheme) {
114+
const value = scheme[key];
115+
if (Utils.isObject(value)) {
116+
schemes[key] = value;
117+
}
118+
}
119+
return schemes;
120+
}
121+
}
122+
return [];
123+
},
96124
show() {
97125
this.$emit('show', ...arguments);
98126
}

0 commit comments

Comments
 (0)