Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add scale/resolution to spatial section #204

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/content/reference/mcf.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
18 changes: 17 additions & 1 deletion pygeometa/schemas/iso19139/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def import_(self, metadata: str) -> dict:
'version': '1.0',
},
'metadata': {},
'spatial': {},
'identification': {},
'contact': {},
'distribution': {}
Expand Down Expand Up @@ -158,7 +159,22 @@ def import_(self, metadata: str) -> dict:

mcf['identification']['extents']['temporal'].append(temp_extent)

if identification.accessconstraints:
if hasattr(identification, 'denominators'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an ok approach, or we expect this property to be always returned by owslib?

mcf['spatial']['denominators'] = identification.denominators

if hasattr(identification, 'distance'):
mcf['spatial']['resolution'] = []
for k, v in enumerate(identification.distance):
uom = ''
if hasattr(identification, 'uom') and len(identification.uom) > k: # noqa
uom = identification.uom[k]
mcf['spatial']['resolution'].append({'distance': v,
'uom': uom})

if hasattr(identification, 'spatialrepresentationtype') and len(identification.spatialrepresentationtype) > 0: # noqa
mcf['spatial']['datatype'] = identification.spatialrepresentationtype[0] # noqa

if hasattr(identification, 'accessconstraints'):
mcf['identification']['accessconstraints'] = identification.accessconstraints[0] # noqa

mcf['identification']['status'] = identification.status
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
14 changes: 14 additions & 0 deletions tests/md-SMJP01RJTD-gmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
<gmd:spatialRepresentationType>
<gmd:MD_SpatialRepresentationTypeCode codeListValue="vector" codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_SpatialRepresentationTypeCode"/>
</gmd:spatialRepresentationType>
<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