Skip to content

Commit

Permalink
Use GDAL metadata to determine non-spatial formats (gdal >=2.3 only)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 11, 2017
1 parent 135ba69 commit 73eec6f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -2715,13 +2715,26 @@ QList< QgsVectorFileWriter::FilterFormatDetails > QgsVectorFileWriter::supported
if ( drv )
{
QString drvName = OGR_Dr_GetName( drv );

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,3,0)
GDALDriverH gdalDriver = GDALGetDriverByName( drvName.toLocal8Bit().constData() );
char **driverMetadata = nullptr;
if ( gdalDriver )
{
driverMetadata = GDALGetMetadata( gdalDriver, nullptr );
}

bool nonSpatialFormat = nonSpatialFormat = CSLFetchBoolean( driverMetadata, GDAL_DCAP_NONSPATIAL, false );
#else
bool nonSpatialFormat = ( drvName == QLatin1String( "ODS" ) || drvName == QLatin1String( "XLSX" ) || drvName == QLatin1String( "XLS" ) );
#endif

if ( OGR_Dr_TestCapability( drv, "CreateDataSource" ) != 0 )
{
if ( options & SkipNonSpatialFormats )
{
// skip non-spatial formats
// TODO - use GDAL metadata to determine this, when support exists in GDAL
if ( drvName == QLatin1String( "ODS" ) || drvName == QLatin1String( "XLSX" ) || drvName == QLatin1String( "XLS" ) )
if ( nonSpatialFormat )
continue;
}

Expand Down

0 comments on commit 73eec6f

Please sign in to comment.