Skip to content

Commit

Permalink
Add minimal smartness for QgsProcessingFeatureSource::hasFeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 22, 2018
1 parent 715edb1 commit 1b15e68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ An optional ``request`` can be used to optimise the returned
iterator, eg by restricting the returned attributes or geometry.
%End

virtual QgsFeatureSource::FeatureAvailability hasFeatures() const;


virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const;

virtual QgsCoordinateReferenceSystem sourceCrs() const;
Expand Down
8 changes: 8 additions & 0 deletions src/core/processing/qgsprocessingutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,14 @@ QgsFeatureIterator QgsProcessingFeatureSource::getFeatures( const QgsFeatureRequ
return mSource->getFeatures( req );
}

QgsFeatureSource::FeatureAvailability QgsProcessingFeatureSource::hasFeatures() const
{
if ( !mTransformErrorCallback && !mInvalidGeometryCallback && mInvalidGeometryCheck == QgsFeatureRequest::GeometryNoCheck )
return mSource->hasFeatures();
else
return QgsFeatureSource::FeaturesMaybeAvailable;
}

QgsFeatureIterator QgsProcessingFeatureSource::getFeatures( const QgsFeatureRequest &request ) const
{
QgsFeatureRequest req( request );
Expand Down
2 changes: 2 additions & 0 deletions src/core/processing/qgsprocessingutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ class CORE_EXPORT QgsProcessingFeatureSource : public QgsFeatureSource
*/
QgsFeatureIterator getFeatures( const QgsFeatureRequest &request, Flags flags ) const;

QgsFeatureSource::FeatureAvailability hasFeatures() const override;

QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const override;
QgsCoordinateReferenceSystem sourceCrs() const override;
QgsFields fields() const override;
Expand Down

0 comments on commit 1b15e68

Please sign in to comment.