geopython / OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
https://owslib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
381 stars 273 forks source link

provide option to not clean ows url? #888

Closed smnorris closed 1 year ago

smnorris commented 1 year ago

I'm using a WFS with this getcapabilites endpoint: http://openmaps.gov.bc.ca/geo/pub/ows?service=WFS&version=2.0.0&request=Getcapabilities

Curiously, it does not return valid WFS capabilities when called with this very slightly different url (note the capital Capabilites): http://openmaps.gov.bc.ca/geo/pub/ows?service=WFS&version=2.0.0&request=GetCapabilities

I've alerted the provider but cannot currently use owslib with this service because the url gets cleaned: https://github.com/geopython/OWSLib/blob/master/owslib/util.py#L709

Does owslib need to always strip service/version/request params from the url before making the getcapabilites request? It does seem like they might be expected when building the capabilities url: https://github.com/geopython/OWSLib/blob/master/owslib/feature/common.py#L23

>>> from owslib.wfs import WebFeatureService
>>> wfs = WebFeatureService("http://openmaps.gov.bc.ca/geo/pub/ows?service=WFS&request=Getcapabilities", version="2.0.0")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/snorris/Projects/repo/owslib/OWSLib/owslib/wfs.py", line 57, in WebFeatureService
    return wfs200.WebFeatureService_2_0_0(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/snorris/Projects/repo/owslib/OWSLib/owslib/feature/wfs200.py", line 77, in __new__
    obj.__init__(
  File "/Users/snorris/Projects/repo/owslib/OWSLib/owslib/feature/wfs200.py", line 130, in __init__
    self._buildMetadata(parse_remote_metadata)
  File "/Users/snorris/Projects/repo/owslib/OWSLib/owslib/feature/wfs200.py", line 165, in _buildMetadata
    for elem in self._capabilities.find(nspath("OperationsMetadata"))[:]:
smnorris commented 1 year ago

figured out the workaround:

from owslib.feature import wfs200
wfs200.WebFeatureService_2_0_0(
    "http://openmaps.gov.bc.ca/geo/pub/ows?service=WFS&request=Getcapabilities", 
    "2.0.0",
    None,
    False)