Skip to content

Commit

Permalink
add identification.license (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Feb 24, 2023
1 parent 69e4b99 commit bd6869e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
17 changes: 13 additions & 4 deletions docs/content/reference/mcf.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------|------------------|-----------|-------|---------:
Expand All @@ -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
-------------|------------------|-----------|-------|---------:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pygeometa/schemas/mcf/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 22 additions & 1 deletion pygeometa/schemas/ogcapi_records/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 = {
Expand All @@ -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]

Expand Down
3 changes: 3 additions & 0 deletions sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bd6869e

Please sign in to comment.