Skip to content

Commit

Permalink
Slight reorganisation of geometry check to make it easier to
Browse files Browse the repository at this point in the history
add other checks in future
  • Loading branch information
nyalldawson committed Apr 25, 2017
1 parent ee77744 commit 92cc88d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/core/qgsvectorlayerfeatureiterator.cpp
Expand Up @@ -242,7 +242,7 @@ bool QgsVectorLayerFeatureIterator::fetchFeature( QgsFeature &f )
if ( mFetchedFid )
return false;
bool res = nextFeatureFid( f );
if ( res && checkGeometry( f ) )
if ( res && testFeature( f ) )
{
mFetchedFid = true;
return res;
Expand Down Expand Up @@ -313,7 +313,7 @@ bool QgsVectorLayerFeatureIterator::fetchFeature( QgsFeature &f )
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) )
updateFeatureGeometry( f );

if ( !checkGeometry( f ) )
if ( !testFeature( f ) )
continue;

return true;
Expand Down Expand Up @@ -377,7 +377,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextAddedFeature( QgsFeature &f )
// skip features which are not accepted by the filter
continue;

if ( !checkGeometry( *mFetchAddedFeaturesIt ) )
if ( !testFeature( *mFetchAddedFeaturesIt ) )
continue;

useAddedFeature( *mFetchAddedFeaturesIt, f );
Expand Down Expand Up @@ -430,7 +430,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextChangedGeomFeature( QgsFeature &f )

useChangedAttributeFeature( fid, *mFetchChangedGeomIt, f );

if ( checkGeometry( f ) )
if ( testFeature( f ) )
{
// return complete feature
mFetchChangedGeomIt++;
Expand All @@ -457,7 +457,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature( QgsFeature
addVirtualAttributes( f );

mRequest.expressionContext()->setFeature( f );
if ( mRequest.filterExpression()->evaluate( mRequest.expressionContext() ).toBool() && checkGeometry( f ) )
if ( mRequest.filterExpression()->evaluate( mRequest.expressionContext() ).toBool() && testFeature( f ) )
{
return true;
}
Expand Down Expand Up @@ -675,7 +675,13 @@ void QgsVectorLayerFeatureIterator::createOrderedJoinList()
}
}

bool QgsVectorLayerFeatureIterator::checkGeometry( const QgsFeature &feature )
bool QgsVectorLayerFeatureIterator::testFeature( const QgsFeature &feature )
{
bool result = checkGeometryValidity( feature );
return result;
}

bool QgsVectorLayerFeatureIterator::checkGeometryValidity( const QgsFeature &feature )
{
if ( !feature.hasGeometry() )
return true;
Expand Down
9 changes: 7 additions & 2 deletions src/core/qgsvectorlayerfeatureiterator.h
Expand Up @@ -223,9 +223,14 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera
void createOrderedJoinList();

/**
* Performs any geometry validity checking.
* Performs any feature based validity checking, e.g. checking for geometry validity.
*/
bool checkGeometry( const QgsFeature &feature );
bool testFeature( const QgsFeature &feature );

/**
* Checks a feature's geometry for validity, if requested in feature request.
*/
bool checkGeometryValidity( const QgsFeature &feature );
};

#endif // QGSVECTORLAYERFEATUREITERATOR_H

0 comments on commit 92cc88d

Please sign in to comment.