Skip to content

Commit 73eec6f

Browse files
committedDec 11, 2017
Use GDAL metadata to determine non-spatial formats (gdal >=2.3 only)
1 parent 135ba69 commit 73eec6f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎src/core/qgsvectorfilewriter.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,13 +2715,26 @@ QList< QgsVectorFileWriter::FilterFormatDetails > QgsVectorFileWriter::supported
27152715
if ( drv )
27162716
{
27172717
QString drvName = OGR_Dr_GetName( drv );
2718+
2719+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,3,0)
2720+
GDALDriverH gdalDriver = GDALGetDriverByName( drvName.toLocal8Bit().constData() );
2721+
char **driverMetadata = nullptr;
2722+
if ( gdalDriver )
2723+
{
2724+
driverMetadata = GDALGetMetadata( gdalDriver, nullptr );
2725+
}
2726+
2727+
bool nonSpatialFormat = nonSpatialFormat = CSLFetchBoolean( driverMetadata, GDAL_DCAP_NONSPATIAL, false );
2728+
#else
2729+
bool nonSpatialFormat = ( drvName == QLatin1String( "ODS" ) || drvName == QLatin1String( "XLSX" ) || drvName == QLatin1String( "XLS" ) );
2730+
#endif
2731+
27182732
if ( OGR_Dr_TestCapability( drv, "CreateDataSource" ) != 0 )
27192733
{
27202734
if ( options & SkipNonSpatialFormats )
27212735
{
27222736
// skip non-spatial formats
2723-
// TODO - use GDAL metadata to determine this, when support exists in GDAL
2724-
if ( drvName == QLatin1String( "ODS" ) || drvName == QLatin1String( "XLSX" ) || drvName == QLatin1String( "XLS" ) )
2737+
if ( nonSpatialFormat )
27252738
continue;
27262739
}
27272740

0 commit comments

Comments
 (0)
Please sign in to comment.