From ae6589b98b5c0456a360d85a29b4bfa37f402646 Mon Sep 17 00:00:00 2001 From: Angelos Tzotsos Date: Tue, 21 Apr 2015 02:10:29 +0300 Subject: [PATCH 1/2] Added support for gmd:MD_ReferenceSystem elements (#231) --- owslib/iso.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 """ From 09ab0e5862d50961a7713d628da004a99ebef72c Mon Sep 17 00:00:00 2001 From: Angelos Tzotsos Date: Tue, 21 Apr 2015 02:11:32 +0300 Subject: [PATCH 2/2] Added test for gmd:MD_ReferenceSystem (#231) --- tests/doctests/iso_creation.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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')