Skip to content
Permalink
Browse files

Use GDAL metadata to determine non-spatial formats (gdal >=2.3 only)

  • Loading branch information
nyalldawson committed Dec 11, 2017
1 parent 135ba69 commit 73eec6f9987d6ce5a018ee87eb4c89c8a8a14962
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/core/qgsvectorfilewriter.cpp
@@ -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;
}

0 comments on commit 73eec6f

Please sign in to comment.
You can’t perform that action at this time.