Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add FlatGeobuf as known input format
(cherry picked from commit 150709c)
  • Loading branch information
bjornharrtell authored and nyalldawson committed Nov 21, 2019
1 parent b39bd70 commit be91de9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -2907,6 +2907,14 @@ QString createFilters( const QString &type )
if ( !sDirectoryExtensions.contains( QStringLiteral( "gdb" ) ) )
sDirectoryExtensions << QStringLiteral( "gdb" );
}
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,1,0)
else if ( driverName.startsWith( QLatin1String( "FlatGeobuf" ) ) )
{
sProtocolDrivers += QLatin1String( "FlatGeobuf;" );
sFileFilters += createFileFilter_( QObject::tr( "FlatGeobuf" ), QStringLiteral( "*.fgb" ) );
sExtensions << QStringLiteral( "fgb" );
}
#endif
else if ( driverName.startsWith( QLatin1String( "PGeo" ) ) )
{
sDatabaseDrivers += QObject::tr( "ESRI Personal GeoDatabase" ) + ",PGeo;";
Expand Down Expand Up @@ -4454,14 +4462,23 @@ void QgsOgrProvider::open( OpenMode mode )
QgsDebugMsg( QStringLiteral( "OGR failed to opened in update mode, trying in read-only mode" ) );
}

QStringList options;
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,1,0)
// assume trusted data to get more speed
if ( mGDALDriverName == QLatin1String( "FlatGeobuf" ) )
{
options << "VERIFY_BUFFERS=NO"
}
#endif

// try to open read-only
if ( !mLayerName.isNull() )
{
mOgrOrigLayer = QgsOgrProviderUtils::getLayer( mFilePath, false, QStringList(), mLayerName, errCause, true );
mOgrOrigLayer = QgsOgrProviderUtils::getLayer( mFilePath, false, options, mLayerName, errCause, true );
}
else
{
mOgrOrigLayer = QgsOgrProviderUtils::getLayer( mFilePath, false, QStringList(), mLayerIndex, errCause, true );
mOgrOrigLayer = QgsOgrProviderUtils::getLayer( mFilePath, false, options, mLayerIndex, errCause, true );
}
}

Expand Down

0 comments on commit be91de9

Please sign in to comment.