[QGIS-Developer] Bug in QgsPathResolver ?

David Marteau dmarteau at 3liz.com
Fri Apr 19 06:23:43 PDT 2019


Hi devs,

I have  a strange behavior with QgsPathResolver that prevent layer to be loaded if a QgsProject read config file from relative path:

The problem has been reduced to the following behavior (pyQgis):

```
# Init a QgsPathResolver as with a relative path
pr = QgsPathResolver('./geography/data/france_parts.qgs')

pr.readPath('./france_parts/france_parts.shp')
# Output -> '/geography/data/france_parts/france_parts.shp' 
# Note the leading '/'
```

Worst:
```
pr = QgsPathResolver('../geography/data/france_parts.qgs')

pr.readPath('./france_parts/france_parts.shp')
# Output -> '/../geography/data/france_parts/france_parts.shp' 
# which is a meaningless path
```

The side effect is that if you do:
```
prj = QgsProject()
prj.read("./geography/data/france_parts.qgs")
```
then you get the error:
```
Qgis OGR: Cannot open /geography/data/france_parts/france_parts.shp.()
Qgis : 1 unavailable layers found:
Qgis :  * ./france_parts/france_parts.shp
```

This is with Qgis 3.6.1

Can anybody confirm that this behavior is a bug ? I will submit a PR  if this is the case.
Thanks,

Cheers
David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190419/90148850/attachment-0001.html>


More information about the QGIS-Developer mailing list