Skip to content
Permalink
Browse files

Implement spatial index detection for OGR provider

Provides warnings in Processing algorithms when running on layers
which don't have a spatial index present (e.g. geojson files) and
where performance will be severely hurt as a result

Fixes #30530

(cherry picked from commit f20801a)
  • Loading branch information
nyalldawson committed May 20, 2020
1 parent a3530fa commit f552a98b54146f49fc3ee3cb14368a16994de7f8
Showing with 11 additions and 0 deletions.
  1. +10 −0 src/core/providers/ogr/qgsogrprovider.cpp
  2. +1 −0 src/core/providers/ogr/qgsogrprovider.h
@@ -3827,6 +3827,16 @@ QStringList QgsOgrProvider::uniqueStringsMatching( int index, const QString &sub
return results;
}

QgsFeatureSource::SpatialIndexPresence QgsOgrProvider::hasSpatialIndex() const
{
if ( mOgrLayer && mOgrLayer->TestCapability( OLCFastSpatialFilter ) )
return QgsFeatureSource::SpatialIndexPresent;
else if ( mOgrLayer )
return QgsFeatureSource::SpatialIndexNotPresent;
else
return QgsFeatureSource::SpatialIndexUnknown;
}

QVariant QgsOgrProvider::minimumValue( int index ) const
{
if ( !mValid || index < 0 || index >= mAttributeFields.count() )
@@ -143,6 +143,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
QSet< QVariant > uniqueValues( int index, int limit = -1 ) const override;
QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
QgsFeedback *feedback = nullptr ) const override;
QgsFeatureSource::SpatialIndexPresence hasSpatialIndex() const override;

QString name() const override;
static QString providerKey();

0 comments on commit f552a98

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