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
95 stars 31 forks source link

IndexError: list index out of range #8

Closed hoge6b01 closed 7 years ago

hoge6b01 commented 7 years ago

Hi, performing an accessibility calculation I always get a python error. It happens if I use the 'Map now!' (with a sligthly different error msg) and when using a point layer.

As the error's result one gets a broken dissolve layer with one entry only.

If you need further clearification please let me know. BR

`Ein Fehler trat bei der Ausführung von Python-Code auf:

IndexError: list index out of range Traceback (most recent call last): File "C:/Users/USERNAME/.qgis2/python/plugins\OSMtools\osm_tools_access.py", line 243, in pointAnalysis self.dissolveFields(layer_out, fields_diss) File "C:/Users/USERNAME/.qgis2/python/plugins\OSMtools\osm_tools_access.py", line 308, in dissolveFields layer_dissolved = QgsMapLayerRegistry.instance().mapLayersByName("Dissolved")[-1] IndexError: list index out of range

Python-Version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] QGIS-Version: 2.18.6 Las Palmas, 5f369b0 `

nilsnolde commented 7 years ago

Hi, in both cases (button and layer) you have 'Use Layer' and 'Dissolve Output' checked?

I´ll try to reproduce later, API seems to down right now..

Cheers Nils

nilsnolde commented 7 years ago

Sorry, can´t reproduce here, no matter how I do it.

If you run the 'Dissolve' tool on a random layer, what is the the output layer called? Might be, that this is a language specific thing. I´m looking for layers called 'Dissolved' and rename them. If your language pack calls it smth else, this could crash.

Cheers Nils

hoge6b01 commented 7 years ago

Well, I changed language to english and tried it again. Same error. If I use QGIS' Dissolve tool it names the layer 'Dissolved'.

So what I did: I created a point layer (EPSG 4326) and calculated areas (max 15 min; intervals 5 min). Result is a layer ''AA_driving-car" and there are three areas for each location - correct. The resulting layer for the dissolve called "memory:dissolved" only contains the dissolved areas for the 15 min drive-time. 5 min and 10 min are missing. It even creates a "memory:dissolve" layer when "dissolve output" is not activated.

I am not a programmer but I am asking myself if '-1' is a valid list index: layer_dissolved = QgsMapLayerRegistry.instance().mapLayersByName("Dissolved")[-1] IndexError: list index out of range

What else can I provide to get this problem solved?

nilsnolde commented 7 years ago

Hi,

no worries, '-1' is used to index the last element in a list, it´s entirely fine.

Let me talk to the ORS guys, I think, the 'Dissolve' feature is obsolete anyways. Before the revamp of the API, the accessibility areas were Multipolygons with lots of holes, now they seem to be very consistently single polygons. But I need to confirm this before taking it out.

Will keep you posted Nils

nilsnolde commented 7 years ago

Looks like the 'dissolve' option can be removed: link to google groups

And you´re right, dissolve happens in any case as of now. Honestly, I can´t remember why I put it in as (fake) optional. The code will apparently always dissolve the polygons on the "AA_Mins" field. Since this is now obsolete, I´ll remove those lines and post a new version sometime this week.

It´s still weird that your installation does something mine doesn´t, but unless we do a Teamviewer session, this is hard to resolve. Let´s see what happens after I fixed it.

hoge6b01 commented 7 years ago

Okay, I tried it on a clean install on different computer. I experienced no problems with that install. Guess the other installation of QGIS is just broken. Thanks for having a deeper look into the programm. Sorry for bothering. And thanks also for your information about the dissolve option. BR

nilsnolde commented 7 years ago

Hi, for anyone still experiencing this issue, here is a new build with the 'dissolve' option removed: osm_tools_v0.2_GUIscrollbar_Nodi

hoge6b01 commented 7 years ago

Perfect. No error anymore. Thank you!