Skip to content

Commit

Permalink
add scale/resolution to spatial section
Browse files Browse the repository at this point in the history
resolves geopython#189
  • Loading branch information
pvgenuchten committed Dec 20, 2022
1 parent 69e5ba9 commit e81d7e8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pygeometa/schemas/iso19139/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def import_(self, metadata: str) -> dict:
'version': '1.0',
},
'metadata': {},
'spatial': {},
'identification': {},
'contact': {},
'distribution': {}
Expand Down Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions pygeometa/schemas/iso19139/main.j2
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,28 @@
<gmd:spatialRepresentationType>
<gmd:MD_SpatialRepresentationTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_SpatialRepresentationTypeCode" codeSpace="ISOTC211/19115" codeListValue="{{ record['spatial']['datatype'] }}">{{ record['spatial']['datatype'] }}</gmd:MD_SpatialRepresentationTypeCode>
</gmd:spatialRepresentationType>
{% for res in record['spatial']['resolutions'] %}
<gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:distance>
<gco:Distance uom="{{ res['uom'] }}">{{ res['distance'] }}</gco:Distance>
</gmd:distance>
</gmd:MD_Resolution>
</gmd:spatialResolution>
{% endfor %}
{% for d in record['spatial']['denominators'] %}
<gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:equivalentScale>
<gmd:MD_RepresentativeFraction>
<gmd:denominator>
<gco:Integer>{{ d }}</gco:Integer>
</gmd:denominator>
</gmd:MD_RepresentativeFraction>
</gmd:equivalentScale>
</gmd:MD_Resolution>
</gmd:spatialResolution>
{% endfor %}
{% if record['identification']['language'] in ['inapplicable', 'missing', 'template', 'unknown', 'withheld'] %}
<gmd:language gco:nilReason="{{ record['identification']['language'] }}"/>
{% else %}
Expand Down
21 changes: 21 additions & 0 deletions pygeometa/schemas/mcf/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/md-SMJP01RJTD-gmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
<gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:equivalentScale>
<gmd:MD_RepresentativeFraction>
<gmd:denominator>
<gco:Integer>10000</gco:Integer>
</gmd:denominator>
</gmd:MD_RepresentativeFraction>
</gmd:equivalentScale>
</gmd:MD_Resolution>
</gmd:spatialResolution>
<gmd:language>
<gco:CharacterString>eng</gco:CharacterString>
</gmd:language>
Expand Down

0 comments on commit e81d7e8

Please sign in to comment.