Skip to content

Commit

Permalink
Add ISO 19115 Part 3 XML gfc:FC_FeatureCatalogue
Browse files Browse the repository at this point in the history
  • Loading branch information
vjf committed Jan 5, 2024
1 parent 1e4dd9e commit 32daa95
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 1 deletion.
10 changes: 10 additions & 0 deletions owslib/catalogue/csw2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from owslib import util
from owslib import ows
from owslib.iso import MD_Metadata, FC_FeatureCatalogue
from owslib.iso_3 import MD_Metadata as MD_Metadata_3 # ISO 19115 Part 3 XML
from owslib.iso_3 import FC_FeatureCatalogue as FC_FeatureCatalogue_3 # ISO 19115 Part 3 XML
from owslib.fgdc import Metadata
from owslib.dif import DIF
from owslib.gm03 import GM03
Expand Down Expand Up @@ -578,6 +580,14 @@ def _parserecords(self, outputschema, esn):
val = i.find(util.nspath_eval('gm03:fileIdentifier', namespaces))
identifier = self._setidentifierkey(util.testXMLValue(val))
self.records[identifier] = GM03(i)
elif outputschema == namespaces['mdb']: # ISO 19115 Part 3 XML
for i in self._exml.findall('.//' + util.nspath_eval('mdb:MD_Metadata', namespaces)):
val = i.find(util.nspath_eval('mdb:metadataIdentifier/mcc:MD_Identifier/mcc:code/gco:CharacterString', namespaces))
identifier = self._setidentifierkey(util.testXMLValue(val))
self.records[identifier] = MD_Metadata_3(i)
for i in self._exml.findall('.//' + util.nspath_eval('gfc:FC_FeatureCatalogue', namespaces)):
identifier = self._setidentifierkey(util.testXMLValue(i.attrib['uuid'], attrib=True))
self.records[identifier] = FC_FeatureCatalogue_3(i)
else: # process default
for i in self._exml.findall('.//' + util.nspath_eval('csw:%s' % self._setesnel(esn), namespaces)):
val = i.find(util.nspath_eval('dc:identifier', namespaces))
Expand Down
10 changes: 10 additions & 0 deletions owslib/catalogue/csw3.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from owslib import util
from owslib import ows
from owslib.iso import MD_Metadata, FC_FeatureCatalogue
from owslib.iso_3 import MD_Metadata as MD_Metadata_3 # ISO 19115 Part 3 XML
from owslib.iso_3 import FC_FeatureCatalogue as FC_FeatureCatalogue_3 # ISO 19115 Part 3 XML
from owslib.fgdc import Metadata
from owslib.dif import DIF
from owslib.gm03 import GM03
Expand Down Expand Up @@ -477,6 +479,14 @@ def _parserecords(self, outputschema, esn):
val = i.find(util.nspath_eval('gm03:fileIdentifier', namespaces))
identifier = self._setidentifierkey(util.testXMLValue(val))
self.records[identifier] = GM03(i)
elif outputschema == namespaces['mdb']: # ISO 19115 Part 3 XML
for i in self._exml.findall('.//' + util.nspath_eval('mdb:MD_Metadata', namespaces)):
val = i.find(util.nspath_eval('mdb:metadataIdentifier/mcc:MD_Identifier/mcc:code/gco:CharacterString', namespaces))
identifier = self._setidentifierkey(util.testXMLValue(val))
self.records[identifier] = MD_Metadata_3(i)
for i in self._exml.findall('.//' + util.nspath_eval('gfc:FC_FeatureCatalogue', namespaces)):
identifier = self._setidentifierkey(util.testXMLValue(i.attrib['uuid'], attrib=True))
self.records[identifier] = FC_FeatureCatalogue_3(i)
else: # process default
for i in self._exml.findall('.//' + util.nspath_eval('csw30:%s' % self._setesnel(esn), namespaces)):
val = i.find(util.nspath_eval('dc:identifier', namespaces))
Expand Down
9 changes: 8 additions & 1 deletion owslib/feature/wfs100.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from owslib.etree import etree
from owslib.fgdc import Metadata
from owslib.iso import MD_Metadata
from owslib.iso_3 import MD_Metadata as MD_Metadata_3 # ISO 19115 Part 3 XML
from owslib.crs import Crs
from owslib.namespaces import Namespaces
from owslib.feature.schema import get_schema
Expand Down Expand Up @@ -470,7 +471,13 @@ def parse_remote_metadata(self, timeout=30):
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata(mdelem)
else:
metadataUrl["metadata"] = None
mdelem = doc.find(
".//" + util.nspath_eval("mdb:MD_Metadata", n.get_namespaces(["mdb"]))
)
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata_3(mdelem)
else:
metadataUrl["metadata"] = None
except Exception:
metadataUrl["metadata"] = None

Expand Down
8 changes: 8 additions & 0 deletions owslib/feature/wfs200.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from owslib import util
from owslib.fgdc import Metadata
from owslib.iso import MD_Metadata
from owslib.iso_3 import MD_Metadata as MD_Metadata_3
from owslib.ows import Constraint, ServiceIdentification, ServiceProvider, OperationsMetadata
from owslib.etree import etree
from owslib.util import nspath, testXMLValue, openURL, Authentication
Expand Down Expand Up @@ -611,5 +612,12 @@ def parse_remote_metadata(self, timeout=30):
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata(mdelem)
continue
else: # ISO 19115 Part 3 XML
mdelem = doc.find(
".//" + util.nspath_eval("mdb:MD_Metadata", n.get_namespaces(["mdb"]))
)
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata_3(mdelem)
continue
except Exception:
metadataUrl["metadata"] = None
139 changes: 139 additions & 0 deletions owslib/iso_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"cit":"http://standards.iso.org/iso/19115/-3/cit/1.0",
"gcx":"http://standards.iso.org/iso/19115/-3/gcx/1.0",
"gex":"http://standards.iso.org/iso/19115/-3/gex/1.0",
"gfc":"http://standards.iso.org/iso/19110/gfc/1.1",
"lan":"http://standards.iso.org/iso/19115/-3/lan/1.0",
"srv":"http://standards.iso.org/iso/19115/-3/srv/2.0",
"mac":"http://standards.iso.org/iso/19115/-3/mac/1.0",
Expand Down Expand Up @@ -236,6 +237,10 @@ def __init__(self, md=None):
for contentinfo in md.findall(
util.nspath_eval('mdb:contentInfo/mrc:MD_ImageDescription', self.namespaces)):
self.contentinfo.append(MD_ImageDescription(self.namespaces, contentinfo))
for contentinfo in md.findall(
util.nspath_eval('mdb:contentInfo/mrc:MD_FeatureCatalogue/mrc:featureCatalogue/gfc:FC_FeatureCatalogue',
self.namespaces)):
self.contentinfo.append(FC_FeatureCatalogue(self.namespaces, contentinfo))

val = md.find(util.nspath_eval('mdb:distributionInfo/mrd:MD_Distribution', self.namespaces))

Expand Down Expand Up @@ -1233,6 +1238,140 @@ def __init__(self, namespaces, fcd=None):
if val is not None:
self.featurecatalogues.append(val)


class FC_FeatureCatalogue(object):
"""Process gfc:FC_FeatureCatalogue"""
def __init__(self, fc=None):
if fc is None:
self.xml = None
self.identifier = None
self.name = None
self.versiondate = None
self.producer = None
self.featuretypes = []
else:
if hasattr(fc, 'getroot'): # standalone document
self.xml = etree.tostring(fc.getroot())
else: # part of a larger document
self.xml = etree.tostring(fc)

val = fc.attrib['uuid']
self.identifier = util.testXMLValue(val, attrib=True)

val = fc.find(util.nspath_eval('cat:name/gco:CharacterString', self.namespaces))
self.name = util.testXMLValue(val)

val = fc.find(util.nspath_eval('cat:versionDate/gco:Date', self.namespaces))
self.versiondate = util.testXMLValue(val)

if not self.versiondate:
val = fc.find(util.nspath_eval('cat:versionDate/gco:DateTime', self.namespaces))
self.versiondate = util.testXMLValue(val)

self.producer = None
prod = fc.find(util.nspath_eval('gfc:producer/cit:CI_Responsiblility', self.namespaces))
if prod is not None:
self.producer = CI_Responsibility(prod)

self.featuretypes = []
for i in fc.findall(util.nspath_eval('gfc:featureType/gfc:FC_FeatureType', self.namespaces)):
self.featuretypes.append(FC_FeatureType(i))

class FC_FeatureType(object):
"""Process gfc:FC_FeatureType"""
def __init__(self, ft=None):
if ft is None:
self.xml = None
self.identifier = None
self.typename = None
self.definition = None
self.isabstract = None
self.aliases = []
self.attributes = []
else:
if hasattr(ft, 'getroot'): # standalone document
self.xml = etree.tostring(ft.getroot())
else: # part of a larger document
self.xml = etree.tostring(ft)

val = ft.attrib['uuid']
self.identifier = util.testXMLValue(val, attrib=True)

val = ft.find(util.nspath_eval('gfc:typeName/gco:LocalName', self.namespaces))
self.typename = util.testXMLValue(val)

val = ft.find(util.nspath_eval('gfc:definition/gco:CharacterString', self.namespaces))
self.definition = util.testXMLValue(val)

self.isabstract = None
val = ft.find(util.nspath_eval('gfc:isAbstract/gco:Boolean', self.namespaces))
val = util.testXMLValue(val)
if val is not None:
self.isabstract = util.getTypedValue('boolean', val)

self.aliases = []
for i in ft.findall(util.nspath_eval('gfc:aliases/gco:LocalName', self.namespaces)):
self.aliases.append(util.testXMLValue(i))

self.attributes = []
for i in ft.findall(util.nspath_eval('gfc:carrierOfCharacteristics/gfc:FC_FeatureAttribute', namespaces)):
self.attributes.append(FC_FeatureAttribute(i))

class FC_FeatureAttribute(object):
"""Process gfc:FC_FeatureAttribute"""
def __init__(self, fa=None):
if fa is None:
self.xml = None
self.membername = None
self.definition = None
self.code = None
self.valuetype = None
self.listedvalues = []
else:
if hasattr(fa, 'getroot'): # standalone document
self.xml = etree.tostring(fa.getroot())
else: # part of a larger document
self.xml = etree.tostring(fa)

val = fa.find(util.nspath_eval('gfc:memberName/gco:ScopedName', self.namespaces))
self.membername = util.testXMLValue(val)

val = fa.find(util.nspath_eval('gfc:definition/gco:CharacterString', self.namespaces))
self.definition = util.testXMLValue(val)

val = fa.find(util.nspath_eval('gfc:code/gco:CharacterString', self.namespaces))
self.code = util.testXMLValue(val)

val = fa.find(util.nspath_eval('gfc:valueType/gco:TypeName/gco:aName/gco:CharacterString', self.namespaces))
self.valuetype = util.testXMLValue(val)

self.listedvalues = []
for i in fa.findall(util.nspath_eval('gfc:listedValue/gfc:FC_ListedValue', self.namespaces)):
self.listedvalues.append(FC_ListedValue(i))

class FC_ListedValue(object):
"""Process gfc:FC_ListedValue"""
def __init__(self, lv=None):
if lv is None:
self.xml = None
self.label = None
self.code = None
self.definition = None
else:
if hasattr(lv, 'getroot'): # standalone document
self.xml = etree.tostring(lv.getroot())
else: # part of a larger document
self.xml = etree.tostring(lv)

val = lv.find(util.nspath_eval('gfc:label/gco:CharacterString', self.namespaces))
self.label = util.testXMLValue(val)

val = lv.find(util.nspath_eval('gfc:code/gco:CharacterString', self.namespaces))
self.code = util.testXMLValue(val)

val = lv.find(util.nspath_eval('gfc:definition/gco:CharacterString', self.namespaces))
self.definition = util.testXMLValue(val)

class MD_ImageDescription(printable):
"""Process mrc:MD_ImageDescription
"""
Expand Down
8 changes: 8 additions & 0 deletions owslib/map/wms111.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
bind_url, nspath_eval, Authentication)
from owslib.fgdc import Metadata
from owslib.iso import MD_Metadata
from owslib.iso_3 import MD_Metadata_3
from owslib.map.common import WMSCapabilitiesReader, AbstractContentMetadata
from owslib.namespaces import Namespaces

Expand Down Expand Up @@ -617,6 +618,13 @@ def parse_remote_metadata(self, timeout=30):
if mdelem is not None:
metadataUrl['metadata'] = MD_Metadata(mdelem)
continue
else: # ISO 19115 Part 3 XML
mdelem = doc.find(
".//" + nspath_eval("mdb:MD_Metadata", n.get_namespaces(["mdb"]))
)
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata_3(mdelem)
continue
except Exception:
metadataUrl['metadata'] = None

Expand Down
9 changes: 9 additions & 0 deletions owslib/map/wms130.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
nspath_eval, bind_url, Authentication)
from owslib.fgdc import Metadata
from owslib.iso import MD_Metadata
from owslib.iso_3 import MD_Metadata_3
from owslib.crs import Crs
from owslib.namespaces import Namespaces
from owslib.map.common import WMSCapabilitiesReader, AbstractContentMetadata
Expand Down Expand Up @@ -709,6 +710,14 @@ def parse_remote_metadata(self, timeout=30):
if mdelem is not None:
metadataUrl['metadata'] = MD_Metadata(mdelem)
continue
else:
mdelem = doc.find(
".//" + nspath_eval("mdb:MD_Metadata", n.get_namespaces(["mdb"]))
)
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata_3(mdelem)
else:
metadataUrl["metadata"] = None
except Exception:
metadataUrl['metadata'] = None

Expand Down

0 comments on commit 32daa95

Please sign in to comment.