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

310 lines
9.0 KiB
Plaintext

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfeatureiterator.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsAbstractFeatureIterator
{
%Docstring(signature="appended")
Internal feature iterator to be implemented within data providers
%End
%TypeHeaderCode
#include "qgsfeatureiterator.h"
%End
public:
enum CompileStatus
{
NoCompilation,
PartiallyCompiled,
Compiled,
};
QgsAbstractFeatureIterator( const QgsFeatureRequest &request );
%Docstring
base class constructor - stores the iteration parameters
%End
virtual ~QgsAbstractFeatureIterator();
virtual bool nextFeature( QgsFeature &f );
%Docstring
Fetch next feature and stores in ``f``, returns ``True`` on success.
%End
virtual bool rewind() = 0;
%Docstring
Resets the iterator to the starting position.
%End
virtual bool close() = 0;
%Docstring
Call to end the iteration. This frees any resources used by the iterator.
%End
CompileStatus compileStatus() const;
%Docstring
Returns the status of expression compilation for filter expression requests.
%End
virtual bool isValid() const;
%Docstring
Returns if this iterator is valid.
An invalid feature iterator is not able to provide a reliable source for data.
If an iterator is invalid, either give up or try to send the request again (preferably
after a timeout to give the system some time to stay responsive).
If you want to check if the iterator successfully completed, better use :py:func:`QgsFeatureIterator.isClosed()`.
%End
bool compileFailed() const;
%Docstring
Indicator if there was an error when sending the compiled query to the server.
This indicates that there is something wrong with the expression compiler.
.. versionadded:: 3.2
%End
enum class RequestToSourceCrsResult
{
Success,
DistanceWithinMustBeCheckedManually,
};
protected:
virtual bool fetchFeature( QgsFeature &f ) = 0;
%Docstring
If you write a feature iterator for your provider, this is the method you
need to implement!!
:param f: The feature to write to
:return: ``True`` if a feature was written to f
%End
virtual bool nextFeatureFilterExpression( QgsFeature &f );
%Docstring
By default, the iterator will fetch all features and check if the feature
matches the expression.
If you have a more sophisticated metodology (SQL request for the features...)
and you check for the expression in your fetchFeature method, you can just
redirect this call to fetchFeature so the default check will be omitted.
:param f: The feature to write to
:return: ``True`` if a feature was written to f
%End
virtual bool nextFeatureFilterFids( QgsFeature &f );
%Docstring
By default, the iterator will fetch all features and check if the id
is in the request.
If you have a more sophisticated metodology (SQL request for the features...)
and you are sure, that any feature you return from fetchFeature will match
if the request was FilterFids you can just redirect this call to fetchFeature
so the default check will be omitted.
:param f: The feature to write to
:return: ``True`` if a feature was written to f
%End
void geometryToDestinationCrs( QgsFeature &feature, const QgsCoordinateTransform &transform ) const;
%Docstring
Transforms ``feature``'s geometry according to the specified coordinate ``transform``.
If ``feature`` has no geometry or ``transform`` is invalid then calling this method
has no effect and will be shortcut.
Iterators should call this method before returning features to ensure that any
:py:func:`QgsFeatureRequest.destinationCrs()` set on the request is respected.
%End
QgsRectangle filterRectToSourceCrs( const QgsCoordinateTransform &transform ) const throw( QgsCsException );
%Docstring
Returns a rectangle representing the original request's :py:func:`QgsFeatureRequest.filterRect()`.
If ``transform`` is a valid coordinate transform, the return rectangle will represent
the requested :py:func:`~QgsAbstractFeatureIterator.filterRect` transformed to the source's coordinate reference system.
Iterators should call this method and use the returned rectangle for filtering
features to ensure that any :py:func:`QgsFeatureRequest.destinationCrs()` set on the request is respected.
Will throw a :py:class:`QgsCsException` if the rect cannot be transformed from the destination CRS.
%End
RequestToSourceCrsResult updateRequestToSourceCrs( QgsFeatureRequest &request, const QgsCoordinateTransform &transform ) const throw( QgsCsException );
%Docstring
Update a :py:class:`QgsFeatureRequest` so that spatial filters are
transformed to the source's coordinate reference system.
Iterators should call this method against the request used for filtering
features to ensure that any :py:func:`QgsFeatureRequest.destinationCrs()` set on the request is respected.
:return: result of operation. See QgsAbstractFeatureIterator.RequestToSourceCrsResult for interpretation.
:raises QgsCsException: if the rect cannot be transformed from the destination CRS.
.. versionadded:: 3.22
%End
void ref();
%Docstring
Add reference
%End
void deref();
%Docstring
Remove reference, delete if refs == 0
%End
virtual bool prepareSimplification( const QgsSimplifyMethod &simplifyMethod );
%Docstring
Setup the simplification of geometries to fetch using the specified simplify method
%End
};
template<T>
class QgsAbstractFeatureIteratorFromSource : QgsAbstractFeatureIterator
{
%Docstring(signature="appended")
Helper template that cares of two things: 1. automatic deletion of source if owned by iterator, 2. notification of open/closed iterator.
.. note::
not available in Python bindings (although present in SIP file)
%End
%TypeHeaderCode
#include "qgsfeatureiterator.h"
%End
public:
QgsAbstractFeatureIteratorFromSource( T *source, bool ownSource, const QgsFeatureRequest &request );
~QgsAbstractFeatureIteratorFromSource();
protected:
void iteratorClosed();
%Docstring
to be called by from subclass in :py:func:`~QgsAbstractFeatureIteratorFromSource.close`
%End
};
class QgsFeatureIterator
{
%Docstring(signature="appended")
Wrapper for iterator of features from vector data provider or vector layer
%End
%TypeHeaderCode
#include "qgsfeatureiterator.h"
%End
public:
QgsFeatureIterator *__iter__();
%MethodCode
sipRes = sipCpp;
%End
SIP_PYOBJECT __next__() /TypeHint="QgsFeature"/;
%MethodCode
std::unique_ptr< QgsFeature > f = std::make_unique< QgsFeature >();
bool result = false;
Py_BEGIN_ALLOW_THREADS
result = ( sipCpp->nextFeature( *f ) );
Py_END_ALLOW_THREADS
if ( result )
sipRes = sipConvertFromType( f.release(), sipType_QgsFeature, Py_None );
else
{
PyErr_SetString( PyExc_StopIteration, "" );
}
%End
QgsFeatureIterator();
%Docstring
Construct invalid iterator
%End
QgsFeatureIterator( QgsAbstractFeatureIterator *iter /Transfer/ );
%Docstring
Construct a valid iterator
%End
QgsFeatureIterator( const QgsFeatureIterator &fi );
%Docstring
Copy constructor copies the iterator, increases ref.count
%End
~QgsFeatureIterator();
bool nextFeature( QgsFeature &f );
%Docstring
Fetch next feature and stores in ``f``, returns ``True`` on success.
%End
bool rewind();
%Docstring
Resets the iterator to the starting position.
%End
bool close();
%Docstring
Call to end the iteration. This frees any resources used by the iterator.
%End
bool isValid() const;
%Docstring
Will return if this iterator is valid.
An invalid iterator was probably introduced by a failed attempt to acquire a connection
or is a default constructed iterator.
.. seealso:: :py:func:`isClosed` to check if the iterator successfully completed and returned all the features.
%End
bool isClosed() const;
%Docstring
find out whether the iterator is still valid or closed already
%End
QgsAbstractFeatureIterator::CompileStatus compileStatus() const;
%Docstring
Returns the status of expression compilation for filter expression requests.
%End
bool compileFailed() const;
%Docstring
Indicator if there was an error when sending the compiled query to the server.
This indicates that there is something wrong with the expression compiler.
.. versionadded:: 3.2
%End
protected:
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfeatureiterator.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/