Skip to content

Commit

Permalink
distribution: ensure format_version exists or emit gco:nilReason=missing
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Jan 15, 2024
1 parent c1ff8ec commit 3a369b6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
8 changes: 4 additions & 4 deletions docs/content/reference/formats/iso19139-hnap.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ distribution:
format:
en: Other
fr: Autre
format_version: 0
format_version: '0'
function: download

waf_eng-CAN:
Expand All @@ -62,7 +62,7 @@ distribution:
format:
en: Other
fr: Autre
format_version: 0
format_version: '0'
function: download

wms_eng-CAN:
Expand All @@ -72,7 +72,7 @@ distribution:
fr: Service Web
type: OGC:WMS
format: WMS
format_version: 1.1.1
format_version: '1.1.1'
name:
en: GDPS.ETA_TT
fr: GDPS.ETA_TT
Expand All @@ -85,7 +85,7 @@ distribution:
fr: Service Web
type: OGC:WMS
format: WMS
format_version: 1.1.1
format_version: '1.1.1'
name:
en: GDPS.ETA_TT
fr: GDPS.ETA_TT
Expand Down
10 changes: 8 additions & 2 deletions pygeometa/schemas/iso19139/main.j2
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,17 @@
<gmd:distributionInfo>
<gmd:MD_Distribution>
{% for k, v in record['distribution'].items() %}
{% if v['format'] and v['format_version'] %}
{% if v['format'] %}
<gmd:distributionFormat>
<gmd:MD_Format>
<gmd:name>{{ v['format'] }}</gmd:name>
<gmd:version>{{ v['format_version'] }}</gmd:version>
{% if v['format_version'] %}
<gmd:version>
<gco:CharacterString>{{ v['format_version'] }}</gco:CharacterString>
</gmd:version>
{% else %}
<gmd:version gco:nilReason="missing"/>
{% endif %}
</gmd:MD_Format>
</gmd:distributionFormat>
{% endif %}
Expand Down
10 changes: 8 additions & 2 deletions pygeometa/schemas/iso19139_2/main.j2
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,17 @@
<gmd:distributionInfo>
<gmd:MD_Distribution>
{% for k, v in record['distribution'].items() %}
{% if v['format'] and v['format_version'] %}
{% if v['format'] %}
<gmd:distributionFormat>
<gmd:MD_Format>
<gmd:name>{{ v['format'] }}</gmd:name>
<gmd:version>{{ v['format_version'] }}</gmd:version>
{% if v['format_version'] %}
<gmd:version>
<gco:CharacterString>{{ v['format_version'] }}</gco:CharacterString>
</gmd:version>
{% else %}
<gco:version gco:nilReason="missing"/>
{% endif %}
</gmd:MD_Format>
</gmd:distributionFormat>
{% endif %}
Expand Down
6 changes: 5 additions & 1 deletion pygeometa/schemas/iso19139_hnap/main.j2
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,17 @@
<gmd:MD_Distribution>
{% set formats = prune_distribution_formats(record['distribution']) %}
{% for v in formats %}
{% if v['format_en'] and v['format_fr'] and v['format_version'] %}
{% if v['format_en'] and v['format_fr'] %}
<gmd:distributionFormat>
<gmd:MD_Format>
{{ cs.get_freetext('name', 'fra', get_charstring(v.get('format'), 'en', 'fr')) }}
{% if v['format_version'] %}
<gmd:version>
<gco:CharacterString>{{ v['format_version'] }}</gco:CharacterString>
</gmd:version>
{% else %}
<gmd:version gco:nilReason="missing"/>
{% endif %}
</gmd:MD_Format>
</gmd:distributionFormat>
{% endif %}
Expand Down
10 changes: 8 additions & 2 deletions pygeometa/schemas/wmo_cmp/main.j2
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,17 @@
<gmd:distributionInfo>
<gmd:MD_Distribution>
{% for k, v in record['distribution'].items() %}
{% if v['format'] and v['format_version'] %}
{% if v['format'] %}
<gmd:distributionFormat>
<gmd:MD_Format>
<gmd:name>{{ v['format'] }}</gmd:name>
<gmd:version>{{ v['format_version'] }}</gmd:version>
{% if v['format_version'] %}
<gmd:version>
<gco:CharacterString>{{ v['format_version'] }}</gco:CharacterString>
</gmd:version>
{% else %}
<gmd:version gco:nilReason="missing"/>
{% endif %}
</gmd:MD_Format>
</gmd:distributionFormat>
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ def test_prune_distribution_formats(self):

formats = {
'wms': {
'format_en': 'image', 'format_fr': 'image', 'format_version': 2
'format_en': 'image', 'format_fr': 'image', 'format_version': '2'
},
'wfs': {
'format_en': 'GRIB2', 'format_fr': 'GRIB2', 'format_version': 2
'format_en': 'GRIB2', 'format_fr': 'GRIB2', 'format_version': '2'
},
'wcs': {
'format_en': 'GRIB2', 'format_fr': 'GRIB2', 'format_version': 2
'format_en': 'GRIB2', 'format_fr': 'GRIB2', 'format_version': '2'
}
}

Expand Down

0 comments on commit 3a369b6

Please sign in to comment.