Skip to content

Commit

Permalink
Merge pull request #232 from PublicaMundi/231-ReferenceSystemInfo
Browse files Browse the repository at this point in the history
231 reference system info
  • Loading branch information
tomkralidis committed Apr 21, 2015
2 parents d23f930 + 09ab0e5 commit b1c40be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
23 changes: 20 additions & 3 deletions owslib/iso.py
Expand Up @@ -717,12 +717,29 @@ def __init__(self, md=None):

class MD_ReferenceSystem(object):
""" process MD_ReferenceSystem """
def __init__(self, md):
def __init__(self, md=None):
if md is None:
pass
self.code = None
self.codeSpace = None
self.version = None
else:
val = md.find(util.nspath_eval('gmd:referenceSystemIdentifier/gmd:RS_Identifier/gmd:code/gco:CharacterString', namespaces))
self.code = util.testXMLValue(val)
if val is not None:
self.code = util.testXMLValue(val)
else:
self.code = None

val = md.find(util.nspath_eval('gmd:referenceSystemIdentifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString', namespaces))
if val is not None:
self.codeSpace = util.testXMLValue(val)
else:
self.codeSpace = None

val = md.find(util.nspath_eval('gmd:referenceSystemIdentifier/gmd:RS_Identifier/gmd:version/gco:CharacterString', namespaces))
if val is not None:
self.version = util.testXMLValue(val)
else:
self.version = None

def _testCodeListValue(elpath):
""" get gco:CodeListValue_Type attribute, else get text content """
Expand Down
6 changes: 5 additions & 1 deletion tests/doctests/iso_creation.txt
Expand Up @@ -3,7 +3,7 @@ Imports
>>> from __future__ import (absolute_import, division, print_function)
>>> import urllib2
>>> from owslib.etree import etree
>>> from owslib.iso import MD_Metadata, MD_DataIdentification, CI_ResponsibleParty
>>> from owslib.iso import MD_Metadata, MD_DataIdentification, CI_ResponsibleParty, MD_ReferenceSystem

Print testing of various ISO fields

Expand All @@ -21,6 +21,10 @@ Print testing of various ISO fields
>>> md.identifier = '286c0725-146e-4533-b1bf-d6e367f6c342'
>>> md.identification.topiccategory.append('biota')
>>> md.identification.topiccategory.append('environment')
>>> md.referencesystem = MD_ReferenceSystem()
>>> md.referencesystem.code = '4326'
>>> md.referencesystem.codeSpace = 'urn:ogc:def:crs:EPSG'
>>> md.referencesystem.version = '6.11.2'
>>> kw = {}
>>> kw['keywords'] = []
>>> kw['keywords'].append('Agricultural and aquaculture facilities')
Expand Down

0 comments on commit b1c40be

Please sign in to comment.