QGIS API Documentation
2.2.0-Valmiera
|
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, FilterExpression, FilterFids } |
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 & | operator= (const QgsFeatureRequest &rh) |
~QgsFeatureRequest () | |
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 & | setFilterFids (QgsFeatureIds fids) |
Set feature ID that should be fetched. | |
const QgsFeatureIds & | filterFids () const |
QgsFeatureRequest & | setFilterExpression (const QString &expression) |
Set filter expression. {. | |
QgsExpression * | filterExpression () 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. | |
QgsFeatureRequest & | setSimplifyMethod (const QgsSimplifyMethod &simplifyMethod) |
Set a simplification method for geometries that will be fetched. | |
const QgsSimplifyMethod & | simplifyMethod () const |
Get simplification method for geometries that will be fetched. | |
bool | acceptFeature (const QgsFeature &feature) |
Check if a feature is accepted by this requests filter. |
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.
Definition at line 70 of file qgsfeaturerequest.h.
Definition at line 61 of file qgsfeaturerequest.h.
QgsFeatureRequest::QgsFeatureRequest | ( | ) |
construct a default request: for all features get attributes and geometries
Definition at line 22 of file qgsfeaturerequest.cpp.
|
explicit |
construct a request with feature ID filter
Definition at line 29 of file qgsfeaturerequest.cpp.
|
explicit |
construct a request with rectangle filter
Definition at line 37 of file qgsfeaturerequest.cpp.
|
explicit |
construct a request with a filter expression
Definition at line 45 of file qgsfeaturerequest.cpp.
QgsFeatureRequest::QgsFeatureRequest | ( | const QgsFeatureRequest & | rh | ) |
QgsFeatureRequest::~QgsFeatureRequest | ( | ) |
Definition at line 77 of file qgsfeaturerequest.cpp.
References mFilterExpression.
bool QgsFeatureRequest::acceptFeature | ( | const QgsFeature & | feature | ) |
Check if a feature is accepted by this requests filter.
feature | The feature which will be tested |
Definition at line 144 of file qgsfeaturerequest.cpp.
References QgsExpression::evaluate(), FilterExpression, FilterFid, FilterFids, FilterNone, FilterRect, QgsFeature::geometry(), QgsFeature::id(), QgsGeometry::intersects(), mFilter, mFilterExpression, mFilterFid, mFilterFids, and mFilterRect.
Referenced by QgsAttributeTableModel::attributeValueChanged(), QgsAttributeTableModel::featureAdded(), QgsCachedFeatureIterator::fetchFeature(), and QgsVectorLayerFeatureIterator::fetchNextAddedFeature().
|
inline |
Definition at line 111 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature(), QgsAbstractFeatureIterator::nextFeatureFilterExpression(), and QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
|
inline |
|
inline |
Definition at line 107 of file qgsfeaturerequest.h.
Referenced by QgsAbstractFeatureIterator::nextFeatureFilterFids(), and QgsCachedFeatureIterator::QgsCachedFeatureIterator().
|
inline |
Definition at line 99 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerFeatureIterator::fetchNextChangedGeomFeature().
|
inline |
Definition at line 94 of file qgsfeaturerequest.h.
Referenced by QgsAttributeTableModel::attributeValueChanged(), QgsAttributeTableModel::featureAdded(), QgsAttributeTableModel::featureDeleted(), QgsVectorLayerFeatureIterator::fetchFeature(), QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature(), QgsCacheIndexFeatureId::getCacheIterator(), QgsAbstractFeatureIterator::nextFeature(), QgsCachedFeatureIterator::QgsCachedFeatureIterator(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), and QgsVectorLayerFeatureIterator::rewind().
|
inline |
Definition at line 115 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerCache::checkInformationCovered(), QgsVectorLayerFeatureIterator::fetchFeature(), QgsVectorLayerCache::getFeatures(), QgsVectorLayerFeatureIterator::nextFeatureFid(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsVectorLayerFeatureIterator::prepareSimplification(), QgsAbstractFeatureIterator::prepareSimplification(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), setFlags(), QgsAttributeTableModel::setRequest(), QgsVectorLayerFeatureIterator::useAddedFeature(), and QgsVectorLayerFeatureIterator::useChangedAttributeFeature().
QgsFeatureRequest & QgsFeatureRequest::operator= | ( | const QgsFeatureRequest & | rh | ) |
Definition at line 57 of file qgsfeaturerequest.cpp.
References QgsExpression::expression(), mAttrs, mFilter, mFilterExpression, mFilterFid, mFilterFids, mFilterRect, mFlags, and mSimplifyMethod.
Referenced by QgsFeatureRequest().
QgsFeatureRequest & QgsFeatureRequest::setFilterExpression | ( | const QString & | expression | ) |
Set filter expression. {.
Definition at line 103 of file qgsfeaturerequest.cpp.
References FilterExpression, mFilter, and mFilterExpression.
Referenced by QgsRelation::getRelatedFeaturesRequest().
QgsFeatureRequest & QgsFeatureRequest::setFilterFid | ( | QgsFeatureId | fid | ) |
Set feature ID that should be fetched.
Definition at line 89 of file qgsfeaturerequest.cpp.
References FilterFid, mFilter, and mFilterFid.
Referenced by QgsVectorLayer::selectedFeatures(), QgsVectorLayerUndoCommandChangeAttribute::undo(), QgsVectorLayer::updateFeature(), and QgsVectorLayerFeatureIterator::useChangedAttributeFeature().
QgsFeatureRequest & QgsFeatureRequest::setFilterFids | ( | QgsFeatureIds | fids | ) |
Set feature ID that should be fetched.
Definition at line 96 of file qgsfeaturerequest.cpp.
References FilterFids, mFilter, and mFilterFids.
Referenced by QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator().
QgsFeatureRequest & QgsFeatureRequest::setFilterRect | ( | const QgsRectangle & | rect | ) |
Set rectangle from which features will be taken.
Empty rectangle removes the filter.
Definition at line 82 of file qgsfeaturerequest.cpp.
References FilterRect, mFilter, and mFilterRect.
Referenced by QgsVectorLayer::draw(), and QgsComposerAttributeTable::getFeatureAttributes().
QgsFeatureRequest & QgsFeatureRequest::setFlags | ( | Flags | flags | ) |
Set flags that affect how features will be fetched.
Definition at line 111 of file qgsfeaturerequest.cpp.
References flags(), and mFlags.
Referenced by QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect(), QgsComposerAttributeTable::getFeatureAttributes(), QgsVectorLayerCache::getFeatures(), QgsVectorLayerImport::importLayer(), QgsAttributeTableModel::QgsAttributeTableModel(), QgsVectorLayer::selectedFeatures(), QgsAttributeTableModel::setRequest(), QgsVectorLayerUndoCommandChangeAttribute::undo(), QgsVectorLayer::updateFeature(), QgsVectorLayerFeatureIterator::useChangedAttributeFeature(), and QgsVectorFileWriter::writeAsVectorFormat().
QgsFeatureRequest & QgsFeatureRequest::setSimplifyMethod | ( | const QgsSimplifyMethod & | simplifyMethod | ) |
Set a simplification method for geometries that will be fetched.
Definition at line 138 of file qgsfeaturerequest.cpp.
References mSimplifyMethod, and simplifyMethod().
Referenced by QgsVectorLayer::draw().
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 117 of file qgsfeaturerequest.cpp.
References mAttrs, mFlags, and SubsetOfAttributes.
Referenced by QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect(), QgsZonalStatistics::calculateStatistics(), QgsTransectSample::createSample(), 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 124 of file qgsfeaturerequest.cpp.
References QgsFields::count(), mAttrs, mFlags, and SubsetOfAttributes.
|
inline |
Get simplification method for geometries that will be fetched.
Definition at line 130 of file qgsfeaturerequest.h.
Referenced by QgsAbstractFeatureIterator::ref(), and setSimplifyMethod().
|
inline |
Definition at line 120 of file qgsfeaturerequest.h.
Referenced by QgsVectorLayerCache::checkInformationCovered(), QgsVectorLayerCache::getFeatures(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), and QgsVectorLayerFeatureIterator::useChangedAttributeFeature().
|
protected |
Definition at line 154 of file qgsfeaturerequest.h.
Referenced by operator=(), and setSubsetOfAttributes().
|
protected |
Definition at line 148 of file qgsfeaturerequest.h.
Referenced by acceptFeature(), operator=(), setFilterExpression(), setFilterFid(), setFilterFids(), and setFilterRect().
|
protected |
Definition at line 152 of file qgsfeaturerequest.h.
Referenced by acceptFeature(), operator=(), setFilterExpression(), and ~QgsFeatureRequest().
|
protected |
Definition at line 150 of file qgsfeaturerequest.h.
Referenced by acceptFeature(), operator=(), and setFilterFid().
|
protected |
Definition at line 151 of file qgsfeaturerequest.h.
Referenced by acceptFeature(), operator=(), and setFilterFids().
|
protected |
Definition at line 149 of file qgsfeaturerequest.h.
Referenced by acceptFeature(), operator=(), and setFilterRect().
|
protected |
Definition at line 153 of file qgsfeaturerequest.h.
Referenced by operator=(), setFlags(), and setSubsetOfAttributes().
|
protected |
Definition at line 155 of file qgsfeaturerequest.h.
Referenced by operator=(), and setSimplifyMethod().