Skip to content

Commit

Permalink
Users can customize asset metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Jul 13, 2024
1 parent 7b25128 commit c05d00c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/api/worker/batchjob.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function createSTAC(storage, job, results) {
for(const { filepath, datacube } of results) {
const filename = path.basename(filepath);
const stat = await fse.stat(filepath);
const asset = {
let asset = {
href: path.relative(folder, filepath),
roles: ["data"],
type: Utils.extensionToMediaType(filepath),
Expand Down Expand Up @@ -119,7 +119,8 @@ async function createSTAC(storage, job, results) {
}
}

assets[filename] = asset;
const params = datacube.getOutputFormatParameters();
assets[filename] = Object.assign(asset, params.metadata);
}
const item = {
stac_version: packageInfo.stac_version,
Expand Down
7 changes: 7 additions & 0 deletions src/formats/fileformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ export const NAME_PARAMETER = {
default: null
};

export const METADATA_PARAMETER = {
type: 'object',
description: 'Additional STAC metadata to be added to the exported asset(s).',
default: {}
};

export default class FileFormat {

constructor(title, parameters = {}, description = '') {
this.title = title;
this.description = description;
this.parameters = parameters;
this.addParameter('name', NAME_PARAMETER);
this.addParameter('metadata', METADATA_PARAMETER);
}

getParameters() {
Expand Down

0 comments on commit c05d00c

Please sign in to comment.