From 92af2f9b6343c8fe7bd77b253b55bb6c838e889b Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 22 Oct 2024 09:32:47 +1300 Subject: [PATCH] feat: Flatten providers into strings per role TDE-1291 (#1108) #### Motivation Make this information easier to process for GIS tools. #### Checklist - [x] Tests updated - [ ] Docs updated - [x] Issue linked in Title --------- Co-authored-by: Wentao Kuang Co-authored-by: Blayne Chard --- .../__test__/mapsheet.coverage.test.ts | 13 +++++++++++++ .../mapsheet-coverage/mapsheet.coverage.ts | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/commands/mapsheet-coverage/__test__/mapsheet.coverage.test.ts b/src/commands/mapsheet-coverage/__test__/mapsheet.coverage.test.ts index 2cdc1d32..f879b46d 100644 --- a/src/commands/mapsheet-coverage/__test__/mapsheet.coverage.test.ts +++ b/src/commands/mapsheet-coverage/__test__/mapsheet.coverage.test.ts @@ -37,6 +37,16 @@ function fakeCollection(id: string): StacCollection { description: `Layer ${id.toUpperCase()} Description`, assets: { capture_area: { href: './capture-area.json' } }, links: [], + providers: [ + { + name: 'First provider', + roles: ['producer', 'licensor', 'processor'], + }, + { + name: 'Second provider', + roles: ['producer'], + }, + ], } as unknown as StacCollection; } @@ -112,6 +122,9 @@ describe('mapsheet-coverage', () => { id: 'layer-a-id', license: 'CC-BY-4.0', source: 'ms://layers/a/collection.json', + licensor: 'First provider', + processor: 'First provider', + producer: 'First provider, Second provider', }); assert.equal(captureDates.features.length, 1); }); diff --git a/src/commands/mapsheet-coverage/mapsheet.coverage.ts b/src/commands/mapsheet-coverage/mapsheet.coverage.ts index b0182f0a..f4844883 100644 --- a/src/commands/mapsheet-coverage/mapsheet.coverage.ts +++ b/src/commands/mapsheet-coverage/mapsheet.coverage.ts @@ -144,7 +144,19 @@ export const commandMapSheetCoverage = command({ captureArea.properties['description'] = collection.description; captureArea.properties['id'] = collection.id; captureArea.properties['license'] = collection.license; - captureArea.properties['providers'] = collection.providers; + + const roleToNames = new Map>(); + for (const provider of collection.providers ?? []) { + for (const role of provider.roles ?? []) { + const names = roleToNames.get(role) ?? new Set(); + names.add(provider.name); + roleToNames.set(role, names); + } + } + for (const [role, names] of roleToNames) { + captureArea.properties[role] = [...names].join(', '); + } + captureArea.properties['source'] = targetCollection.href; if (flownDates) captureArea.properties['flown_from'] = flownDates[0]; if (flownDates) captureArea.properties['flown_to'] = flownDates[1];