Skip to content
Permalink
Browse files

[processing] Remove some unrequired geometry checks

  • Loading branch information
m-kuhn authored and nyalldawson committed Apr 9, 2018
1 parent 5b7b7be commit 925d9af93f014bb2d754c866da708df2947880a4
@@ -83,7 +83,7 @@ QgsExtractByAttributeAlgorithm *QgsExtractByAttributeAlgorithm::createInstance()

QVariantMap QgsExtractByAttributeAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
std::unique_ptr< QgsFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( !source )
throw QgsProcessingException( QObject::tr( "Could not load source layer for INPUT" ) );

@@ -187,7 +187,7 @@ QVariantMap QgsExtractByAttributeAlgorithm::processAlgorithm( const QVariantMap
req.setFilterExpression( expr );
req.setExpressionContext( expressionContext );

QgsFeatureIterator it = source->getFeatures( req );
QgsFeatureIterator it = source->getFeatures( req, QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks );
QgsFeature f;
while ( it.nextFeature( f ) )
{
@@ -208,7 +208,7 @@ QVariantMap QgsExtractByAttributeAlgorithm::processAlgorithm( const QVariantMap
expressionContext.setFields( source->fields() );
expression.prepare( &expressionContext );

QgsFeatureIterator it = source->getFeatures();
QgsFeatureIterator it = source->getFeatures( QgsFeatureRequest(), QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks );
QgsFeature f;
while ( it.nextFeature( f ) )
{
@@ -70,7 +70,7 @@ QgsExtractByExpressionAlgorithm *QgsExtractByExpressionAlgorithm::createInstance

QVariantMap QgsExtractByExpressionAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
std::unique_ptr< QgsFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( !source )
throw QgsProcessingException( QObject::tr( "Could not load source layer for INPUT" ) );

@@ -106,7 +106,7 @@ QVariantMap QgsExtractByExpressionAlgorithm::processAlgorithm( const QVariantMap
req.setFilterExpression( expressionString );
req.setExpressionContext( expressionContext );

QgsFeatureIterator it = source->getFeatures( req );
QgsFeatureIterator it = source->getFeatures( req, QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks );
QgsFeature f;
while ( it.nextFeature( f ) )
{
@@ -93,8 +93,8 @@ QVariantMap QgsJoinByAttributeAlgorithm::processAlgorithm( const QVariantMap &pa
int joinMethod = parameterAsEnum( parameters, QStringLiteral( "METHOD" ), context );
bool discardNonMatching = parameterAsBool( parameters, QStringLiteral( "DISCARD_NONMATCHING" ), context );

std::unique_ptr< QgsFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
std::unique_ptr< QgsFeatureSource > input2( parameterAsSource( parameters, QStringLiteral( "INPUT_2" ), context ) );
std::unique_ptr< QgsProcessingFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
std::unique_ptr< QgsProcessingFeatureSource > input2( parameterAsSource( parameters, QStringLiteral( "INPUT_2" ), context ) );
if ( !input || !input2 )
throw QgsProcessingException( QObject::tr( "Could not load source layers" ) );

@@ -144,7 +144,7 @@ QVariantMap QgsJoinByAttributeAlgorithm::processAlgorithm( const QVariantMap &pa

// cache attributes of input2
QMultiHash< QVariant, QgsAttributes > input2AttributeCache;
QgsFeatureIterator features = input2->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( fields2Fetch ) );
QgsFeatureIterator features = input2->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( fields2Fetch ), QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks );
double step = input2->featureCount() > 0 ? 50.0 / input2->featureCount() : 1;
int i = 0;
QgsFeature feat;
@@ -175,7 +175,7 @@ QVariantMap QgsJoinByAttributeAlgorithm::processAlgorithm( const QVariantMap &pa

// Create output vector layer with additional attribute
step = input->featureCount() > 0 ? 50.0 / input->featureCount() : 1;
features = input->getFeatures();
features = input->getFeatures( QgsFeatureRequest(), QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks );
i = 0;
while ( features.nextFeature( feat ) )
{
@@ -69,7 +69,7 @@ QgsOrderByExpressionAlgorithm *QgsOrderByExpressionAlgorithm::createInstance() c

QVariantMap QgsOrderByExpressionAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
std::unique_ptr< QgsFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( !source )
throw QgsProcessingException( QObject::tr( "Could not load source layer for INPUT" ) );

@@ -91,7 +91,7 @@ QVariantMap QgsOrderByExpressionAlgorithm::processAlgorithm( const QVariantMap &
request.addOrderBy( expressionString, ascending, nullsFirst );

QgsFeature inFeature;
QgsFeatureIterator features = source->getFeatures( request );
QgsFeatureIterator features = source->getFeatures( request, QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks );
while ( features.nextFeature( inFeature ) )
{
if ( feedback->isCanceled() )

0 comments on commit 925d9af

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