Skip to content

Commit

Permalink
Add support for ISO 19115 Part 3 XML (geopython#900)
Browse files Browse the repository at this point in the history
* Add ISO 19115 Part 3 XML parsing, including unit test

* Improved ISO 19115 Part 3 XML parsing

- Added ArcGIS synthetic sample
- Added tests for DQ_DataQuality, MD_FeatureCatalogueDescription and MD_Bands
- Ability to parse older mdb v1.0 XML

* Add iso_3 service tests

* Fix missing thesaurus keyword bug

* Add test for get_all_contacts()

* Make iso_3 DQ_DataQuality more consistent

* Fix bug in iso_3 legal constraints

* Fix iso_3 identifier resourcelanguage xpath error

* Fix xpath bug in iso_3 distribution

* Add ISO 19115 Part 3 XML gfc:FC_FeatureCatalogue

* Fix up metadata URL tests

- Some 'Offline' tests were still calling on external services, monkeypatch of 'OpenURL' not working
- Fixed up monkeypatch of 'OpenURL' calls
- Added function to detect outer tag for iso_3.py
- Added code to utilise iso_3 in WFS/WMS GetCapabilities responses
- Added ISO 19115 Part 3 XML tests using pytest parameters

* Remove redundant test file

* Add CSW geonetwork tests for iso_3.py

* Add spaces to inline comments for flake8

* Add spaces to inline comments for flake8

* Fix error in path description

* Rename 'iso_3' to 'iso3' etc.
  • Loading branch information
vjf authored Mar 23, 2024
1 parent af8b0f2 commit cdcfce7
Show file tree
Hide file tree
Showing 16 changed files with 8,196 additions and 37 deletions.
8 changes: 8 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.iso3 import MD_Metadata as MD_Metadata3 # ISO 19115 Part 3 XML
from owslib.iso3 import FC_FeatureCatalogue as FC_FeatureCatalogue3 # 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,12 @@ 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 MD_Metadata3.handles(outputschema): # ISO 19115 Part 3 XML
for elem, id in MD_Metadata3.find_ids(self._exml):
self.records[self._setidentifierkey(id)] = MD_Metadata3(elem)
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_FeatureCatalogue3(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
8 changes: 8 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.iso3 import MD_Metadata as MD_Metadata3 # ISO 19115 Part 3 XML
from owslib.iso3 import FC_FeatureCatalogue as FC_FeatureCatalogue3 # 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,12 @@ 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 MD_Metadata3.handles(outputschema): # ISO 19115 Part 3 XML
for elem, id in MD_Metadata3.find_ids(self._exml):
self.records[self._setidentifierkey(id)] = MD_Metadata3(elem)
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_FeatureCatalogue3(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
7 changes: 6 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.iso3 import MD_Metadata as MD_Metadata3 # 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,11 @@ def parse_remote_metadata(self, timeout=30):
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata(mdelem)
else:
metadataUrl["metadata"] = None
mdelem = MD_Metadata3.find_start(doc)
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata3(mdelem)
else:
metadataUrl["metadata"] = None
except Exception:
metadataUrl["metadata"] = None

Expand Down
10 changes: 7 additions & 3 deletions owslib/feature/wfs110.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
testXMLValue,
nspath_eval,
ServiceException,
Authentication,
# openURL,
Authentication
)
from owslib.etree import etree
from owslib.fgdc import Metadata
from owslib.iso import MD_Metadata
from owslib.iso3 import MD_Metadata as MD_Metadata3 # ISO 19115 Part 3 XML
from owslib.ows import (
OwsCommon,
ServiceIdentification,
Expand Down Expand Up @@ -488,6 +488,10 @@ def parse_remote_metadata(self, timeout=30):
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata(mdelem)
else:
metadataUrl["metadata"] = None
mdelem = MD_Metadata3.find_start(doc)
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata3(mdelem)
else:
metadataUrl["metadata"] = None
except Exception:
metadataUrl["metadata"] = None
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.iso3 import MD_Metadata as MD_Metadata3 # ISO 19115 Part 3 XML
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 = MD_Metadata3.find_start(doc)
if mdelem is not None:
metadataUrl["metadata"] = MD_Metadata3(mdelem)
else:
metadataUrl["metadata"] = None
continue
except Exception:
metadataUrl["metadata"] = None
Loading

0 comments on commit cdcfce7

Please sign in to comment.