Skip to content
Permalink
Browse files
Slight reorganisation of geometry check to make it easier to
add other checks in future
  • Loading branch information
nyalldawson committed Apr 25, 2017
1 parent ee77744 commit 92cc88d82981b80a060db1023667e29df8bc9bfe
Showing with 19 additions and 8 deletions.
  1. +12 −6 src/core/qgsvectorlayerfeatureiterator.cpp
  2. +7 −2 src/core/qgsvectorlayerfeatureiterator.h
@@ -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;
@@ -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;
@@ -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 );
@@ -430,7 +430,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextChangedGeomFeature( QgsFeature &f )

useChangedAttributeFeature( fid, *mFetchChangedGeomIt, f );

if ( checkGeometry( f ) )
if ( testFeature( f ) )
{
// return complete feature
mFetchChangedGeomIt++;
@@ -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;
}
@@ -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;
@@ -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.