Skip to content
Permalink
Browse files

Create spatial index support for spatialite connections

  • Loading branch information
nyalldawson committed Mar 16, 2020
1 parent 97e47fa commit 2dc4329f19316482aad05cc1b83a1fa7603e6df9
@@ -196,6 +196,17 @@ void QgsSpatiaLiteProviderConnection::vacuum( const QString &schema, const QStri
executeSqlDirect( QStringLiteral( "VACUUM" ) );
}

void QgsSpatiaLiteProviderConnection::createSpatialIndex( const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options ) const
{
Q_UNUSED( name )
checkCapability( Capability::Vacuum );
if ( ! schema.isEmpty() )
{
QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::Info );
}
executeSqlPrivate( QStringLiteral( "SELECT CreateSpatialIndex(%1, %2)" ).arg( QgsSqliteUtils::quotedString( name ),
QgsSqliteUtils::quotedString( ( options.geometryColumnName ) ) ) );
}

QList<QgsSpatiaLiteProviderConnection::TableProperty> QgsSpatiaLiteProviderConnection::tables( const QString &schema, const TableFlags &flags ) const
{
@@ -334,6 +345,7 @@ void QgsSpatiaLiteProviderConnection::setDefaultCapabilities()
Capability::Spatial,
Capability::TableExists,
Capability::ExecuteSql,
Capability::CreateSpatialIndex,
};
}

@@ -40,6 +40,7 @@ class QgsSpatiaLiteProviderConnection : public QgsAbstractDatabaseProviderConnec
void renameVectorTable( const QString &schema, const QString &name, const QString &newName ) const override;
QList<QList<QVariant>> executeSql( const QString &sql ) const override;
void vacuum( const QString &schema, const QString &name ) const override;
void createSpatialIndex( const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options = QgsAbstractDatabaseProviderConnection::SpatialIndexOptions() ) const override;
QList<QgsAbstractDatabaseProviderConnection::TableProperty> tables( const QString &schema = QString(),
const TableFlags &flags = nullptr ) const override;
QIcon icon() const override;

0 comments on commit 2dc4329

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