From 15d5b27735c4a71b7897b4ed8ac49f07c6a8291d Mon Sep 17 00:00:00 2001 From: paul van genuchten Date: Tue, 20 Dec 2022 15:09:18 +0100 Subject: [PATCH 1/4] add scale/resolution to spatial section resolves #189 --- pygeometa/schemas/iso19139/__init__.py | 17 +++++++++++++++++ pygeometa/schemas/iso19139/main.j2 | 22 ++++++++++++++++++++++ pygeometa/schemas/mcf/core.yaml | 21 +++++++++++++++++++++ tests/md-SMJP01RJTD-gmd.xml | 11 +++++++++++ 4 files changed, 71 insertions(+) diff --git a/pygeometa/schemas/iso19139/__init__.py b/pygeometa/schemas/iso19139/__init__.py index 1c2998e..2b9bbe0 100644 --- a/pygeometa/schemas/iso19139/__init__.py +++ b/pygeometa/schemas/iso19139/__init__.py @@ -84,6 +84,7 @@ def import_(self, metadata: str) -> dict: 'version': '1.0', }, 'metadata': {}, + 'spatial': {}, 'identification': {}, 'contact': {}, 'distribution': {} @@ -156,8 +157,24 @@ def import_(self, metadata: str) -> dict: if identification.temporalextent_end: temp_extent['end'] = identification.temporalextent_end + mcf['identification']['extents']['temporal'].append(temp_extent) + if m.identification.denominators: + mcf['spatial']['denominators'] = m.identification.denominators + + if m.identification.distance: + mcf['spatial']['resolution'] = [] + for k, v in enumerate(m.identification.distance): + uom = '' + if m.identification.uom and len(m.identification.uom) > k: + uom = m.identification.uom[k] + mcf['spatial']['resolution'].append({'distance': v, + 'uom': uom}) + + if m.identification.accessconstraints: + mcf['identification']['accessconstraints'] = m.identification.accessconstraints[0] # noqa + if identification.accessconstraints: mcf['identification']['accessconstraints'] = identification.accessconstraints[0] # noqa diff --git a/pygeometa/schemas/iso19139/main.j2 b/pygeometa/schemas/iso19139/main.j2 index 069c3f0..f86a47e 100644 --- a/pygeometa/schemas/iso19139/main.j2 +++ b/pygeometa/schemas/iso19139/main.j2 @@ -247,6 +247,28 @@ {{ record['spatial']['datatype'] }} + {% for res in record['spatial']['resolutions'] %} + + + + {{ res['distance'] }} + + + + {% endfor %} + {% for d in record['spatial']['denominators'] %} + + + + + + {{ d }} + + + + + + {% endfor %} {% if record['identification']['language'] in ['inapplicable', 'missing', 'template', 'unknown', 'withheld'] %} {% else %} diff --git a/pygeometa/schemas/mcf/core.yaml b/pygeometa/schemas/mcf/core.yaml index 0b858a7..bb79c28 100644 --- a/pygeometa/schemas/mcf/core.yaml +++ b/pygeometa/schemas/mcf/core.yaml @@ -89,6 +89,27 @@ properties: - point - solid - surface + denominators: + type: array + description: one or two (min-max) denominators to indicate the scale of the resource + items: + type: integer + resolutions: + type: array + description: one or two (min-max) distance values + uom to indicate the resolution of the resource + properties: + distance: + type: number + uom: + type: string + description: the unit of measure of the distance value + enum: + - m + - km + - feet + - mile + - degree + - parsec required: - datatype - geomtype diff --git a/tests/md-SMJP01RJTD-gmd.xml b/tests/md-SMJP01RJTD-gmd.xml index 7bdb7ef..e655a6d 100644 --- a/tests/md-SMJP01RJTD-gmd.xml +++ b/tests/md-SMJP01RJTD-gmd.xml @@ -315,6 +315,17 @@ + + + + + + 10000 + + + + + eng From 6b526174bf395d3e27e5ac41793602bc298fb552 Mon Sep 17 00:00:00 2001 From: paul van genuchten Date: Tue, 20 Dec 2022 17:08:00 +0100 Subject: [PATCH 2/4] add datatype section resolves #189 --- pygeometa/schemas/iso19139/__init__.py | 3 +++ tests/md-SMJP01RJTD-gmd.xml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pygeometa/schemas/iso19139/__init__.py b/pygeometa/schemas/iso19139/__init__.py index 2b9bbe0..318236b 100644 --- a/pygeometa/schemas/iso19139/__init__.py +++ b/pygeometa/schemas/iso19139/__init__.py @@ -172,6 +172,9 @@ def import_(self, metadata: str) -> dict: mcf['spatial']['resolution'].append({'distance': v, 'uom': uom}) + if m.identification.spatialrepresentationtype and len(m.identification.spatialrepresentationtype) > 0: # noqa + mcf['spatial']['datatype'] = m.identification.spatialrepresentationtype[0] # noqa + if m.identification.accessconstraints: mcf['identification']['accessconstraints'] = m.identification.accessconstraints[0] # noqa diff --git a/tests/md-SMJP01RJTD-gmd.xml b/tests/md-SMJP01RJTD-gmd.xml index e655a6d..73fee26 100644 --- a/tests/md-SMJP01RJTD-gmd.xml +++ b/tests/md-SMJP01RJTD-gmd.xml @@ -315,6 +315,9 @@ + + + From 54d57880b0589b781fce1c5321a0babfdd17394a Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Thu, 9 Nov 2023 09:39:15 +0100 Subject: [PATCH 3/4] fix tests, checking availability of the property on owslib with hasattr() --- pygeometa/schemas/iso19139/__init__.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/pygeometa/schemas/iso19139/__init__.py b/pygeometa/schemas/iso19139/__init__.py index 318236b..512630a 100644 --- a/pygeometa/schemas/iso19139/__init__.py +++ b/pygeometa/schemas/iso19139/__init__.py @@ -157,28 +157,24 @@ def import_(self, metadata: str) -> dict: if identification.temporalextent_end: temp_extent['end'] = identification.temporalextent_end - mcf['identification']['extents']['temporal'].append(temp_extent) - if m.identification.denominators: - mcf['spatial']['denominators'] = m.identification.denominators + if hasattr(identification, 'denominators'): + mcf['spatial']['denominators'] = identification.denominators - if m.identification.distance: + if hasattr(identification, 'distance'): mcf['spatial']['resolution'] = [] - for k, v in enumerate(m.identification.distance): + for k, v in enumerate(identification.distance): uom = '' - if m.identification.uom and len(m.identification.uom) > k: - uom = m.identification.uom[k] + if hasattr(identification, 'uom') and len(identification.uom) > k: # noqa + uom = identification.uom[k] mcf['spatial']['resolution'].append({'distance': v, 'uom': uom}) - if m.identification.spatialrepresentationtype and len(m.identification.spatialrepresentationtype) > 0: # noqa - mcf['spatial']['datatype'] = m.identification.spatialrepresentationtype[0] # noqa - - if m.identification.accessconstraints: - mcf['identification']['accessconstraints'] = m.identification.accessconstraints[0] # noqa + if hasattr(identification, 'spatialrepresentationtype') and len(identification.spatialrepresentationtype) > 0: # noqa + mcf['spatial']['datatype'] = identification.spatialrepresentationtype[0] # noqa - if identification.accessconstraints: + if hasattr(identification, 'accessconstraints'): mcf['identification']['accessconstraints'] = identification.accessconstraints[0] # noqa mcf['identification']['status'] = identification.status From 3d8f7bf665d25127606536dc45efdc8b20ef2429 Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Thu, 9 Nov 2023 11:22:22 +0100 Subject: [PATCH 4/4] update documentation --- docs/content/reference/mcf.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/content/reference/mcf.md b/docs/content/reference/mcf.md index e1ce202..8bc5e75 100644 --- a/docs/content/reference/mcf.md +++ b/docs/content/reference/mcf.md @@ -129,6 +129,9 @@ Property Name|Mandatory/Optional|Description|Example|Reference -------------|------------------|-----------|-------|---------: datatype|Mandatory|method used to represent geographic information in the dataset (must be one of 'vector', 'grid', 'textTable', 'tin', 'stereoModel', 'video')|vector|Section B.5.26 geomtype|Mandatory|name of point or vector objects used to locate zero-, one-, two-, or threedimensional spatial locations in the dataset (must be one of 'complex', 'composite', 'curve', 'point', 'solid', 'surface')|point|ISO 19115:2003 B.5.15 +denominators|Optional|level of detail expressed as the scale of a comparable hardcopy map or chart|5000|ISO 19115:2003 Section B.2.2.5 +resolution.distance|Optional|ground sample distance|100|ISO 19115:2003 Section B.2.2.5 +resolution.uom|Optional|unit of measure of the distance|m|ISO 19115:2003 Section B.2.2.5 ### `identification`