QGIS API Documentation
2.0.1-Dufour
|
This class wraps a request for features to a vector layer (or directly its vector data provider). More...
#include <qgsfeaturerequest.h>
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 |
QgsFeatureRequest & | setFilterRect (const QgsRectangle &rect) |
Set rectangle from which features will be taken. | |
const QgsRectangle & | filterRect () const |
QgsFeatureRequest & | setFilterFid (QgsFeatureId fid) |
Set feature ID that should be fetched. | |
const QgsFeatureId & | filterFid () const |
QgsFeatureRequest & | setFlags (Flags flags) |
Set flags that affect how features will be fetched. | |
const Flags & | flags () const |
QgsFeatureRequest & | setSubsetOfAttributes (const QgsAttributeList &attrs) |
Set a subset of attributes that will be fetched. | |
const QgsAttributeList & | subsetOfAttributes () const |
QgsFeatureRequest & | setSubsetOfAttributes (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 |
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.
FilterNone |
No filter is applied. |
FilterRect |
Filter using a rectangle. |
FilterFid |
Filter using feature ID. |
Definition at line 67 of file qgsfeaturerequest.h.
Definition at line 58 of file qgsfeaturerequest.h.
QgsFeatureRequest::QgsFeatureRequest | ( | ) |
construct a default request: for all features get attributes and geometries
Definition at line 21 of file qgsfeaturerequest.cpp.
|
explicit |
construct a request with feature ID filter
Definition at line 27 of file qgsfeaturerequest.cpp.
|
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.
|
inline |
Definition at line 92 of file qgsfeaturerequest.h.
Referenced by QgsCacheIndexFeatureId::getCacheIterator(), and QgsVectorLayerFeatureIterator::nextFeatureFid().
|
inline |
Definition at line 88 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerFeatureIterator::fetchNextAddedFeature(), and QgsVectorLayerFeatureIterator::fetchNextChangedGeomFeature().
|
inline |
Definition at line 83 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerFeatureIterator::fetchNextAddedFeature(), QgsCacheIndexFeatureId::getCacheIterator(), QgsVectorLayerFeatureIterator::nextFeature(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), and QgsVectorLayerFeatureIterator::rewind().
|
inline |
Definition at line 96 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerCache::checkInformationCovered(), QgsVectorLayerCache::getFeatures(), QgsVectorLayerFeatureIterator::nextFeature(), QgsVectorLayerFeatureIterator::nextFeatureFid(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), setFlags(), QgsVectorLayerFeatureIterator::useAddedFeature(), and QgsVectorLayerFeatureIterator::useChangedAttributeFeature().
QgsFeatureRequest & QgsFeatureRequest::setFilterFid | ( | QgsFeatureId | fid | ) |
Set feature ID that should be fetched.
Definition at line 58 of file qgsfeaturerequest.cpp.
References FilterFid, mFilter, and mFilterFid.
Referenced by QgsVectorLayer::selectedFeatures(), QgsVectorLayerUndoCommandChangeAttribute::undo(), QgsVectorLayer::updateFeature(), and QgsVectorLayerFeatureIterator::useChangedAttributeFeature().
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 | ) |
Set flags that affect how features will be fetched.
Definition at line 65 of file qgsfeaturerequest.cpp.
References flags(), and mFlags.
Referenced by QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect(), QgsComposerAttributeTable::getFeatureAttributes(), QgsVectorLayerCache::getFeatures(), QgsVectorLayerImport::importLayer(), QgsAttributeTableModel::QgsAttributeTableModel(), QgsVectorLayer::selectedFeatures(), QgsVectorLayerUndoCommandChangeAttribute::undo(), QgsVectorLayer::updateFeature(), QgsVectorLayerFeatureIterator::useChangedAttributeFeature(), and QgsVectorFileWriter::writeAsVectorFormat().
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 71 of file qgsfeaturerequest.cpp.
References mAttrs, mFlags, and SubsetOfAttributes.
Referenced by QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect(), QgsZonalStatistics::calculateStatistics(), QgsGeometryAnalyzer::eventLayer(), QgsComposerAttributeTable::getFeatureAttributes(), QgsVectorLayerCache::getFeatures(), QgsVectorLayerImport::importLayer(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), QgsVectorLayerUndoCommandChangeAttribute::undo(), QgsVectorLayer::updateFeature(), QgsVectorLayerFeatureIterator::useChangedAttributeFeature(), and QgsVectorFileWriter::writeAsVectorFormat().
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.
|
inline |
Definition at line 101 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerCache::checkInformationCovered(), QgsVectorLayerCache::getFeatures(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), and QgsVectorLayerFeatureIterator::useChangedAttributeFeature().
|
protected |
Definition at line 116 of file qgsfeaturerequest.h.
Referenced by QgsFeatureRequest(), and setSubsetOfAttributes().
|
protected |
Definition at line 112 of file qgsfeaturerequest.h.
Referenced by QgsFeatureRequest(), setFilterFid(), and setFilterRect().
|
protected |
Definition at line 114 of file qgsfeaturerequest.h.
Referenced by QgsFeatureRequest(), and setFilterFid().
|
protected |
Definition at line 113 of file qgsfeaturerequest.h.
Referenced by QgsFeatureRequest(), and setFilterRect().
|
protected |
Definition at line 115 of file qgsfeaturerequest.h.
Referenced by QgsFeatureRequest(), setFlags(), and setSubsetOfAttributes().