OWSLib icon indicating copy to clipboard operation
OWSLib copied to clipboard

get_observation fails with Exception

Open cdaller opened this issue 3 years ago • 1 comments

PR https://github.com/geopython/OWSLib/pull/741 breaks the code:

Example

#!/usr/bin/python3

from owslib.sos import SensorObservationService

service = SensorObservationService('http://sensorweb.demo.52north.org/52n-sos-webapp/sos/kvp', version='2.0.0')

offering = 'ws2500'
observedProperty = 'AirTemperature'

get_obs = service.get_operation_by_name('GetObservation')
response = service.get_observation(responseFormat='http://www.opengis.net/om/2.0', offerings=[offering],
                                   observedProperties=[observedProperty])

Results in

Traceback (most recent call last):
  File "/Users/xxxx/testrequest.py", line 11, in <module>
    response = service.get_observation(responseFormat='http://www.opengis.net/om/2.0', offerings=[offering],
  File "/Library/Python/3.8/site-packages/owslib/swe/observation/sos200.py", line 205, in get_observation
    response = openURL(base_url, request, method,
  File "/Library/Python/3.8/site-packages/owslib/util.py", line 200, in openURL
    rkwargs['params'] = unquote(data) if data else None
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/urllib/parse.py", line 635, in unquote
    string.split
AttributeError: 'dict' object has no attribute 'split'

The problem is that the unquote call in utils.py line 200 throws an exception if the data argument is a dict. Which is the case in the get_observation call.

cdaller avatar Jul 07 '21 12:07 cdaller

Still open... I had to remove the "unquote" to make it work with SOS.

jsanchezfr avatar Nov 19 '21 09:11 jsanchezfr