| Quantum GIS API Documentation
    1.8
    | 
The feature class encapsulates a single feature including its id, geometry and a list of field/values attributes. More...
#include <qgsfeature.h>

| Public Member Functions | |
| QgsFeature (QgsFeatureId id=QgsFeatureId(), QString typeName="") | |
| Constructor. | |
| QgsFeature (QgsFeature const &rhs) | |
| copy ctor needed due to internal pointer | |
| QgsFeature & | operator= (QgsFeature const &rhs) | 
| assignment operator needed due to internal pointer | |
| ~QgsFeature () | |
| Destructor. | |
| QgsFeatureId | id () const | 
| Get the feature id for this feature. | |
| void | setFeatureId (QgsFeatureId id) | 
| Set the feature id for this feature. | |
| QString | typeName () const | 
| returns the feature's type name | |
| void | setTypeName (QString typeName) | 
| sets the feature's type name | |
| const QgsAttributeMap & | attributeMap () const | 
| Get the attributes for this feature. | |
| void | setAttributeMap (const QgsAttributeMap &attributeMap) | 
| Sets all the attributes in one go. | |
| void | clearAttributeMap () | 
| Clear attribute map added in 1.5. | |
| void | addAttribute (int field, QVariant attr) | 
| Add an attribute to the map. | |
| void | deleteAttribute (int field) | 
| Deletes an attribute and its value. | |
| void | changeAttribute (int field, QVariant attr) | 
| Changes an existing attribute value. | |
| bool | isValid () const | 
| Return the validity of this feature. | |
| void | setValid (bool validity) | 
| Set the validity of the feature. | |
| bool | isDirty () const | 
| Return the dirty state of this feature. | |
| void | clean () | 
| Reset the dirtiness of the feature. | |
| QgsGeometry * | geometry () | 
| Get the geometry object associated with this feature. | |
| QgsGeometry * | geometryAndOwnership () | 
| Get the geometry object associated with this feature The caller assumes responsibility for the QgsGeometry*'s destruction. | |
| void | setGeometry (const QgsGeometry &geom) | 
| Set this feature's geometry from another QgsGeometry object (deep copy) | |
| void | setGeometry (QgsGeometry *geom) | 
| Set this feature's geometry (takes geometry ownership) | |
| void | setGeometryAndOwnership (unsigned char *geom, size_t length) | 
| Set this feature's geometry from WKB. | |
| Private Attributes | |
| QgsFeatureId | mFid | 
| feature id | |
| QgsAttributeMap | mAttributes | 
| map of attributes accessed by field index | |
| QgsGeometry * | mGeometry | 
| pointer to geometry in binary WKB format | |
| bool | mOwnsGeometry | 
| Indicator if the mGeometry is owned by this QgsFeature. | |
| bool | mValid | 
| Flag to indicate if this feature is valid. | |
| bool | mDirty | 
| Flag to indicate if this feature is dirty (e.g. geometry has been modified in-memory) | |
| QString | mTypeName | 
| feature type name | |
The feature class encapsulates a single feature including its id, geometry and a list of field/values attributes.
Encapsulates a spatial feature with attributes.
Definition at line 104 of file qgsfeature.h.
| QgsFeature::QgsFeature | ( | QgsFeatureId | id = QgsFeatureId(), | 
| QString | typeName = "" | ||
| ) | 
Constructor.
Definition at line 24 of file qgsfeature.cpp.
| QgsFeature::QgsFeature | ( | QgsFeature const & | rhs | ) | 
copy ctor needed due to internal pointer
Definition at line 35 of file qgsfeature.cpp.
References mGeometry, and setGeometry().
| void QgsFeature::addAttribute | ( | int | field, | 
| QVariant | attr | ||
| ) | 
Add an attribute to the map.
Definition at line 120 of file qgsfeature.cpp.
References mAttributes.
Referenced by QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes(), and QgsVectorLayer::addJoinedFeatureAttributes().
| const QgsAttributeMap & QgsFeature::attributeMap | ( | ) | const | 
Get the attributes for this feature.
Definition at line 100 of file qgsfeature.cpp.
References mAttributes.
Referenced by QgsGeometryAnalyzer::addEventLayerFeature(), QgsVectorLayerImport::addFeature(), QgsVectorFileWriter::addFeature(), QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes(), QgsVectorLayer::addJoinedFeatureAttributes(), QgsGeometryAnalyzer::bufferFeature(), QgsInterpolator::cacheBaseData(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsGeometryAnalyzer::centroidFeature(), QgsAttributeEditor::createAttributeEditor(), QgsFormAnnotationItem::createDesignerWidget(), QgsGraduatedSymbolRendererV2::createRenderer(), QgsAttributeAction::doAction(), QgsExpression::NodeColumnRef::eval(), QgsGeometryAnalyzer::eventLayer(), QgsVectorLayer::featureAtId(), QgsMapTip::fetchFeature(), QgsLabel::fieldValue(), QgsVectorDataProvider::fillMinMaxCache(), QgsComposerAttributeTable::getFeatureAttributes(), QgsSearchQueryBuilder::getFieldValues(), QgsPointDisplacementRenderer::getLabel(), QgsTINInterpolator::insertData(), QgsOverlayAnalyzer::intersectFeature(), QgsLineVectorLayerDirector::makeGraph(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayer::nextFeature(), QgsEllipseSymbolLayerV2::preparePath(), QgsPalLabeling::registerDiagramFeature(), QgsPalLayerSettings::registerFeature(), QgsUniqueValueRenderer::renderFeature(), QgsContinuousColorRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), QgsGraduatedSymbolRenderer::renderFeature(), QgsEllipseSymbolLayerV2::renderPoint(), QgsVectorFieldSymbolLayer::renderPoint(), QgsGeometryAnalyzer::simplifyFeature(), QgsSingleSymbolRendererV2::symbolForFeature(), QgsGraduatedSymbolRendererV2::symbolForFeature(), QgsCategorizedSymbolRendererV2::symbolForFeature(), QgsUniqueValueRenderer::symbolForFeature(), QgsGraduatedSymbolRenderer::symbolForFeature(), QgsVectorLayer::undoEditCommand(), QgsVectorDataProvider::uniqueValues(), QgsVectorLayer::uniqueValues(), QgsVectorLayer::updateFeature(), QgsVectorLayerJoinBuffer::updateFeatureAttributes(), QgsVectorLayer::updateFeatureAttributes(), and QgsSearchTreeNode::valueAgainst().
| void QgsFeature::changeAttribute | ( | int | field, | 
| QVariant | attr | ||
| ) | 
Changes an existing attribute value.
| field | index of the field | 
| attr | attribute name and value to be set | 
Definition at line 132 of file qgsfeature.cpp.
References mAttributes.
Referenced by QgsVectorLayer::updateFeatureAttributes().
| void QgsFeature::clean | ( | ) | 
Reset the dirtiness of the feature.
(i.e. make clean) You would normally do this after it's saved to permanent storage (e.g. disk, an ACID-compliant database)
Definition at line 217 of file qgsfeature.cpp.
References mDirty.
| void QgsFeature::clearAttributeMap | ( | ) | 
Clear attribute map added in 1.5.
Clear attribute map for this feature.
Definition at line 112 of file qgsfeature.cpp.
References mAttributes.
Referenced by QgsVectorLayerImport::importLayer(), and QgsVectorFileWriter::writeAsVectorFormat().
| void QgsFeature::deleteAttribute | ( | int | field | ) | 
Deletes an attribute and its value.
Definition at line 126 of file qgsfeature.cpp.
References mAttributes.
Referenced by QgsVectorLayer::updateFeatureAttributes().
Get the geometry object associated with this feature.
Definition at line 137 of file qgsfeature.cpp.
References mGeometry.
Referenced by QgsVectorFileWriter::addFeature(), QgsVectorLayer::addFeature(), QgsVectorLayer::addRing(), QgsVectorLayer::boundingBoxOfSelected(), QgsGeometryAnalyzer::bufferFeature(), QgsInterpolator::cacheBaseData(), QgsZonalStatistics::calculateStatistics(), QgsGeometryAnalyzer::centroidFeature(), QgsGeometryAnalyzer::convexFeature(), QgsPointDisplacementRenderer::createDisplacementGroups(), QgsGeometryAnalyzer::dissolveFeature(), QgsVectorLayer::draw(), QgsVectorLayer::drawFeature(), QgsVectorLayer::drawRendererV2(), QgsVectorLayer::drawRendererV2Levels(), QgsGeometryAnalyzer::eventLayer(), fcnGeomArea(), fcnGeomLength(), fcnGeomPerimeter(), QgsSpatialIndex::featureInfo(), QgsVectorLayerImport::importLayer(), QgsTINInterpolator::insertData(), QgsOverlayAnalyzer::intersectFeature(), QgsLabel::labelPoint(), QgsLineVectorLayerDirector::makeGraph(), QgsVectorLayer::redoEditCommand(), QgsPalLabeling::registerDiagramFeature(), QgsPalLayerSettings::registerFeature(), QgsVectorLayer::removePolygonIntersections(), QgsPointDisplacementRenderer::renderFeature(), QgsFeatureRendererV2::renderFeatureWithSymbol(), QgsGeometryAnalyzer::simplifyFeature(), QgsVectorLayer::snapWithContext(), QgsVectorLayer::translateFeature(), QgsVectorLayer::undoEditCommand(), QgsVectorLayer::updateExtents(), QgsVectorLayer::updateFeature(), QgsSearchTreeNode::valueAgainst(), and QgsVectorFileWriter::writeAsVectorFormat().
Get the geometry object associated with this feature The caller assumes responsibility for the QgsGeometry*'s destruction.
Definition at line 142 of file qgsfeature.cpp.
References mGeometry, and mOwnsGeometry.
Referenced by QgsVectorLayer::addPart().
| QgsFeatureId QgsFeature::id | ( | ) | const | 
Get the feature id for this feature.
Definition at line 91 of file qgsfeature.cpp.
References mFid.
Referenced by QgsVectorFileWriter::addFeature(), QgsVectorLayer::addFeature(), QgsVectorLayer::addRing(), QgsVectorLayer::boundingBoxOfSelected(), QgsZonalStatistics::calculateStatistics(), QgsVectorLayer::commitChanges(), QgsPointDisplacementRenderer::createDisplacementGroups(), QgsVectorLayer::draw(), QgsVectorLayer::drawRendererV2(), QgsVectorLayer::drawRendererV2Levels(), QgsGeometryAnalyzer::eventLayer(), fcnFeatureId(), QgsVectorDataProvider::featureAtId(), QgsVectorLayer::featureAtId(), QgsSpatialIndex::featureInfo(), QgsVectorLayerImport::importLayer(), QgsVectorLayer::invertSelection(), QgsVectorLayer::invertSelectionInRectangle(), QgsVectorLayer::nextFeature(), QgsPalLabeling::registerDiagramFeature(), QgsPalLayerSettings::registerFeature(), QgsPointDisplacementRenderer::renderFeature(), QgsVectorLayer::select(), QgsFormAnnotationItem::setFeatureForMapPosition(), setFeatureId(), QgsVectorLayer::snapWithContext(), QgsVectorLayer::updateFeature(), QgsVectorLayer::updateFeatureAttributes(), QgsVectorLayer::updateFeatureGeometry(), QgsSearchTreeNode::valueAgainst(), and QgsVectorFileWriter::writeAsVectorFormat().
| bool QgsFeature::isDirty | ( | ) | const | 
Return the dirty state of this feature.
Dirty is set if (e.g.) the feature's geometry has been modified in-memory.
Definition at line 212 of file qgsfeature.cpp.
References mDirty.
| bool QgsFeature::isValid | ( | ) | const | 
Return the validity of this feature.
This is normally set by the provider to indicate some problem that makes the feature invalid or to indicate a null feature.
Definition at line 202 of file qgsfeature.cpp.
References mValid.
Referenced by QgsVectorLayer::drawFeature(), and QgsExpressionBuilderWidget::on_txtExpressionString_textChanged().
| QgsFeature & QgsFeature::operator= | ( | QgsFeature const & | rhs | ) | 
assignment operator needed due to internal pointer
Definition at line 53 of file qgsfeature.cpp.
References mAttributes, mDirty, mFid, mGeometry, mOwnsGeometry, mTypeName, mValid, and setGeometry().
| void QgsFeature::setAttributeMap | ( | const QgsAttributeMap & | attributeMap | ) | 
Sets all the attributes in one go.
Sets the attributes for this feature.
Definition at line 106 of file qgsfeature.cpp.
References mAttributes.
Referenced by QgsVectorLayerImport::addFeature(), QgsGeometryAnalyzer::bufferFeature(), QgsGeometryAnalyzer::centroidFeature(), QgsSearchTreeNode::checkAgainst(), QgsGeometryAnalyzer::convexHull(), QgsGeometryAnalyzer::dissolve(), QgsGeometryAnalyzer::extent(), QgsVectorLayer::featureAtId(), QgsSearchTreeNode::getValue(), QgsOverlayAnalyzer::intersectFeature(), QgsVectorLayer::nextFeature(), QgsGeometryAnalyzer::simplifyFeature(), QgsVectorLayer::splitFeatures(), and QgsSearchTreeNode::valueAgainst().
| void QgsFeature::setFeatureId | ( | QgsFeatureId | id | ) | 
Set the feature id for this feature.
Set the feature id.
| id | Feature id | 
Definition at line 153 of file qgsfeature.cpp.
Referenced by QgsVectorLayer::addFeature(), QgsVectorLayer::featureAtId(), and QgsVectorLayer::nextFeature().
| void QgsFeature::setGeometry | ( | const QgsGeometry & | geom | ) | 
Set this feature's geometry from another QgsGeometry object (deep copy)
Definition at line 174 of file qgsfeature.cpp.
Referenced by QgsGeometryAnalyzer::addEventLayerFeature(), QgsGeometryAnalyzer::buffer(), QgsGeometryAnalyzer::bufferFeature(), QgsGeometryAnalyzer::centroidFeature(), QgsSearchTreeNode::checkAgainst(), QgsVectorLayer::commitChanges(), QgsGeometryAnalyzer::convexHull(), QgsGeometryAnalyzer::dissolve(), QgsGeometryAnalyzer::extent(), QgsVectorLayer::featureAtId(), QgsSearchTreeNode::getValue(), QgsOverlayAnalyzer::intersectFeature(), QgsVectorLayer::nextFeature(), operator=(), QgsFeature(), setGeometryAndOwnership(), QgsGeometryAnalyzer::simplifyFeature(), QgsVectorLayer::splitFeatures(), QgsVectorLayer::updateFeatureGeometry(), and QgsSearchTreeNode::valueAgainst().
| void QgsFeature::setGeometry | ( | QgsGeometry * | geom | ) | 
Set this feature's geometry (takes geometry ownership)
Definition at line 179 of file qgsfeature.cpp.
References mGeometry, and mOwnsGeometry.
| void QgsFeature::setGeometryAndOwnership | ( | unsigned char * | geom, | 
| size_t | length | ||
| ) | 
Set this feature's geometry from WKB.
Set the pointer to the feature geometry.
This feature assumes responsibility for destroying geom.
Definition at line 194 of file qgsfeature.cpp.
References QgsGeometry::fromWkb(), and setGeometry().
| void QgsFeature::setTypeName | ( | QString | typeName | ) | 
sets the feature's type name
Definition at line 168 of file qgsfeature.cpp.
References mTypeName, and typeName().
| void QgsFeature::setValid | ( | bool | validity | ) | 
Set the validity of the feature.
Definition at line 207 of file qgsfeature.cpp.
References mValid.
Referenced by QgsVectorLayer::featureAtId(), and QgsVectorLayer::nextFeature().
| QString QgsFeature::typeName | ( | ) | const | 
returns the feature's type name
Definition at line 159 of file qgsfeature.cpp.
References mTypeName.
Referenced by QgsVectorLayer::draw(), QgsVectorLayer::drawRendererV2(), QgsVectorLayer::drawRendererV2Levels(), QgsVectorLayerImport::importLayer(), setTypeName(), and QgsVectorFileWriter::writeAsVectorFormat().
| QgsAttributeMap QgsFeature::mAttributes  [private] | 
map of attributes accessed by field index
Definition at line 224 of file qgsfeature.h.
Referenced by addAttribute(), attributeMap(), changeAttribute(), clearAttributeMap(), deleteAttribute(), operator=(), and setAttributeMap().
| bool QgsFeature::mDirty  [private] | 
Flag to indicate if this feature is dirty (e.g. geometry has been modified in-memory)
Definition at line 243 of file qgsfeature.h.
Referenced by clean(), isDirty(), and operator=().
| QgsFeatureId QgsFeature::mFid  [private] | 
feature id
Definition at line 221 of file qgsfeature.h.
Referenced by id(), operator=(), and setFeatureId().
| QgsGeometry* QgsFeature::mGeometry  [private] | 
pointer to geometry in binary WKB format
This is usually set by a call to OGRGeometry::exportToWkb()
Definition at line 230 of file qgsfeature.h.
Referenced by geometry(), geometryAndOwnership(), operator=(), QgsFeature(), setGeometry(), and ~QgsFeature().
| bool QgsFeature::mOwnsGeometry  [private] | 
Indicator if the mGeometry is owned by this QgsFeature.
If so, this QgsFeature takes responsibility for the mGeometry's destruction.
Definition at line 235 of file qgsfeature.h.
Referenced by geometryAndOwnership(), operator=(), setGeometry(), and ~QgsFeature().
| QString QgsFeature::mTypeName  [private] | 
feature type name
Definition at line 246 of file qgsfeature.h.
Referenced by operator=(), setTypeName(), and typeName().
| bool QgsFeature::mValid  [private] | 
Flag to indicate if this feature is valid.
Definition at line 239 of file qgsfeature.h.
Referenced by isValid(), operator=(), and setValid().
 1.7.6.1
 1.7.6.1