GIScience / orstools-qgis-plugin

Plugin for QGIS with a set of tools to use openrouteservice API´s, based on openstreetmap
https://plugins.qgis.org/plugins/ORStools/
MIT License
92 stars 31 forks source link

Python error on running isochrone #77

Closed GitHubMLee closed 5 years ago

GitHubMLee commented 5 years ago

Here's what I did

I am running QGIS 3.4.1 and have updated and reinstalled the OSMTools plugin.

I created a point layer with one object.

I then ran the tool, set an isochrone range in minutes (in my case 15), and used my layer as the 'Point layer' source.

Other details:

The point layer is in EPSG:2193 (New Zealand Transverse Mercator 2000)


Here's what I got

Python error as follows:

2018-11-23T15:14:56 WARNING Traceback (most recent call last): File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\gui\OSMtoolsDialog.py", line 103, in run iso.isochrones_calc() File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\core\isochrones.py", line 121, in isochrones_calc responses.append(self.client.request(self.url, self.params)) File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\core\client.py", line 180, in request result = self._get_body(response) File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\core\client.py", line 212, in _get_body error['message']) TypeError: string indices must be integers

Stack trace as follows:

TypeError: string indices must be integers Traceback (most recent call last): File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\gui\OSMtoolsDialog.py", line 103, in run iso.isochrones_calc() File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\core\isochrones.py", line 121, in isochrones_calc responses.append(self.client.request(self.url, self.params)) File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\core\client.py", line 180, in request result = self._get_body(response) File "C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\core\client.py", line 212, in _get_body error['message']) TypeError: string indices must be integers

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] QGIS version: 3.4.1-Madeira Madeira, 383851c597

Python Path: C:/PROGRA~1/QGIS3~1.4/apps/qgis/./python C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA~1/QGIS3~1.4/apps/qgis/./python/plugins C:\Program Files\QGIS 3.4\bin\python37.zip C:\PROGRA~1\QGIS3~1.4\apps\Python37\DLLs C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib C:\Program Files\QGIS 3.4\bin C:\PROGRA~1\QGIS3~1.4\apps\Python37 C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\win32 C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\win32\lib C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\Pythonwin C:/XXXX/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:\XXXX\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\mmqgis/forms H:/

GitHubMLee commented 5 years ago

Also note that I tried to run the same process using WGS84 CRS (ie EPSG 4326) with same result

nilsnolde commented 5 years ago

So sorry for the late reply.. Not been watching for a while.

Can you give me the coordinate pls?

BTW, the Here's what I got section tells you to paste the request from the Python console. That helps me in tracking down backend issues.

I just tried a few coordinates in New Zealand and in the worst case, it gives me a 500 error, but it's sorta handled, Python doesn't crash for me.

GitHubMLee commented 5 years ago

Apologies for not including python console text. I have performed the same request (same error) and the console shows this...

Python Console Use iface to access QGIS API interface or Type help(iface) for more info Security warning: typing commands from an untrusted source can lead to data loss and/or leak url: https://api.openrouteservice.org/isochrones?id=0&locations=174.60847%2C-36.81121&profile=driving-car&range=900&range_type=time&api_key=58d904a497c67e00015b45fceee5826e9d92437a96ddffcb4bb3b7b8 Parameters: {'headers': {'User-Agent': 'ORSClientQGISv3.2', 'Content-type': 'application/json'}}

The actual coordinate (in WGS 84) is 174.60847,-36.81121 - the tool seems to be parsing the comma as %2C for some reason.

GitHubMLee commented 5 years ago

I've played around and tested on the openrouteservice website. I think it was a problem with my token - I deleted it and created a new one and now it works ok!

nilsnolde commented 5 years ago

Yep. You only have to paste the full URL in the browser and you'll get an answer. Unfortunately, the error message is a little cryptic atm. We'll fix that.

But yes, that's your token being invalid for some reason. Good that you were able to fix that:)

Anyways, the plugin shouldn't crash. The lovely backenders keep shuffling around error codes and it's hard to keep up (actually impossible, they wouldn't say anything when they do change them). So, thanks for the pointer, a fix is on the way.