Skip to content

Commit

Permalink
CMR-10043: Adding browse asset to items
Browse files Browse the repository at this point in the history
  • Loading branch information
william-valencia committed Aug 22, 2024
1 parent 1013b5b commit 83bcf00
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/domains/stac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ const thumbnailAssets = (concept: Collection | Granule) => {
}, {} as AssetLinks);
};

/**
* Return browse assets if present.
*/
const browseAssets = (concept: Collection | Granule) => {
const browseTypes = [RelatedUrlType.GET_RELATED_VISUALIZATION];
return (concept.relatedUrls ?? [])
.filter((relatedUrl) =>
browseTypes.find((browseType) => (browseType === relatedUrl["type"] && relatedUrl.url.startsWith("http")))
)
.reduce((metadataAssets, relatedUrl, idx, available) => {

Check warning on line 109 in src/domains/stac.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

'idx' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 109 in src/domains/stac.ts

View workflow job for this annotation

GitHub Actions / Lint (18)

'available' is defined but never used. Allowed unused args must match /^_/u
const browseAsset: AssetLinks = {};
browseAsset[`browse`] = {
href: relatedUrl.url,
title: `Download ${relatedUrl.url.split("/").at(-1)}`,
type: "image/jpeg",
roles: ["browse"],
};
return { ...metadataAssets, ...browseAsset };
}, {} as AssetLinks);
};

/**
* Reducer for s3 buckets.
*/
Expand Down Expand Up @@ -144,7 +165,7 @@ const s3Assets = (concept: Collection | Granule) => {
return s3Assets;
};

const defaultExtractors = [thumbnailAssets, downloadAssets, metadataAssets, s3Assets];
const defaultExtractors = [browseAssets, thumbnailAssets, downloadAssets, metadataAssets, s3Assets];

/**
* Given a concept and a list of asset extractors return available assets.
Expand Down

0 comments on commit 83bcf00

Please sign in to comment.