[processing] Show some more warnings when spatial indexes are missing but desirable

This commit is contained in:
Nyall Dawson 2020-07-30 19:29:44 +10:00
parent 8cbafe7a44
commit fd19167c0a
3 changed files with 10 additions and 0 deletions

View File

@ -35,6 +35,7 @@ from qgis.core import (NULL,
QgsFeatureSink, QgsFeatureSink,
QgsFeatureRequest, QgsFeatureRequest,
QgsGeometry, QgsGeometry,
QgsFeatureSource,
QgsCoordinateTransform, QgsCoordinateTransform,
QgsStatisticalSummary, QgsStatisticalSummary,
QgsDateTimeStatisticalSummary, QgsDateTimeStatisticalSummary,
@ -160,6 +161,9 @@ class SpatialJoinSummary(QgisAlgorithm):
if join_source is None: if join_source is None:
raise QgsProcessingException(self.invalidSourceError(parameters, self.JOIN)) 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) join_fields = self.parameterAsFields(parameters, self.JOIN_FIELDS, context)
discard_nomatch = self.parameterAsBoolean(parameters, self.DISCARD_NONMATCHING, context) discard_nomatch = self.parameterAsBoolean(parameters, self.DISCARD_NONMATCHING, context)
summaries = [self.statistics[i][0] for i in summaries = [self.statistics[i][0] for i in

View File

@ -96,6 +96,9 @@ QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap &parameters, Q
if ( !maskSource ) if ( !maskSource )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "OVERLAY" ) ) ); 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; QString dest;
QgsWkbTypes::GeometryType sinkType = QgsWkbTypes::geometryType( featureSource->wkbType() ); 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() ) ); std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, featureSource->fields(), QgsWkbTypes::multiType( featureSource->wkbType() ), featureSource->sourceCrs() ) );

View File

@ -70,6 +70,9 @@ QVariantMap QgsExtractByExtentAlgorithm::processAlgorithm( const QVariantMap &pa
if ( !featureSource ) if ( !featureSource )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) ); 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() ); QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context, featureSource->sourceCrs() );
bool clip = parameterAsBoolean( parameters, QStringLiteral( "CLIP" ), context ); bool clip = parameterAsBoolean( parameters, QStringLiteral( "CLIP" ), context );