mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-24 00:47:57 -05:00
134 lines
3.5 KiB
Plaintext
134 lines
3.5 KiB
Plaintext
|
|
||
|
|
||
|
class QgsFeature
|
||
|
{
|
||
|
%TypeHeaderCode
|
||
|
#include <qgsfeature.h>
|
||
|
%End
|
||
|
|
||
|
public:
|
||
|
|
||
|
typedef unsigned int size_t;
|
||
|
|
||
|
//! Constructor
|
||
|
QgsFeature(int id = 0, QString typeName = "" );
|
||
|
|
||
|
/** create a copy of this feature in its uncommitted state.
|
||
|
To do this, you also pass in a reference to the feature's
|
||
|
layer's uncommitted attribute and geometry changes.
|
||
|
The resulting feature will have those changes applied.
|
||
|
|
||
|
This is useful in the cut/copy routine, where you'd
|
||
|
want a copy of the "current" feature, not the on-disk feature.
|
||
|
*/
|
||
|
QgsFeature( const QgsFeature & rhs,
|
||
|
const QMap<int, QMap<int, QgsFeatureAttribute> >& changedAttributes,
|
||
|
const QMap<int, QgsGeometry> & changedGeometries );
|
||
|
|
||
|
/** copy ctor needed due to internal pointer */
|
||
|
QgsFeature(const QgsFeature & rhs );
|
||
|
|
||
|
//! Destructor
|
||
|
~QgsFeature();
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Get the feature id for this feature
|
||
|
* @return Feature id
|
||
|
*/
|
||
|
int featureId() const;
|
||
|
|
||
|
/**
|
||
|
* Set the feature id for this feature
|
||
|
* @param id Feature id
|
||
|
*/
|
||
|
void setFeatureId(int id);
|
||
|
|
||
|
|
||
|
/** returns the feature's type name
|
||
|
*/
|
||
|
QString typeName() const;
|
||
|
|
||
|
|
||
|
/** sets the feature's type name
|
||
|
*/
|
||
|
void setTypeName(QString typeName);
|
||
|
|
||
|
/**
|
||
|
* Get the attributes for this feature.
|
||
|
* @return A std::map containing the field name/value mapping
|
||
|
*/
|
||
|
const QMap<int, QgsFeatureAttribute> & attributeMap() const;
|
||
|
|
||
|
/**
|
||
|
* Add an attribute to the map
|
||
|
*/
|
||
|
void addAttribute(int field, QgsFeatureAttribute attr);
|
||
|
|
||
|
/**Deletes an attribute and its value*/
|
||
|
void deleteAttribute(int field);
|
||
|
|
||
|
/**Changes an existing attribute value
|
||
|
@param field index of the field
|
||
|
@param attr attribute name and value to be set */
|
||
|
void changeAttribute(int field, QgsFeatureAttribute attr);
|
||
|
|
||
|
/**
|
||
|
* Get the fields for this feature
|
||
|
* @return A std::map containing field position (index) and field name
|
||
|
*/
|
||
|
QMap<int, QString> fields() 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.
|
||
|
*/
|
||
|
bool isValid() const;
|
||
|
|
||
|
/**
|
||
|
* Set the validity of the feature.
|
||
|
*/
|
||
|
void setValid(bool validity);
|
||
|
|
||
|
/**
|
||
|
* Return the dirty state of this feature.
|
||
|
* Dirty is set if (e.g.) the feature's geometry has been modified in-memory.
|
||
|
*/
|
||
|
bool isDirty() const;
|
||
|
|
||
|
/**
|
||
|
* 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)
|
||
|
*/
|
||
|
void resetDirty();
|
||
|
|
||
|
/**
|
||
|
* Get the geometry object associated with this feature
|
||
|
*/
|
||
|
QgsGeometry * geometry();
|
||
|
|
||
|
/**
|
||
|
* Get the geometry object associated with this feature
|
||
|
* The caller assumes responsibility for the QgsGeometry*'s destruction.
|
||
|
*/
|
||
|
QgsGeometry * geometryAndOwnership() /Factory/;
|
||
|
|
||
|
/** Set this feature's geometry from another QgsGeometry object (deep copy)
|
||
|
*/
|
||
|
void setGeometry(QgsGeometry& geom);
|
||
|
|
||
|
/**
|
||
|
* Set this feature's geometry from WKB
|
||
|
*
|
||
|
* This feature assumes responsibility for destroying geom.
|
||
|
*/
|
||
|
void setGeometryAndOwnership(unsigned char * geom, size_t length);
|
||
|
|
||
|
/**Returns the bounding box of this feature*/
|
||
|
QgsRect boundingBox() const;
|
||
|
|
||
|
|
||
|
}; // class QgsFeature
|
||
|
|