[QGIS-Developer] QBrowser, QgsGdalLayerItems, QgsOgrLayerItems and non valid layers

Even Rouault even.rouault at spatialys.com
Fri Jul 7 04:11:15 PDT 2017


On vendredi 7 juillet 2017 12:44:00 CEST Richard Duivenvoorde wrote:
> Hi Devs,
> 
> using the Qbrowser-widget (and new load it all button) here.
> In my testdata directory it is showing some (GDAL) layers as layers, but
> upon loading they fail.
> 
> Some examples:
> - /initrd.img
> ERROR 4: `/initrd.img' not recognized as a supported file format.
> - a prov.gpkg throws errors but shows it as a raster file:
> ERROR 4: `/home/richard/geodata/prov.gpkg' not recognized as a supported
> file format.
> The same by the way for OGR layers like pdf which appear as vectors.
> 
> Trying to look into it, I see that in the QgsGdalLayerItem constructor
> QGIS tries top use GDALOpen on those files, and acutally failing!

If QGIS is setup to look at file content and not just extension, this shouldn't happen
since the instanciation of a QgsGdalLayerItem is done at
https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdaldataitems.cpp#L287
after the check at
https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdaldataitems.cpp#L272

So what I suspect here is that your QGIS is setup to only look at extensions,
which is the default setting I think.

See 
https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdaldataitems.cpp#L145
and then
https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdaldataitems.cpp#L239

And so for drivers that have both raster&vector capabilities, a file will appear twice. Probably
this logic should be amended for dual capabiiity drivers like GPKG and PDF. Actually L246 shows
a particular case for VRT. But I think this logic is now invalid since GDAL 2.0, since
GDALIdentifyDriver() will now retun "VRT" for a raster VRT, and "OGR_VRT" for a vector VRT (in GDAL 1.X
era GDALIdentifyDriver() only worked on raster drivers)

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170707/b56f2940/attachment.html>


More information about the QGIS-Developer mailing list