diff --git a/owslib/iso.py b/owslib/iso.py index c2b5b26bd..c69b1bc1e 100644 --- a/owslib/iso.py +++ b/owslib/iso.py @@ -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 """ diff --git a/tests/doctests/iso_creation.txt b/tests/doctests/iso_creation.txt index d36cd412d..1cbe19400 100644 --- a/tests/doctests/iso_creation.txt +++ b/tests/doctests/iso_creation.txt @@ -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 @@ -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')