Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
QgsFeature Class Reference

The feature class encapsulates a single feature including its id, geometry and a list of field/values attributes. More...

#include <qgsfeature.h>

Collaboration diagram for QgsFeature:
Collaboration graph
[legend]

Public Member Functions

 QgsFeature (int id=0, QString typeName="")
 Constructor. More...
 
 QgsFeature (QgsFeature const &rhs)
 copy ctor needed due to internal pointer More...
 
QgsFeatureoperator= (QgsFeature const &rhs)
 assignment operator needed due to internal pointer More...
 
 ~QgsFeature ()
 Destructor. More...
 
int id () const
 Get the feature id for this feature. More...
 
void setFeatureId (int id)
 Set the feature id for this feature. More...
 
QString typeName () const
 returns the feature's type name More...
 
void setTypeName (QString typeName)
 sets the feature's type name More...
 
const QgsAttributeMapattributeMap () const
 Get the attributes for this feature. More...
 
void setAttributeMap (const QgsAttributeMap &attributeMap)
 Sets all the attributes in one go. More...
 
void clearAttributeMap ()
 Clear attribute map added in 1.5. More...
 
void addAttribute (int field, QVariant attr)
 Add an attribute to the map. More...
 
void deleteAttribute (int field)
 Deletes an attribute and its value. More...
 
void changeAttribute (int field, QVariant attr)
 Changes an existing attribute value. More...
 
bool isValid () const
 Return the validity of this feature. More...
 
void setValid (bool validity)
 Set the validity of the feature. More...
 
bool isDirty () const
 Return the dirty state of this feature. More...
 
void clean ()
 Reset the dirtiness of the feature. More...
 
QgsGeometrygeometry ()
 Get the geometry object associated with this feature. More...
 
QgsGeometrygeometryAndOwnership ()
 Get the geometry object associated with this feature The caller assumes responsibility for the QgsGeometry*'s destruction. More...
 
void setGeometry (const QgsGeometry &geom)
 Set this feature's geometry from another QgsGeometry object (deep copy) More...
 
void setGeometry (QgsGeometry *geom)
 Set this feature's geometry (takes geometry ownership) More...
 
void setGeometryAndOwnership (unsigned char *geom, size_t length)
 Set this feature's geometry from WKB. More...
 

Private Attributes

int mFid
 feature id More...
 
QgsAttributeMap mAttributes
 map of attributes accessed by field index More...
 
QgsGeometrymGeometry
 pointer to geometry in binary WKB format More...
 
bool mOwnsGeometry
 Indicator if the mGeometry is owned by this QgsFeature. More...
 
bool mValid
 Flag to indicate if this feature is valid. More...
 
bool mDirty
 Flag to indicate if this feature is dirty (e.g. geometry has been modified in-memory) More...
 
QString mTypeName
 feature type name More...
 

Detailed Description

The feature class encapsulates a single feature including its id, geometry and a list of field/values attributes.

Encapsulates a spatial feature with attributes.

Author
Gary E.Sherman

Definition at line 49 of file qgsfeature.h.

Constructor & Destructor Documentation

QgsFeature::QgsFeature ( int  id = 0,
QString  typeName = "" 
)

Constructor.

Definition at line 25 of file qgsfeature.cpp.

QgsFeature::QgsFeature ( QgsFeature const &  rhs)

copy ctor needed due to internal pointer

Definition at line 36 of file qgsfeature.cpp.

References mGeometry, and setGeometry().

QgsFeature::~QgsFeature ( )

Destructor.

Definition at line 81 of file qgsfeature.cpp.

References mGeometry, and mOwnsGeometry.

Member Function Documentation

void QgsFeature::addAttribute ( int  field,
QVariant  attr 
)

Add an attribute to the map.

Definition at line 121 of file qgsfeature.cpp.

References mAttributes.

Referenced by QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes(), and QgsVectorLayer::addJoinedFeatureAttributes().

const QgsAttributeMap & QgsFeature::attributeMap ( ) const

Get the attributes for this feature.

Returns
A std::map containing the field name/value mapping

Definition at line 101 of file qgsfeature.cpp.

References mAttributes.

Referenced by QgsVectorFileWriter::addFeature(), QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes(), QgsVectorLayer::addJoinedFeatureAttributes(), QgsGeometryAnalyzer::bufferFeature(), QgsInterpolator::cacheBaseData(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsGeometryAnalyzer::centroidFeature(), QgsFormAnnotationItem::createDesignerWidget(), QgsGraduatedSymbolRendererV2::createRenderer(), QgsVectorLayer::featureAtId(), QgsMapTip::fetchFeature(), QgsLabel::fieldValue(), QgsVectorDataProvider::fillMinMaxCache(), QgsComposerAttributeTable::getFeatureAttributes(), QgsSearchQueryBuilder::getFieldValues(), QgsTINInterpolator::insertData(), QgsOverlayAnalyzer::intersectFeature(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayer::nextFeature(), QgsPalLabeling::registerDiagramFeature(), QgsPalLayerSettings::registerFeature(), QgsUniqueValueRenderer::renderFeature(), QgsContinuousColorRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), QgsGraduatedSymbolRenderer::renderFeature(), QgsGeometryAnalyzer::simplifyFeature(), QgsSingleSymbolRendererV2::symbolForFeature(), QgsGraduatedSymbolRendererV2::symbolForFeature(), QgsCategorizedSymbolRendererV2::symbolForFeature(), QgsUniqueValueRenderer::symbolForFeature(), QgsGraduatedSymbolRenderer::symbolForFeature(), QgsVectorLayer::undoEditCommand(), QgsVectorDataProvider::uniqueValues(), QgsVectorLayer::uniqueValues(), QgsVectorLayerJoinBuffer::updateFeatureAttributes(), QgsVectorLayer::updateFeatureAttributes(), and QgsSearchTreeNode::valueAgainst().

void QgsFeature::changeAttribute ( int  field,
QVariant  attr 
)

Changes an existing attribute value.

Parameters
fieldindex of the field
attrattribute name and value to be set

Definition at line 133 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 218 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 113 of file qgsfeature.cpp.

References mAttributes.

Referenced by QgsVectorFileWriter::writeAsVectorFormat().

void QgsFeature::deleteAttribute ( int  field)

Deletes an attribute and its value.

Definition at line 127 of file qgsfeature.cpp.

References mAttributes.

Referenced by QgsVectorLayer::updateFeatureAttributes().

QgsGeometry * QgsFeature::geometry ( )
QgsGeometry * QgsFeature::geometryAndOwnership ( )

Get the geometry object associated with this feature The caller assumes responsibility for the QgsGeometry*'s destruction.

Definition at line 143 of file qgsfeature.cpp.

References mGeometry, and mOwnsGeometry.

Referenced by QgsVectorLayer::addIsland().

int QgsFeature::id ( ) const
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 213 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 203 of file qgsfeature.cpp.

References mValid.

Referenced by QgsVectorLayer::drawFeature().

QgsFeature & QgsFeature::operator= ( QgsFeature const &  rhs)

assignment operator needed due to internal pointer

Definition at line 54 of file qgsfeature.cpp.

References mAttributes, mDirty, mFid, mGeometry, mOwnsGeometry, mTypeName, mValid, and setGeometry().

void QgsFeature::setAttributeMap ( const QgsAttributeMap attributeMap)
void QgsFeature::setFeatureId ( int  id)

Set the feature id for this feature.

Set the feature id.

Parameters
idFeature id

Definition at line 154 of file qgsfeature.cpp.

References id(), and mFid.

Referenced by QgsVectorLayer::addFeature(), QgsVectorLayer::featureAtId(), and QgsVectorLayer::nextFeature().

void QgsFeature::setGeometry ( const QgsGeometry geom)
void QgsFeature::setGeometry ( QgsGeometry geom)

Set this feature's geometry (takes geometry ownership)

Definition at line 180 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 195 of file qgsfeature.cpp.

References QgsGeometry::fromWkb(), and setGeometry().

void QgsFeature::setTypeName ( QString  typeName)

sets the feature's type name

Definition at line 169 of file qgsfeature.cpp.

References mTypeName, and typeName().

void QgsFeature::setValid ( bool  validity)

Set the validity of the feature.

Definition at line 208 of file qgsfeature.cpp.

References mValid.

Referenced by QgsVectorLayer::featureAtId(), and QgsVectorLayer::nextFeature().

QString QgsFeature::typeName ( ) const

Member Data Documentation

QgsAttributeMap QgsFeature::mAttributes
private

map of attributes accessed by field index

Definition at line 170 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 189 of file qgsfeature.h.

Referenced by clean(), isDirty(), and operator=().

int QgsFeature::mFid
private

feature id

Definition at line 167 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 176 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 181 of file qgsfeature.h.

Referenced by geometryAndOwnership(), operator=(), setGeometry(), and ~QgsFeature().

QString QgsFeature::mTypeName
private

feature type name

Definition at line 192 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 185 of file qgsfeature.h.

Referenced by isValid(), operator=(), and setValid().


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