Feature request #12101

Try user-selected GDAL/OGR driver first when loading a layer

Added by Larry Shaffer about 9 years ago. Updated almost 7 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Data Provider
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:20296

Description

QGIS always relies upon the GDAL/OGR driver selection when loading a file, e.g. as is coded in the OGR provider. In that code, no specific driver is set when asking GDAL/OGR to open a data source. Then QGIS has a reference to what GDAL/OGR driver was chosen:

"OGR opened using Driver " + QString( OGR_Dr_GetName( ogrDriver ) )

But... a user has no run-time control over which driver should be tried first.

The listing of available drivers, used to generate the drop-down menus in QGIS for adding a layer, e.g. Add Vector Layer dialog, and the order in which GDAL/OGR drivers prioritize opening files are mutually exclusive. Essentially, as in the Add Vector Layer dialog, the found GDAL/OGR drivers are merely used for registering available file extension filters for the Open File dialogs. However, the listing ostensibly indicates to the user that they are selecting the driver to use to open a particular file, which is not the case. This causes user confusion.

Example: FileGDB and OpenFileGDB can both open files with .gdb extension, but if your .gdb file is version 9.x, FileGDB will attempt to load the file first (and fail, because that version is unsupported), regardless of whether the user actually selected OpenFileGDB in the dialog to presumably open the file with. Only removing the FileGDB plugin or using OGR_SKIP prior to launching QGIS will help fix the issue, and allow OpenFileGDB to try opening the file. The user has no clue that a completely different driver is actually being used.

Conversely, there is no user pre-selection of driver when doing drag-drop or selection within the browser panel for adding a file. Those file loads are purely extension-based and QGIS relies upon GDAL/OGR driver selection process for those as well. QGIS does have a GUI means of managing this issue for GDAL (in Options -> GDAL), but there is no twin dialog for OGR, yet. See Issue #10313.

QGIS can be updated to try loading a GDAL/OGR layer using a specific provider, regardless of how many registered drivers can open the same file. This can be overcome at the C-API level, when calling GDAL/OGR to open a file/directory, by explicitly telling it what driver to use.

OGRSFDriverH ogrDriver = OGRGetDriverByName( "FileGDB" );
ogrDataSource = OGROpen( TO8F( mFilePath ), true, &ogrDriver );

Seems to me, the process can be refined to:

  • Try specific driver, if it is indicated by user (like when using the Add Vector Layer dialog)
  • If specific driver failed to open file, drop back to current behavior of having GDAL/OGR auto-select driver

Related issues

Related to QGIS Application - Feature request #10313: List of available OGR drivers Open 2014-05-20

History

#1 Updated by Giovanni Manghi almost 7 years ago

  • Easy fix? set to No

Also available in: Atom PDF