1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
/************************************************************************
* 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 /BaseType=IntEnum/
{
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 /BaseType=IntEnum/
{
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 *
************************************************************************/
|