QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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
 QgsFeatureRequest (QgsFeatureId fid)
 construct a request with feature ID filter
 QgsFeatureRequest (const QgsRectangle &rect)
 construct a request with rectangle filter
 QgsFeatureRequest (const QgsExpression &expr)
 construct a request with a filter expression
 QgsFeatureRequest (const QgsFeatureRequest &rh)
 copy constructor
 ~QgsFeatureRequest ()
bool acceptFeature (const QgsFeature &feature)
 Check if a feature is accepted by this requests filter.
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. {.
QgsFeatureRequestsetFilterFid (QgsFeatureId fid)
 Set feature ID that should be fetched.
QgsFeatureRequestsetFilterFids (QgsFeatureIds fids)
 Set feature ID that should be fetched.
QgsFeatureRequestsetFilterRect (const QgsRectangle &rect)
 Set rectangle from which features will be taken.
QgsFeatureRequestsetFlags (Flags flags)
 Set flags that affect how features will be fetched.
QgsFeatureRequestsetSimplifyMethod (const QgsSimplifyMethod &simplifyMethod)
 Set a simplification method for geometries that will be fetched.
QgsFeatureRequestsetSubsetOfAttributes (const QgsAttributeList &attrs)
 Set a subset of attributes that will be fetched.
QgsFeatureRequestsetSubsetOfAttributes (const QStringList &attrNames, const QgsFields &fields)
 Set a subset of attributes by names that will be fetched.
const QgsSimplifyMethodsimplifyMethod () const
 Get simplification method for geometries that will be fetched.
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 33 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsRectangle rect)
explicit

construct a request with rectangle filter

Definition at line 41 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsExpression expr)
explicit

construct a request with a filter expression

Definition at line 50 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsFeatureRequest rh)

copy constructor

Definition at line 58 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::~QgsFeatureRequest ( )

Definition at line 83 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 157 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 63 of file qgsfeaturerequest.cpp.

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

Set filter expression. {.

See Also
QgsExpression}

Definition at line 109 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFilterFid ( QgsFeatureId  fid)

Set feature ID that should be fetched.

Definition at line 95 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFilterFids ( QgsFeatureIds  fids)

Set feature ID that should be fetched.

Definition at line 102 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 88 of file qgsfeaturerequest.cpp.

QgsFeatureRequest & QgsFeatureRequest::setFlags ( Flags  flags)

Set flags that affect how features will be fetched.

Definition at line 117 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 151 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 123 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 130 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: