48 , mAttributes( rhs.mAttributes )
50 , mOwnsGeometry( false )
51 , mValid( rhs.mValid )
52 , mFields( rhs.mFields )
69 mAttributes = rhs.mAttributes;
71 mFields = rhs.mFields;
74 if ( mGeometry && mOwnsGeometry )
78 mOwnsGeometry =
false;
92 if ( mOwnsGeometry && mGeometry )
108 mAttributes.remove( field );
119 mOwnsGeometry =
false;
142 if ( mOwnsGeometry && mGeometry )
149 mOwnsGeometry =
true;
183 mAttributes.resize( fieldCount );
184 QVariant* ptr = mAttributes.data();
185 for (
int i = 0; i < fieldCount; ++i, ++ptr )
192 if ( idx < 0 || idx >= mAttributes.size() )
198 mAttributes[idx] = value;
205 if ( fieldIdx == -1 )
208 mAttributes[fieldIdx] = value;
215 if ( fieldIdx == -1 )
218 mAttributes[fieldIdx].clear();
224 if ( fieldIdx < 0 || fieldIdx >= mAttributes.count() )
226 return mAttributes[fieldIdx];
233 if ( fieldIdx == -1 )
236 return mAttributes[fieldIdx];
241 for (
int i = 0; i < mFields.
count(); ++i )
243 if ( QString::compare( mFields.
at( i ).
name(), fieldName, Qt::CaseInsensitive ) == 0 )
QgsFeatureId id() const
Get the feature id for this feature.
const QString & name() const
Gets the name of the field.
bool isValid() const
Return the validity of this feature.
int fieldNameIndex(const QString &fieldName) const
Utility method to get attribute index from name.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
Container of fields for a vector layer.
bool setAttribute(int field, const QVariant &attr)
Set an attribute by id.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
void deleteAttribute(int field)
Deletes an attribute and its value.
void setFeatureId(QgsFeatureId id)
Set the feature id for this feature.
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
const QgsFields * fields() const
Get associated field map.
int count() const
Return number of items.
QgsFeature & operator=(QgsFeature const &rhs)
assignment operator needed due to internal pointer
void setFields(const QgsFields *fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
QgsFeature(QgsFeatureId id=QgsFeatureId())
Constructor.
void setValid(bool validity)
Set the validity of the feature.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
void fromWkb(unsigned char *wkb, size_t length)
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length...
QgsGeometry * geometryAndOwnership()
Get the geometry object associated with this feature The caller assumes responsibility for the QgsGeo...
void setGeometryAndOwnership(unsigned char *geom, size_t length)
Set this feature's geometry from WKB.