Skip to content

Commit

Permalink
feat: Flatten providers into strings per role TDE-1291 (#1108)
Browse files Browse the repository at this point in the history
#### 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 <[email protected]>
Co-authored-by: Blayne Chard <[email protected]>
  • Loading branch information
3 people authored Oct 21, 2024
1 parent ffa03ad commit 92af2f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/commands/mapsheet-coverage/__test__/mapsheet.coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
});
Expand Down
14 changes: 13 additions & 1 deletion src/commands/mapsheet-coverage/mapsheet.coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Set<string>>();
for (const provider of collection.providers ?? []) {
for (const role of provider.roles ?? []) {
const names = roleToNames.get(role) ?? new Set<string>();
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];
Expand Down

0 comments on commit 92af2f9

Please sign in to comment.