Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show some more warnings when spatial indexes are missing but desirable
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Jul 30, 2020
1 parent 46ebfaf commit 0efd579
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/qgis/SpatialJoinSummary.py
Expand Up @@ -35,6 +35,7 @@
QgsFeatureSink,
QgsFeatureRequest,
QgsGeometry,
QgsFeatureSource,
QgsCoordinateTransform,
QgsStatisticalSummary,
QgsDateTimeStatisticalSummary,
Expand Down Expand Up @@ -160,6 +161,9 @@ def processAlgorithm(self, parameters, context, feedback):
if join_source is None:
raise QgsProcessingException(self.invalidSourceError(parameters, self.JOIN))

if join_source.hasSpatialIndex() == QgsFeatureSource.SpatialIndexNotPresent:
feedback.reportError(self.tr("No spatial index exists for join layer, performance will be severely degraded"))

join_fields = self.parameterAsFields(parameters, self.JOIN_FIELDS, context)
discard_nomatch = self.parameterAsBoolean(parameters, self.DISCARD_NONMATCHING, context)
summaries = [self.statistics[i][0] for i in
Expand Down
3 changes: 3 additions & 0 deletions src/analysis/processing/qgsalgorithmclip.cpp
Expand Up @@ -96,6 +96,9 @@ QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap &parameters, Q
if ( !maskSource )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "OVERLAY" ) ) );

if ( featureSource->hasSpatialIndex() == QgsFeatureSource::SpatialIndexNotPresent )
feedback->reportError( QObject::tr( "No spatial index exists for input layer, performance will be severely degraded" ) );

QString dest;
QgsWkbTypes::GeometryType sinkType = QgsWkbTypes::geometryType( featureSource->wkbType() );
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, featureSource->fields(), QgsWkbTypes::multiType( featureSource->wkbType() ), featureSource->sourceCrs() ) );
Expand Down
3 changes: 3 additions & 0 deletions src/analysis/processing/qgsalgorithmextractbyextent.cpp
Expand Up @@ -70,6 +70,9 @@ QVariantMap QgsExtractByExtentAlgorithm::processAlgorithm( const QVariantMap &pa
if ( !featureSource )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) );

if ( featureSource->hasSpatialIndex() == QgsFeatureSource::SpatialIndexNotPresent )
feedback->reportError( QObject::tr( "No spatial index exists for input layer, performance will be severely degraded" ) );

QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context, featureSource->sourceCrs() );
bool clip = parameterAsBoolean( parameters, QStringLiteral( "CLIP" ), context );

Expand Down

0 comments on commit 0efd579

Please sign in to comment.