QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
QgsFeatureRequest Class Reference

This class wraps a request for features to a vector layer (or directly its vector data provider). More...

#include <qgsfeaturerequest.h>

Public Types

enum  FilterType {
  FilterNone, FilterRect, FilterFid, FilterExpression,
  FilterFids
}
 
enum  Flag { NoFlags = 0, NoGeometry = 1, SubsetOfAttributes = 2, ExactIntersect = 4 }
 

Public Member Functions

 QgsFeatureRequest ()
 construct a default request: for all features get attributes and geometries More...
 
 QgsFeatureRequest (QgsFeatureId fid)
 construct a request with feature ID filter More...
 
 QgsFeatureRequest (const QgsRectangle &rect)
 construct a request with rectangle filter More...
 
 QgsFeatureRequest (const QgsExpression &expr)
 construct a request with a filter expression More...
 
 QgsFeatureRequest (const QgsFeatureRequest &rh)
 copy constructor More...
 
 ~QgsFeatureRequest ()
 
bool acceptFeature (const QgsFeature &feature)
 Check if a feature is accepted by this requests filter. More...
 
QgsExpressionfilterExpression () const
 
const QgsFeatureIdfilterFid () const
 
const QgsFeatureIdsfilterFids () const
 
const QgsRectanglefilterRect () const
 
FilterType filterType () const
 
const Flags & flags () const
 
QgsFeatureRequestoperator= (const QgsFeatureRequest &rh)
 
QgsFeatureRequestsetFilterExpression (const QString &expression)
 Set filter expression. {. More...
 
QgsFeatureRequestsetFilterFid (QgsFeatureId fid)
 Set feature ID that should be fetched. More...
 
QgsFeatureRequestsetFilterFids (QgsFeatureIds fids)
 Set feature ID that should be fetched. More...
 
QgsFeatureRequestsetFilterRect (const QgsRectangle &rect)
 Set rectangle from which features will be taken. More...
 
QgsFeatureRequestsetFlags (Flags flags)
 Set flags that affect how features will be fetched. More...
 
QgsFeatureRequestsetSimplifyMethod (const QgsSimplifyMethod &simplifyMethod)
 Set a simplification method for geometries that will be fetched. More...
 
QgsFeatureRequestsetSubsetOfAttributes (const QgsAttributeList &attrs)
 Set a subset of attributes that will be fetched. More...
 
QgsFeatureRequestsetSubsetOfAttributes (const QStringList &attrNames, const QgsFields &fields)
 Set a subset of attributes by names that will be fetched. More...
 
const QgsSimplifyMethodsimplifyMethod () const
 Get simplification method for geometries that will be fetched. More...
 
const QgsAttributeListsubsetOfAttributes () const
 

Static Public Attributes

static const QString AllAttributes = QString( "#!allattributes!#" )
 

Protected Attributes

QgsAttributeList mAttrs
 
FilterType mFilter
 
QgsExpressionmFilterExpression
 
QgsFeatureId mFilterFid
 
QgsFeatureIds mFilterFids
 
QgsRectangle mFilterRect
 
Flags mFlags
 
QgsSimplifyMethod mSimplifyMethod
 

Detailed Description

This class wraps a request for features to a vector layer (or directly its vector data provider).

The request may apply a filter to fetch only a particular subset of features. Currently supported filters:

For efficiency, it is also possible to tell provider that some data is not required:

The options may be chained, e.g.: QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest::ExactIntersect)

Examples:

Definition at line 58 of file qgsfeaturerequest.h.

Member Enumeration Documentation

Enumerator
FilterNone 

No filter is applied.

FilterRect 

Filter using a rectangle, no need to set NoGeometry.

FilterFid 

Filter using feature ID.

FilterExpression 

Filter using expression.

FilterFids 

Filter using feature IDs.

Definition at line 70 of file qgsfeaturerequest.h.

Enumerator
NoFlags 
NoGeometry 

Geometry is not required. It may still be returned if e.g. required for a filter condition.

SubsetOfAttributes 

Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)

ExactIntersect 

Use exact geometry intersection (slower) instead of bounding boxes.

Definition at line 61 of file qgsfeaturerequest.h.

Constructor & Destructor Documentation

QgsFeatureRequest::QgsFeatureRequest ( )

construct a default request: for all features get attributes and geometries

Definition at line 25 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( QgsFeatureId  fid)
explicit

construct a request with feature ID filter

Definition at line 32 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsRectangle rect)
explicit

construct a request with rectangle filter

Definition at line 40 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsExpression expr)
explicit

construct a request with a filter expression

Definition at line 48 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsFeatureRequest rh)

copy constructor

Definition at line 55 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::~QgsFeatureRequest ( )

Definition at line 80 of file qgsfeaturerequest.cpp.

Member Function Documentation

bool QgsFeatureRequest::acceptFeature ( const QgsFeature feature)

Check if a feature is accepted by this requests filter.

Parameters
featureThe feature which will be tested
Returns
true, if the filter accepts the feature
Note
added in 2.1

Definition at line 154 of file qgsfeaturerequest.cpp.

QgsExpression* QgsFeatureRequest::filterExpression ( ) const
inline

Definition at line 113 of file qgsfeaturerequest.h.

const QgsFeatureId& QgsFeatureRequest::filterFid ( ) const
inline

Definition at line 105 of file qgsfeaturerequest.h.

const QgsFeatureIds& QgsFeatureRequest::filterFids ( ) const
inline

Definition at line 109 of file qgsfeaturerequest.h.

const QgsRectangle& QgsFeatureRequest::filterRect ( ) const
inline

Definition at line 101 of file qgsfeaturerequest.h.

FilterType QgsFeatureRequest::filterType ( ) const
inline

Definition at line 96 of file qgsfeaturerequest.h.

const Flags& QgsFeatureRequest::flags ( ) const
inline

Definition at line 117 of file qgsfeaturerequest.h.

QgsFeatureRequest & QgsFeatureRequest::operator= ( const QgsFeatureRequest rh)

Definition at line 60 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFilterExpression ( const QString &  expression)

Set filter expression. {.

See also
QgsExpression}

Definition at line 106 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFilterFid ( QgsFeatureId  fid)

Set feature ID that should be fetched.

Definition at line 92 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFilterFids ( QgsFeatureIds  fids)

Set feature ID that should be fetched.

Definition at line 99 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFilterRect ( const QgsRectangle rect)

Set rectangle from which features will be taken.

Empty rectangle removes the filter.

Definition at line 85 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFlags ( Flags  flags)

Set flags that affect how features will be fetched.

Definition at line 114 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setSimplifyMethod ( const QgsSimplifyMethod simplifyMethod)

Set a simplification method for geometries that will be fetched.

Note
added in 2.2

Definition at line 148 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setSubsetOfAttributes ( const QgsAttributeList attrs)

Set a subset of attributes that will be fetched.

Empty list means that all attributes are used. To disable fetching attributes, reset the FetchAttributes flag (which is set by default)

Definition at line 120 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setSubsetOfAttributes ( const QStringList &  attrNames,
const QgsFields fields 
)

Set a subset of attributes by names that will be fetched.

Definition at line 127 of file qgsfeaturerequest.cpp.

const QgsSimplifyMethod& QgsFeatureRequest::simplifyMethod ( ) const
inline

Get simplification method for geometries that will be fetched.

Note
added in 2.2

Definition at line 132 of file qgsfeaturerequest.h.

const QgsAttributeList& QgsFeatureRequest::subsetOfAttributes ( ) const
inline

Definition at line 122 of file qgsfeaturerequest.h.

Member Data Documentation

const QString QgsFeatureRequest::AllAttributes = QString( "#!allattributes!#" )
static

Definition at line 79 of file qgsfeaturerequest.h.

QgsAttributeList QgsFeatureRequest::mAttrs
protected

Definition at line 156 of file qgsfeaturerequest.h.

FilterType QgsFeatureRequest::mFilter
protected

Definition at line 150 of file qgsfeaturerequest.h.

QgsExpression* QgsFeatureRequest::mFilterExpression
protected

Definition at line 154 of file qgsfeaturerequest.h.

QgsFeatureId QgsFeatureRequest::mFilterFid
protected

Definition at line 152 of file qgsfeaturerequest.h.

QgsFeatureIds QgsFeatureRequest::mFilterFids
protected

Definition at line 153 of file qgsfeaturerequest.h.

QgsRectangle QgsFeatureRequest::mFilterRect
protected

Definition at line 151 of file qgsfeaturerequest.h.

Flags QgsFeatureRequest::mFlags
protected

Definition at line 155 of file qgsfeaturerequest.h.

QgsSimplifyMethod QgsFeatureRequest::mSimplifyMethod
protected

Definition at line 157 of file qgsfeaturerequest.h.


The documentation for this class was generated from the following files: