Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch WMTS fails in Python Console (with owslib) but works through QGIS widget #24243

Closed
qgib opened this issue Mar 9, 2017 · 2 comments
Closed
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins

Comments

@qgib
Copy link
Contributor

qgib commented Mar 9, 2017

Author Name: geo julien (@Guts)
Original Redmine Issue: 16333
Affected QGIS version: 2.14.12
Redmine category:python_plugins
Assignee: Tom Kralidis


I'm working on my plugin which can add layers from OGC services directly to Map canvas without UI step. So I use owslib with PyQGIS. Trying various WMTS sample (check my script here: https://github.com/isogeo/isogeo-plugin-qgis/blob/master/test/test_wmts.py), I've found a WMTS that works through QGIS integrated widget but not from owslib (see attached screen capture), but not from Python script.

Just with version parameter (I know, quite useless but...):

wmts = WebMapTileService("http://data.geus.dk/arcgis/rest/services/OneGeologyGlobal/S071_G2500_OneGeology/MapServer/WMTS?request=GetCapabilities", version="1.0.0")
Traceback (most recent call last):
  File "", line 1, in 
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\wmts.py", line 114, in __init__
    self._buildMetadata(parse_remote_metadata)
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\wmts.py", line 133, in _buildMetadata
    self.provider=ServiceProvider(serviceprov)
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\ows.py", line 78, in __init__
    val = self._root.find(util.nspath('ProviderName', namespace))
AttributeError: 'NoneType' object has no attribute 'find'

```


With full parameters:

wmts = WebMapTileService("http://data.geus.dk/arcgis/rest/services/OneGeologyGlobal/S071_G2500_OneGeology/MapServer/WMTS?request=GetCapabilities", version="1.0.0", parse_remote_metadata=0, xml="http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS/1.0.0/WMTSCapabilities.xml")
Traceback (most recent call last):
  File "", line 1, in 
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\wmts.py", line 102, in __init__
    self._capabilities = reader.readString(xml)
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\wmts.py", line 649, in readString
    return etree.fromstring(st)
  File "C:\\OSGEO4~1\\apps\\Python27\\lib\\xml\\etree\\ElementTree.py", line 1300, in XML
    parser.feed(text)
  File "C:\\OSGEO4~1\\apps\\Python27\\lib\\xml\\etree\\ElementTree.py", line 1642, in feed
    self._raiseerror(v)
  File "C:\\OSGEO4~1\\apps\\Python27\\lib\\xml\\etree\\ElementTree.py", line 1506, in _raiseerror
    raise err
ParseError: not well-formed (invalid token): line 1, column 5

```

Pointing only on the XML:

```
wmts = WebMapTileService("http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS/1.0.0/WMTSCapabilities.xml")
Traceback (most recent call last):
  File "", line 1, in 
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\wmts.py", line 114, in __init__
    self._buildMetadata(parse_remote_metadata)
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\wmts.py", line 133, in _buildMetadata
    self.provider=ServiceProvider(serviceprov)
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\\owslib\\ows.py", line 78, in __init__
    val = self._root.find(util.nspath('ProviderName', namespace))
AttributeError: 'NoneType' object has no attribute 'find'


```

Behaviors should be the same, no? (sincere question)

---

- [qgis_214_osgeo4w_owslib_wmts.png](https://issues.qgis.org/attachments/download/10822/qgis_214_osgeo4w_owslib_wmts.png) (geo julien)
@qgib
Copy link
Contributor Author

qgib commented Mar 9, 2017

Author Name: Tom Kralidis (@tomkralidis)


Suggest opening this as a pure OWSLib ticket (https://github.com/OWSLib/issues/new)


  • resolution was changed from to up/downstream
  • status_id was changed from Open to Closed

@qgib
Copy link
Contributor Author

qgib commented Mar 9, 2017

Author Name: geo julien (@Guts)


Done: geopython/OWSLib#361.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins labels May 25, 2019
@qgib qgib closed this as completed May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins
Projects
None yet
Development

No branches or pull requests

1 participant