Skip to content

Commit cfbc0d8

Browse files
committed
Add request parameters to STAC asset URLs.
1 parent 2f783b0 commit cfbc0d8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/models/stac.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import Utils from "../utils";
22
import Migrate from '@radiantearth/stac-migrate';
33
import { getBest } from '../locale-id';
4+
import URI from 'urijs';
5+
import { addQueryIfNotExists } from '../store/utils';
46

57
let stacObjCounter = 0;
68

79
// STAC Entity
810
class STAC {
911

10-
constructor(data, url, path, migrate = true) {
12+
constructor(cx, data, url, path, migrate = true) {
1113
this._id = stacObjCounter++;
1214
this._url = url;
1315
this._path = path;
@@ -35,6 +37,11 @@ class STAC {
3537
this[key] = data[key];
3638
}
3739
}
40+
if (Utils.isObject(this.assets)) {
41+
for (const asset of Object.values(this.assets)) {
42+
asset.href = addQueryIfNotExists(URI(asset.href), cx.state.globalRequestQueryParameters).toString();
43+
}
44+
}
3845
}
3946

4047
isPotentiallyIncomplete() {

src/store/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ function getStore(config, router) {
713713
if (!Utils.isObject(response.data)) {
714714
throw new BrowserError(i18n.t('errors.invalidJsonObject'));
715715
}
716-
data = new STAC(response.data, url, path);
716+
data = new STAC(cx, response.data, url, path);
717717
if (show) {
718718
// If we prefer another language abort redirect to the new language
719719
let localeLink = data.getLocaleLink(cx.state.dataLanguage);
@@ -849,7 +849,7 @@ function getStore(config, router) {
849849
return data;
850850
}
851851
else {
852-
data = new STAC(item, url, cx.getters.toBrowserPath(url));
852+
data = new STAC(cx, item, url, cx.getters.toBrowserPath(url));
853853
data.markPotentiallyIncomplete();
854854
cx.commit('loaded', { data, url });
855855
return data;
@@ -908,7 +908,7 @@ function getStore(config, router) {
908908
return data;
909909
}
910910
else {
911-
data = new STAC(collection, url, cx.getters.toBrowserPath(url));
911+
data = new STAC(cx, collection, url, cx.getters.toBrowserPath(url));
912912
data.markPotentiallyIncomplete();
913913
cx.commit('loaded', { data, url });
914914
return data;

0 commit comments

Comments
 (0)