Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMR-7804 Change where the cmr-stac granule cloud-cover value comes from #228

Merged
merged 4 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions search/lib/convert/granules.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,10 @@ async function cmrGranuleToStac (event, granule) {
let opendapLink;

const extensions = [];
if (_.has(granule, 'umm.AdditionalAttributes')) {
const attributes = granule.umm.AdditionalAttributes;
const eo = attributes.filter(attr => attr.Name === 'CLOUD_COVERAGE');
if (eo.length) {
extensions.push('https://stac-extensions.github.io/eo/v1.0.0/schema.json');
const eoValue = eo[0].Values[0];
properties['eo:cloud_cover'] = parseInt(eoValue);
}
if (_.has(granule, 'umm.CloudCover')) {
const eo = granule.umm.CloudCover;
extensions.push('https://stac-extensions.github.io/eo/v1.0.0/schema.json');
properties['eo:cloud_cover'] = eo;
}

if (granule.links) {
Expand Down
12 changes: 12 additions & 0 deletions search/tests/convert/granules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,18 @@ describe('granuleToItem', () => {
});
});

describe('cmrGranuleToStac', () => {
const cmrGran = exampleData.examplesByName.lancemodisCmrCcGran;
const expectedStacGran = exampleData.examplesByName.lancemodisStacCcGran;

const event = { headers: { Host: 'example.com' }, multiValueQueryStringParameters: [] };

it('should return a FeatureGeoJSON from a cmrGran containing a eo:cloud_cover field', async () => {
const stacItem = await cmrGranuleToStac(event, cmrGran);
expect(stacItem).toEqual(expectedStacGran);
});
});

describe('cmrGranulesToStac', () => {
beforeEach(() => {
mockFunction(cmr, 'cmrCollectionToStacId', 'landsat.v1');
Expand Down
34 changes: 34 additions & 0 deletions search/tests/example-data/lancemodis_cmr_cc_gran.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"producer_granule_id": "MYD02HKM.A2020162.2355.061.2020163011006.NRT.hdf",
"time_start": "2020-06-10T23:55:00.000Z",
"updated": "2020-06-11T01:10:52.489Z",
"dataset_id": "MODIS/Aqua Calibrated Radiances 5-Min L1B Swath 500m - NRT",
"data_center": "LANCEMODIS",
"title": "LANCEMODIS:1028235774",
"coordinate_system": "GEODETIC",
"day_night_flag": "BOTH",
"time_end": "2020-06-11T00:00:00.000Z",
"id": "G1848422111-LANCEMODIS",
"original_format": "ECHO10",
"granule_size": "83.7333726882935",
"browse_flag": false,
"polygons": [
["-46.728858 -130.072843 -51.176483 -163.057516 -69.364972 -164.573697 -61.968957 -112.537606 -46.728858 -130.072843"]
],
"collection_concept_id": "C1426617060-LANCEMODIS",
"online_access_flag": true,
"links": [{
"rel": "http://esipfed.org/ns/fedsearch/1.1/data#",
"type": "application/x-hdfeos",
"hreflang": "en-US",
"href": "https://nrt3.modaps.eosdis.nasa.gov/archive/allData/61/MYD02HKM/2020/162/MYD02HKM.A2020162.2355.061.NRT.hdf"
}],
"umm": {
"GranuleUR": "G1848422111-LANCEMODIS",
"CollectionReference": {
"ShortName": "MYD02HKM",
"Version": "6.1NRT"
},
"CloudCover": 4
}
}
86 changes: 86 additions & 0 deletions search/tests/example-data/lancemodis_stac_cc_gran.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"type": "Feature",
"id": "G1848422111-LANCEMODIS",
"stac_version": "1.0.0",
"stac_extensions": ["https://stac-extensions.github.io/eo/v1.0.0/schema.json"],
"collection": "MYD02HKM.v6.1NRT",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-130.072843,
-46.728858
],
[
-163.057516,
-51.176483
],
[
-164.573697,
-69.364972
],
[
-112.537606,
-61.968957
],
[
-130.072843,
-46.728858
]
]
]
},
"bbox": [
-164.573697,
-69.492825,
-112.537606,
-46.728858
],
"links": [
{
"rel": "self",
"href": "https://example.com/stac/LANCEMODIS/collections/MYD02HKM.v6.1NRT/items/G1848422111-LANCEMODIS"
},
{
"rel": "parent",
"href": "https://example.com/stac/LANCEMODIS/collections/MYD02HKM.v6.1NRT"
},
{
"rel": "collection",
"href": "https://example.com/stac/LANCEMODIS/collections/MYD02HKM.v6.1NRT"
},
{
"rel": "root",
"href": "https://example.com/stac/"
},
{
"rel": "provider",
"href": "https://example.com/stac/LANCEMODIS"
},
{
"rel": "via",
"href": "http://localhost:3003/concepts/G1848422111-LANCEMODIS.json"
},
{
"rel": "via",
"href": "http://localhost:3003/concepts/G1848422111-LANCEMODIS.umm_json"
}
],
"properties": {
"datetime": "2020-06-10T23:55:00.000Z",
"start_datetime": "2020-06-10T23:55:00.000Z",
"end_datetime": "2020-06-11T00:00:00.000Z",
"eo:cloud_cover": 4
},
"assets": {
"data": {
"href": "https://nrt3.modaps.eosdis.nasa.gov/archive/allData/61/MYD02HKM/2020/162/MYD02HKM.A2020162.2355.061.NRT.hdf",
"type": "application/x-hdfeos"
},
"metadata": {
"href": "http://localhost:3003/concepts/G1848422111-LANCEMODIS.xml",
"type": "application/xml"
}
}
}