-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lambda-tiler): update imagery layer attributions to show licenso…
…r details BM-897 (#3357) ### Motivation As an Imagery Data Maintainer, I want to ensure that imagery is attributed to the correct licensor(s) for all published surveys so that councils and government departments receive appropriate recognition. --- ### Attribution Types || Compact | Extended | | - | - | - | | Template | © `stac_license` `licensor_names` | © `stac_license` `licensor_names` - `tileset_info` | | Example | © CC BY 4.0 Otago Regional Council | © CC BY 4.0 Otago Regional Council - Otago 0.3 Rural Aerial Photos (2017-2019) | --- ### Modifications #### packages/config-loader - Updated the package so that it copies through `providers` metadata when generating config files. #### packages/lambda-tiler - Updated the attribution endpoint to include `providers` metadata as part of collections when returning `AttributionStac` responses. - Updated the style endpoint to include a _compact attribution_ on sources when returning `StyleJson` responses. #### packages/attribution - Updated the attribution class to return an _extended attribution_ for the bottom-right of the landing page. ### Verification #### packages/lambda-tiler 1. Implemented a test suite for the style endpoint to ensure it generates the correct _compact attribution_ for a given tileset. #### packages/attribution 5. Implemented a test suite to verify that the new utility function `createLicensorAttribution()` generates the correct _compact attribution_ for a given list of providers. --- ### Example Layer: Top of the South 0.15m Flood Aerial Photos (2022) > To recreate this example, you will need to locally download the `collection.json` file and at least one of the .TIFF files. You will then need to run them through the `cogify` process and serve them using the `server` package. #### Landing Page Screenshot showing the _extended attribution_ for the bottom-right of the landing page. ![top-of-the-south-flood-2022-0 15m](https://github.com/user-attachments/assets/d90bb27c-0b66-41c1-91b8-402a5e10e2bc) #### Styles Endpoint `/v1/styles/:styleName.json` Excerpt from the JSON response showing the provider metadata: ```json { ... "collections": [ { ... "providers": [ { "name": "Nelson City Council", "roles": [ "licensor" ] }, { "name": "Tasman District Council", "roles": [ "licensor" ] }, { "name": "Waka Kotahi", "roles": [ "licensor" ] }, ... ], ... } ], ... } ``` #### Attribution Endpoint `/v1/tiles/:tileSet/:tileMatrix/attribution.json` Excerpt from the JSON response showing the _compact attribution_ for the layer source: ```json { ... "sources": { "basemaps-top-of-the-south-flood-2022-0.15m": { ... "attribution": "© CC BY 4.0 Nelson City Council, Tasman District Council, Waka Kotahi", ... } }, ... } ```
- Loading branch information
1 parent
4a684f2
commit e702c7e
Showing
10 changed files
with
497 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { strictEqual } from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
import { StacProvider } from '@basemaps/geo'; | ||
|
||
import { copyright, createLicensorAttribution } from '../utils.js'; | ||
|
||
const defaultAttribution = `${copyright} LINZ`; | ||
|
||
describe('utils', () => { | ||
const FakeHost: StacProvider = { | ||
name: 'FakeHost', | ||
roles: ['host'], | ||
}; | ||
const FakeLicensor1: StacProvider = { | ||
name: 'FakeLicensor1', | ||
roles: ['licensor'], | ||
}; | ||
const FakeLicensor2: StacProvider = { | ||
name: 'FakeLicensor2', | ||
roles: ['licensor'], | ||
}; | ||
|
||
it('default attribution: no providers', () => { | ||
const providers = undefined; | ||
const attribution = createLicensorAttribution(providers); | ||
|
||
strictEqual(attribution, defaultAttribution); | ||
}); | ||
|
||
it('default attribution: empty providers', () => { | ||
const providers: StacProvider[] = []; | ||
const attribution = createLicensorAttribution(providers); | ||
|
||
strictEqual(attribution, defaultAttribution); | ||
}); | ||
|
||
it('default attribution: one provider, no licensors', () => { | ||
const providers = [FakeHost]; | ||
|
||
const attribution = createLicensorAttribution(providers); | ||
strictEqual(attribution, defaultAttribution); | ||
}); | ||
|
||
it('custom attribution: one provider, one licensor', () => { | ||
const providers = [FakeLicensor1]; | ||
|
||
const attribution = createLicensorAttribution(providers); | ||
strictEqual(attribution, `${copyright} ${FakeLicensor1.name}`); | ||
}); | ||
|
||
it('custom attribution: two providers, one licensor', () => { | ||
const providers = [FakeHost, FakeLicensor1]; | ||
|
||
const attribution = createLicensorAttribution(providers); | ||
strictEqual(attribution, `${copyright} ${FakeLicensor1.name}`); | ||
}); | ||
|
||
it('custom attribution: two providers, two licensors', () => { | ||
const providers = [FakeLicensor1, FakeLicensor2]; | ||
|
||
const attribution = createLicensorAttribution(providers); | ||
strictEqual(attribution, `${copyright} ${FakeLicensor1.name}, ${FakeLicensor2.name}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Stac, StacProvider } from '@basemaps/geo'; | ||
|
||
export const copyright = `© ${Stac.License}`; | ||
|
||
/** | ||
* Create a licensor attribution string. | ||
* | ||
* @param providers The optional list of providers. | ||
* | ||
* @returns A copyright string comprising the names of licensor providers. | ||
* | ||
* @example | ||
* "CC BY 4.0 LINZ" | ||
* | ||
* @example | ||
* "CC BY 4.0 Nelson City Council, Tasman District Council, Waka Kotahi" | ||
*/ | ||
export function createLicensorAttribution(providers?: StacProvider[]): string { | ||
if (providers == null) return `${copyright} LINZ`; | ||
|
||
const licensors = providers.filter((p) => p.roles?.includes('licensor')); | ||
if (licensors.length === 0) return `${copyright} LINZ`; | ||
|
||
return `${copyright} ${licensors.map((l) => l.name).join(', ')}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.