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

Avoid polygons: geopackage layer not working #114

Closed slautenb closed 4 years ago

slautenb commented 4 years ago

I used a shapefile polygon layer as the avoid polygon layer to get directions. Worked fine. Exported the shapefile to a geopackage and rerun get directions with the same settings. Got an error. Seems that the geometry is somehow lost - potentially similar to the scratch layer issue? I have used a multipolygon layer (since avoid poly seems to use only the latest polygon in the layer, not all of them) but the same issue occured then using a single polygone object

directions with geopackage layer

JSONDecodeError: Expecting value: line 1 column 1 (char 0) https://api.openrouteservice.org/v2/directions/driving-car/geojson? Parameters: { "preference": "shortest", "geometry": "true", "instructions": "false", "elevation": true, "id": 1, "options": { "avoid_polygons": null }, "coordinates": [ [ 8.960339, 48.9332 ], [ 8.964302, 48.940164 ], [ 8.964302, 48.940164 ] ] }

directions with shapefile layer

https://api.openrouteservice.org/v2/directions/driving-car/geojson? Parameters: { "preference": "shortest", "geometry": "true", "instructions": "false", "elevation": true, "id": 1, "options": { "avoid_polygons": { "coordinates": [ [ [ [ 8.963599963217254, 48.938162988202 ], [ 8.963991513405508, 48.937218946562346 ], [ 8.962446, 48.93693 ], [ 8.96138559006528, 48.93743268648382 ], [ 8.961580298132365, 48.93837691600576 ], [ 8.963599963217254, 48.938162988202 ] ] ], [ [ [ 8.960542285965213, 48.93983287840176 ], [ 8.960541635103766, 48.94065856316303 ], [ 8.960541635103766, 48.94065856316303 ], [ 8.963888, 48.94044 ], [ 8.962896, 48.938592 ], [ 8.960542285965213, 48.93983287840176 ] ] ] ], "type": "MultiPolygon" } }, "coordinates": [ [ 8.960339, 48.9332 ], [ 8.964302, 48.940164 ], [ 8.964302, 48.940164 ] ] }

nilsnolde commented 4 years ago

Oops, somehow I didn't get notified, sorry Sven. Will investigate!

nilsnolde commented 4 years ago

This is the weirdest thing:

I think that's a bug in QGIS GPKG driver: When one creates a fresh GPKG with a fresh layer and adds new features, QGIS (or GDAL) somehow assigns the first feature an FID = 1 instead of FID = 0 (as for shapefile). I wrote the dev mailing list to test the waters before opening a QGIS issue.

Anyways was a quick, backwards-compatible and future-proof fix (after hours of stupid research in the wrong direction..). You can upgrade from the QGIS plugin repo in a day or two max.

nilsnolde commented 4 years ago

Published on the official plugin repo.

nilsnolde commented 4 years ago

Opened a QGIS bug report:

https://github.com/qgis/QGIS/issues/34606