QGIS/python/core/auto_generated/qgsfeature.sip.in

544 lines
12 KiB
Plaintext
Raw Normal View History

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfeature.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2017-03-27 14:41:33 +02:00
2017-03-27 14:41:33 +02:00
class QgsFeature
{
%Docstring
2017-12-15 10:36:55 -04:00
The feature class encapsulates a single feature including its id,
geometry and a list of field/values attributes.
.. note::
QgsFeature objects are implicitly shared.
2017-03-27 14:41:33 +02:00
%End
%TypeHeaderCode
#include "qgsfeature.h"
#if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c01)
#define sipType_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
#endif
%End
public:
static const QMetaObject staticMetaObject;
public:
2013-08-03 22:42:13 +10:00
SIP_PYOBJECT __iter__();
%MethodCode
2015-05-21 05:49:01 +10:00
QgsAttributes attributes = sipCpp->attributes();
PyObject *attrs = sipConvertFromType( &attributes, sipType_QgsAttributes, Py_None );
2017-03-27 14:41:33 +02:00
sipRes = PyObject_GetIter( attrs );
2013-08-03 22:42:13 +10:00
%End
2017-03-27 14:41:33 +02:00
SIP_PYOBJECT __getitem__( int key );
%MethodCode
2017-03-27 14:41:33 +02:00
QgsAttributes attrs = sipCpp->attributes();
if ( a0 < 0 || a0 >= attrs.count() )
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
else
{
QVariant *v = new QVariant( attrs.at( a0 ) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
%End
2017-03-27 14:41:33 +02:00
SIP_PYOBJECT __getitem__( const QString &name );
%MethodCode
2017-03-27 14:41:33 +02:00
int fieldIdx = sipCpp->fieldNameIndex( *a0 );
if ( fieldIdx == -1 )
{
PyErr_SetString( PyExc_KeyError, a0->toAscii() );
sipIsErr = 1;
}
else
{
QVariant *v = new QVariant( sipCpp->attribute( fieldIdx ) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
%End
2017-03-27 14:41:33 +02:00
void __setitem__( int key, QVariant value /GetWrapper/ );
%MethodCode
2017-03-27 14:41:33 +02:00
bool rv;
2017-03-27 14:41:33 +02:00
if ( a1Wrapper == Py_None )
{
rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) );
}
else
{
rv = sipCpp->setAttribute( a0, *a1 );
}
2017-03-27 14:41:33 +02:00
if ( !rv )
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
%End
2017-03-27 14:41:33 +02:00
void __setitem__( const QString &key, QVariant value /GetWrapper/ );
%MethodCode
2017-03-27 14:41:33 +02:00
int fieldIdx = sipCpp->fieldNameIndex( *a0 );
if ( fieldIdx == -1 )
{
2017-03-27 14:41:33 +02:00
PyErr_SetString( PyExc_KeyError, a0->toAscii() );
sipIsErr = 1;
}
else
{
2017-03-27 14:41:33 +02:00
if ( a1Wrapper == Py_None )
{
sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
}
else
{
sipCpp->setAttribute( fieldIdx, *a1 );
}
}
%End
2017-03-27 14:41:33 +02:00
void __delitem__( int key );
%MethodCode
2017-03-27 14:41:33 +02:00
if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
sipCpp->deleteAttribute( a0 );
else
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
%End
2017-03-27 14:41:33 +02:00
void __delitem__( const QString &name );
%MethodCode
2017-03-27 14:41:33 +02:00
int fieldIdx = sipCpp->fieldNameIndex( *a0 );
if ( fieldIdx == -1 )
{
PyErr_SetString( PyExc_KeyError, a0->toAscii() );
sipIsErr = 1;
}
else
sipCpp->deleteAttribute( fieldIdx );
%End
QgsFeature( qint64 id = 0 );
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsFeature
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param id: feature id
%End
QgsFeature( const QgsFields &fields, qint64 id = 0 );
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsFeature
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param fields: feature's fields
:param id: feature id
%End
QgsFeature( const QgsFeature &rhs );
%Docstring
2017-12-15 10:36:55 -04:00
Copy constructor
%End
2017-03-27 14:41:33 +02:00
virtual ~QgsFeature();
QgsFeatureId id() const;
%Docstring
Gets the feature ID for this feature.
2017-12-15 10:36:55 -04:00
:return: feature ID
.. seealso:: :py:func:`setId`
%End
void setId( QgsFeatureId id );
%Docstring
2017-12-15 10:36:55 -04:00
Sets the feature ID for this feature.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param id: feature id
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`id`
%End
QgsAttributes attributes() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the feature's attributes.
:return: list of feature's attributes
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setAttributes`
2017-12-15 10:36:55 -04:00
.. note::
Alternatively in Python: iterate feature, eg. @code [attr for attr in feature] @endcode
2018-05-28 11:31:08 -04:00
.. versionadded:: 2.9
%End
void setAttributes( const QgsAttributes &attrs );
%Docstring
2017-12-15 10:36:55 -04:00
Sets the feature's attributes.
The feature will be valid after.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param attrs: attribute list
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setAttribute`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`attributes`
%End
2017-03-27 14:41:33 +02:00
bool setAttribute( int field, const QVariant &attr /GetWrapper/ );
%Docstring
2017-12-15 10:36:55 -04:00
Set an attribute's value by field index.
The feature will be valid if it was successful.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param field: the index of the field to set
:param attr: the value of the attribute
:return: false, if the field index does not exist
.. note::
For Python: raises a KeyError exception instead of returning false
2017-12-15 10:36:55 -04:00
.. note::
Alternatively in Python: @code feature[field] = attr @endcode
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setAttributes`
%End
%MethodCode
2017-03-27 14:41:33 +02:00
bool rv;
2017-03-27 14:41:33 +02:00
if ( a1Wrapper == Py_None )
{
rv = sipCpp->setAttribute( a0, QVariant( QVariant::Int ) );
}
else
{
rv = sipCpp->setAttribute( a0, *a1 );
}
2017-03-27 14:41:33 +02:00
if ( !rv )
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
2017-03-27 14:41:33 +02:00
sipRes = rv;
%End
void initAttributes( int fieldCount );
%Docstring
2017-12-15 10:36:55 -04:00
Initialize this feature with the given number of fields. Discard any previously set attribute data.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param fieldCount: Number of fields to initialize
%End
void deleteAttribute( int field );
%Docstring
2017-12-15 10:36:55 -04:00
Deletes an attribute and its value.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param field: the index of the field
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setAttribute`
2017-12-15 10:36:55 -04:00
.. note::
For Python: raises a KeyError exception if the field is not found
2017-12-15 10:36:55 -04:00
.. note::
Alternatively in Python: @code del feature[field] @endcode
%End
%MethodCode
2017-03-27 14:41:33 +02:00
if ( a0 >= 0 && a0 < sipCpp->attributes().count() )
sipCpp->deleteAttribute( a0 );
else
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
%End
bool isValid() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns 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.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setValid`
%End
void setValid( bool validity );
%Docstring
2017-12-15 10:36:55 -04:00
Sets the validity of the feature.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param validity: set to true if feature is valid
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`isValid`
%End
bool hasGeometry() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns true if the feature has an associated geometry.
.. seealso:: :py:func:`geometry`
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0.
%End
QgsGeometry geometry() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the geometry associated with this feature. If the feature has no geometry,
an empty QgsGeometry object will be returned.
.. seealso:: :py:func:`hasGeometry`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`setGeometry`
%End
void setGeometry( const QgsGeometry &geometry );
%Docstring
2017-12-15 10:36:55 -04:00
Set the feature's geometry. The feature will be valid after.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param geometry: new feature geometry
.. seealso:: :py:func:`geometry`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`clearGeometry`
%End
void clearGeometry();
%Docstring
2017-12-15 10:36:55 -04:00
Removes any geometry associated with the feature.
.. seealso:: :py:func:`setGeometry`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`hasGeometry`
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
void setFields( const QgsFields &fields, bool initAttributes = true );
%Docstring
2017-12-15 10:36:55 -04:00
Assign a field map with the feature to allow attribute access by attribute name.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param fields: The attribute fields which this feature holds
:param initAttributes: If true, attributes are initialized. Clears any data previously assigned.
C++: Defaults to false
Python: Defaults to true
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`fields`
2018-05-28 11:31:08 -04:00
.. versionadded:: 2.9
%End
QgsFields fields() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the field map associated with the feature.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setFields`
%End
void setAttribute( const QString &name, const QVariant &value /GetWrapper/ );
%Docstring
2017-12-15 10:36:55 -04:00
Insert a value into attribute. Returns false if attribute name could not be converted to index.
Field map must be associated using setFields() before this method can be used.
The feature will be valid if it was successful
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param name: The name of the field to set
:param value: The value to set
:return: false if attribute name could not be converted to index (C++ only)
.. note::
For Python: raises a KeyError exception instead of returning false
2017-12-15 10:36:55 -04:00
.. note::
Alternatively in Python: @code feature[name] = attr @endcode
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setFields`
%End
%MethodCode
2017-03-27 14:41:33 +02:00
int fieldIdx = sipCpp->fieldNameIndex( *a0 );
if ( fieldIdx == -1 )
{
2017-03-27 14:41:33 +02:00
PyErr_SetString( PyExc_KeyError, a0->toAscii() );
sipIsErr = 1;
}
else
{
2017-03-27 14:41:33 +02:00
if ( a1Wrapper == Py_None )
{
sipCpp->setAttribute( *a0, QVariant( QVariant::Int ) );
}
else
{
sipCpp->setAttribute( fieldIdx, *a1 );
}
}
%End
bool deleteAttribute( const QString &name );
%Docstring
2017-12-15 10:36:55 -04:00
Removes an attribute value by field name. Field map must be associated using setFields()
before this method can be used.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param name: The name of the field to delete
:return: false if attribute name could not be converted to index (C++ only)
.. note::
For Python: raises a KeyError exception instead of returning false
2017-12-15 10:36:55 -04:00
.. note::
Alternatively in Python: @code del feature[name] @endcode
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setFields`
%End
%MethodCode
2017-03-27 14:41:33 +02:00
int fieldIdx = sipCpp->fieldNameIndex( *a0 );
if ( fieldIdx == -1 )
{
PyErr_SetString( PyExc_KeyError, a0->toAscii() );
sipIsErr = 1;
sipRes = false;
}
else
{
sipCpp->deleteAttribute( fieldIdx );
sipRes = true;
}
%End
SIP_PYOBJECT attribute( const QString &name ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Lookup attribute value from attribute name. Field map must be associated using setFields()
before this method can be used.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param name: The name of the attribute to get
:return: The value of the attribute (C++: Invalid variant if no such name exists )
.. note::
For Python: raises a KeyError exception if the field is not found
2017-12-15 10:36:55 -04:00
.. note::
Alternatively in Python: @code feature[name] @endcode
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setFields`
%End
%MethodCode
2017-03-27 14:41:33 +02:00
int fieldIdx = sipCpp->fieldNameIndex( *a0 );
if ( fieldIdx == -1 )
{
2017-03-27 14:41:33 +02:00
PyErr_SetString( PyExc_KeyError, a0->toAscii() );
sipIsErr = 1;
}
else
{
2017-03-27 14:41:33 +02:00
QVariant *v = new QVariant( sipCpp->attribute( fieldIdx ) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
2017-03-27 14:41:33 +02:00
%End
SIP_PYOBJECT attribute( int fieldIdx ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Lookup attribute value from its index. Field map must be associated using setFields()
before this method can be used.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param fieldIdx: The index of the attribute to get
:return: The value of the attribute (C++: Invalid variant if no such index exists )
.. note::
For Python: raises a KeyError exception if the field is not found
2017-12-15 10:36:55 -04:00
.. note::
Alternatively in Python: @code feature[fieldIdx] @endcode
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setFields`
%End
2017-03-27 14:41:33 +02:00
%MethodCode
{
if ( a0 < 0 || a0 >= sipCpp->attributes().count() )
{
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
sipIsErr = 1;
}
else
{
QVariant *v = new QVariant( sipCpp->attribute( a0 ) );
sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
}
}
%End
int fieldNameIndex( const QString &fieldName ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Utility method to get attribute index from name. Field map must be associated using setFields()
before this method can be used.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param fieldName: name of field to get attribute index of
:return: -1 if field does not exist or field map is not associated.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`setFields`
%End
operator QVariant() const;
}; // class QgsFeature
2017-03-27 14:41:33 +02:00
typedef QMap<qint64, QMap<int, QVariant> > QgsChangedAttributesMap;
2017-05-12 09:47:03 +02:00
2017-03-27 14:41:33 +02:00
typedef QMap<qint64, QgsGeometry> QgsGeometryMap;
typedef QSet<qint64> QgsFeatureIds;
2017-03-27 14:41:33 +02:00
typedef QList<QgsFeature> QgsFeatureList;
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfeature.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/