From 1fe2285187d5d73981a6ff3f10a2fd050f6ba275 Mon Sep 17 00:00:00 2001 From: paul van genuchten Date: Tue, 20 Dec 2022 15:09:18 +0100 Subject: [PATCH] add scale/resolution to spatial section resolves #189 --- pygeometa/schemas/iso19139/__init__.py | 13 +++++++++++++ pygeometa/schemas/iso19139/main.j2 | 22 ++++++++++++++++++++++ pygeometa/schemas/mcf/core.yaml | 21 +++++++++++++++++++++ tests/md-SMJP01RJTD-gmd.xml | 11 +++++++++++ 4 files changed, 67 insertions(+) diff --git a/pygeometa/schemas/iso19139/__init__.py b/pygeometa/schemas/iso19139/__init__.py index 47e4198..531ebe2 100644 --- a/pygeometa/schemas/iso19139/__init__.py +++ b/pygeometa/schemas/iso19139/__init__.py @@ -82,6 +82,7 @@ def import_(self, metadata: str) -> dict: 'version': '1.0', }, 'metadata': {}, + 'spatial': {}, 'identification': {}, 'contact': {}, 'distribution': {} @@ -138,6 +139,18 @@ def import_(self, metadata: str) -> dict: 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 diff --git a/pygeometa/schemas/iso19139/main.j2 b/pygeometa/schemas/iso19139/main.j2 index efc8ecd..6d357ad 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 dac91e3..46c5f73 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