QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | 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>

Collaboration diagram for QgsFeatureRequest:
Collaboration graph
[legend]

Public Types

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

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 QgsFeatureRequest &rh)
 copy constructor
FilterType filterType () const
QgsFeatureRequestsetFilterRect (const QgsRectangle &rect)
 Set rectangle from which features will be taken.
const QgsRectanglefilterRect () const
QgsFeatureRequestsetFilterFid (QgsFeatureId fid)
 Set feature ID that should be fetched.
const QgsFeatureIdfilterFid () const
QgsFeatureRequestsetFlags (Flags flags)
 Set flags that affect how features will be fetched.
const Flags & flags () const
QgsFeatureRequestsetSubsetOfAttributes (const QgsAttributeList &attrs)
 Set a subset of attributes that will be fetched.
const QgsAttributeListsubsetOfAttributes () const
QgsFeatureRequestsetSubsetOfAttributes (const QStringList &attrNames, const QgsFields &fields)
 Set a subset of attributes by names that will be fetched.

Protected Attributes

FilterType mFilter
QgsRectangle mFilterRect
QgsFeatureId mFilterFid
Flags mFlags
QgsAttributeList mAttrs

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 55 of file qgsfeaturerequest.h.

Member Enumeration Documentation

Enumerator:
FilterNone 

No filter is applied.

FilterRect 

Filter using a rectangle.

FilterFid 

Filter using feature ID.

Definition at line 67 of file qgsfeaturerequest.h.

Enumerator:
NoFlags 
NoGeometry 

Do not fetch geometry.

SubsetOfAttributes 

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

ExactIntersect 

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

Definition at line 58 of file qgsfeaturerequest.h.

Constructor & Destructor Documentation

QgsFeatureRequest::QgsFeatureRequest ( )

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

Definition at line 21 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( QgsFeatureId  fid)
explicit

construct a request with feature ID filter

Definition at line 27 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsRectangle rect)
explicit

construct a request with rectangle filter

Definition at line 34 of file qgsfeaturerequest.cpp.

QgsFeatureRequest::QgsFeatureRequest ( const QgsFeatureRequest rh)

copy constructor

Definition at line 41 of file qgsfeaturerequest.cpp.

References mAttrs, mFilter, mFilterFid, mFilterRect, and mFlags.

Member Function Documentation

const QgsFeatureId& QgsFeatureRequest::filterFid ( ) const
inline
const QgsRectangle& QgsFeatureRequest::filterRect ( ) const
inline
FilterType QgsFeatureRequest::filterType ( ) const
inline
const Flags& QgsFeatureRequest::flags ( ) const
inline
QgsFeatureRequest & QgsFeatureRequest::setFilterFid ( QgsFeatureId  fid)
QgsFeatureRequest & QgsFeatureRequest::setFilterRect ( const QgsRectangle rect)

Set rectangle from which features will be taken.

Empty rectangle removes the filter.

Definition at line 51 of file qgsfeaturerequest.cpp.

References FilterRect, mFilter, and mFilterRect.

Referenced by QgsComposerAttributeTable::getFeatureAttributes().

QgsFeatureRequest & QgsFeatureRequest::setFlags ( Flags  flags)
QgsFeatureRequest & QgsFeatureRequest::setSubsetOfAttributes ( const QgsAttributeList attrs)
QgsFeatureRequest & QgsFeatureRequest::setSubsetOfAttributes ( const QStringList &  attrNames,
const QgsFields fields 
)

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

Definition at line 79 of file qgsfeaturerequest.cpp.

References QgsFields::count(), mAttrs, mFlags, and SubsetOfAttributes.

const QgsAttributeList& QgsFeatureRequest::subsetOfAttributes ( ) const
inline

Member Data Documentation

QgsAttributeList QgsFeatureRequest::mAttrs
protected

Definition at line 116 of file qgsfeaturerequest.h.

Referenced by QgsFeatureRequest(), and setSubsetOfAttributes().

FilterType QgsFeatureRequest::mFilter
protected

Definition at line 112 of file qgsfeaturerequest.h.

Referenced by QgsFeatureRequest(), setFilterFid(), and setFilterRect().

QgsFeatureId QgsFeatureRequest::mFilterFid
protected

Definition at line 114 of file qgsfeaturerequest.h.

Referenced by QgsFeatureRequest(), and setFilterFid().

QgsRectangle QgsFeatureRequest::mFilterRect
protected

Definition at line 113 of file qgsfeaturerequest.h.

Referenced by QgsFeatureRequest(), and setFilterRect().

Flags QgsFeatureRequest::mFlags
protected

Definition at line 115 of file qgsfeaturerequest.h.

Referenced by QgsFeatureRequest(), setFlags(), and setSubsetOfAttributes().


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