diff --git a/docs/content/reference/mcf.md b/docs/content/reference/mcf.md index e94d207..dc2ac02 100644 --- a/docs/content/reference/mcf.md +++ b/docs/content/reference/mcf.md @@ -151,7 +151,7 @@ browsegraphic|Optional|graphic that provides an illustration of the dataset|http #### `identification.dates` -MCF `identification.dates` sections can have 1..n `dates` sections as required with the following object names/types: +`identification.dates` sections can have 1..n `dates` sections as required with the following object names/types: Property Name|Mandatory/Optional|Description|Example|Reference -------------|------------------|-----------|-------|---------: @@ -169,7 +169,7 @@ identification: #### `identification.extents` -MCF `identification.extents` sections can have 1..n `spatial` and `temporal` sections as required with the following properties. +`identification.extents` sections can have 1..n `spatial` and `temporal` sections as required with the following properties. Property Name|Mandatory/Optional|Description|Example|Reference -------------|------------------|-----------|-------|---------: @@ -194,7 +194,7 @@ identification: #### `identification.keywords` -MCF `identification` sections can have 1..n `keywords` sections as required using nesting. Example: +`identification` sections can have 1..n `keywords` sections as required using nesting. Example: ```yaml identification: @@ -235,13 +235,22 @@ keywords_codelist|Optional|specific code list URL (for advanced use cases, else ##### `identification.keywords.vocabulary` -MCF `keyword` sections can specify an optional `vocabulary` section with the following elements: +`identification.keywords` sections can specify an optional `vocabulary` section with the following elements: Property Name|Mandatory/Optional|Description|Example|Reference -------------|------------------|-----------|-------|---------: name|Mandatory|name of the source of keywords (English)|my thesaurus name|ISO 19115:2003 Section B.2.2.3 url|Optional|URL of source of keywords|https://example.org/my-vocab|- +##### `identification.license` + +`identification.license` sections can provide a optinoal license via a name or URL using the following elements: + +Property Name|Mandatory/Optional|Description|Example|Reference +-------------|------------------|-----------|-------|---------: +name|Mandatory|name of license|CC BY 4.0|- +url|Optional|URL of license|https://creativecommons.org/licenses/by/4.0|- + ### `content_info` Property Name|Mandatory/Optional|Description|Example|Reference diff --git a/pygeometa/schemas/mcf/core.yaml b/pygeometa/schemas/mcf/core.yaml index a0afa2f..c5beb2f 100644 --- a/pygeometa/schemas/mcf/core.yaml +++ b/pygeometa/schemas/mcf/core.yaml @@ -165,6 +165,20 @@ properties: rights: $ref: '#/definitions/i18n_string' description: name by which the cited resource is known + license: + type: object + properties: + name: + $ref: '#/definitions/i18n_string' + description: license applied to resource + url: + $ref: '#/definitions/i18n_string' + description: URL with more information about license + anyOf: + - required: + - name + - required: + - url url: $ref: '#/definitions/i18n_string' description: URL of the dataset to which the metadata applies diff --git a/pygeometa/schemas/ogcapi_records/__init__.py b/pygeometa/schemas/ogcapi_records/__init__.py index 5f6791f..7f37fa6 100644 --- a/pygeometa/schemas/ogcapi_records/__init__.py +++ b/pygeometa/schemas/ogcapi_records/__init__.py @@ -196,6 +196,24 @@ def write(self, mcf: dict, stringify: str = True) -> Union[dict, str]: record['properties']['themes'].append(theme) + LOGGER.debug('Checking for licensing') + if mcf['identification'].get('license') is not None: + license = mcf['identification']['license'] + + print(license) + if 'url' in license: + LOGGER.debug('Encoding license as link') + license_link = { + 'rel': 'license', + 'type': 'text/html', + 'title': license.get('name', 'license for this resource'), + 'url': license['url'] + } + record['links'].append(self.generate_link(license_link)) + else: + LOGGER.debug('Encoding license as property') + record['properties']['license'] = license['name'] + LOGGER.debug('Checking for distribution') for value in mcf['distribution'].values(): record['links'].append(self.generate_link(value)) @@ -299,6 +317,9 @@ def generate_link(self, distribution: dict) -> dict: name = get_charstring(distribution.get('name'), self.lang1, self.lang2) + print("TITLE", title) + print("NAME", name) + reltype = distribution.get('rel') or distribution.get('function') link = { @@ -307,7 +328,7 @@ def generate_link(self, distribution: dict) -> dict: 'type': distribution['type'] } if title != [None, None]: - link['title'] = name[0] + link['title'] = title[0] elif name != [None, None]: link['title'] = name[0] diff --git a/sample.yml b/sample.yml index 59bc0a6..37465e0 100644 --- a/sample.yml +++ b/sample.yml @@ -58,6 +58,9 @@ identification: resolution: P1Y fees: None accessconstraints: otherRestrictions + license: + name: CC BY 4.0 + url: https://creativecommons.org/licenses/by/4.0 rights: en: Copyright (c) 2010 Her Majesty the Queen in Right of Canada fr: Copyright (c) 2010 Her Majesty the Queen in Right of Canada