QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsfeaturerequest.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturerequest.cpp
3  ---------------------
4  begin : Mai 2012
5  copyright : (C) 2012 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "qgsfeaturerequest.h"
16 
17 #include "qgsfields.h"
18 #include "qgsgeometry.h"
19 #include "qgsgeometryengine.h"
20 
21 #include <QStringList>
22 
23 //constants
24 const QString QgsFeatureRequest::ALL_ATTRIBUTES = QStringLiteral( "#!allattributes!#" );
25 
27 {
28 }
29 
31 
33  : mFilter( FilterFid )
34  , mFilterFid( fid )
35 {
36 }
37 
39  : mFilter( FilterFids )
40  , mFilterFids( fids )
41 {
42 
43 }
44 
46  : mSpatialFilter( !rect.isNull() ? Qgis::SpatialFilterType::BoundingBox : Qgis::SpatialFilterType::NoFilter )
47  , mFilterRect( rect )
48 {
49 }
50 
52  : mFilter( FilterExpression )
53  , mFilterExpression( new QgsExpression( expr ) )
54  , mExpressionContext( context )
55 {
56 }
57 
59 {
60  operator=( rh );
61 }
62 
64 {
65  if ( &rh == this )
66  return *this;
67 
68  mFlags = rh.mFlags;
69  mFilter = rh.mFilter;
77  if ( rh.mFilterExpression )
78  {
80  }
81  else
82  {
83  mFilterExpression.reset( nullptr );
84  }
88  mAttrs = rh.mAttrs;
90  mLimit = rh.mLimit;
91  mOrderBy = rh.mOrderBy;
92  mCrs = rh.mCrs;
95  mTimeout = rh.mTimeout;
97  mFeedback = rh.mFeedback;
98  return *this;
99 }
100 
102 {
103  mFilterRect = rect;
105  mDistanceWithin = 0;
106  if ( mFilterRect.isNull() )
107  {
109  }
110  else
111  {
113  }
114  return *this;
115 }
116 
118 {
119  return mFilterRect;
120 }
121 
123 {
124  mReferenceGeometry = geometry;
125  if ( !mReferenceGeometry.isEmpty() )
126  {
128  mReferenceGeometryEngine->prepareGeometry();
129  }
130  else
131  {
132  mReferenceGeometryEngine.reset();
133  }
134  mDistanceWithin = distance;
137 
138  return *this;
139 }
140 
142 {
143  mFilter = FilterFid;
144  mFilterFid = fid;
145  return *this;
146 }
147 
149 {
151  mFilterFids = fids;
152  return *this;
153 }
154 
156 {
157  mInvalidGeometryFilter = check;
158  return *this;
159 }
160 
161 QgsFeatureRequest &QgsFeatureRequest::setInvalidGeometryCallback( const std::function<void ( const QgsFeature & )> &callback )
162 {
163  mInvalidGeometryCallback = callback;
164  return *this;
165 }
166 
168 {
170  mFilterExpression.reset( new QgsExpression( expression ) );
171  return *this;
172 }
173 
175 {
176  if ( mFilterExpression )
177  {
178  setFilterExpression( QStringLiteral( "(%1) AND (%2)" ).arg( mFilterExpression->expression(), expression ) );
179  }
180  else
181  {
182  setFilterExpression( expression );
183  }
184  return *this;
185 }
186 
188 {
189  mExpressionContext = context;
190  return *this;
191 }
192 
193 QgsFeatureRequest &QgsFeatureRequest::addOrderBy( const QString &expression, bool ascending )
194 {
195  mOrderBy.append( OrderByClause( expression, ascending ) );
196  return *this;
197 }
198 
199 QgsFeatureRequest &QgsFeatureRequest::addOrderBy( const QString &expression, bool ascending, bool nullsfirst )
200 {
201  mOrderBy.append( OrderByClause( expression, ascending, nullsfirst ) );
202  return *this;
203 }
204 
206 {
207  return mOrderBy;
208 }
209 
211 {
212  mOrderBy = orderBy;
213  return *this;
214 }
215 
217 {
218  mLimit = limit;
219  return *this;
220 }
221 
222 QgsFeatureRequest &QgsFeatureRequest::setFlags( QgsFeatureRequest::Flags flags )
223 {
224  mFlags = flags;
225  return *this;
226 }
227 
229 {
231  mAttrs = attrs;
232  return *this;
233 }
234 
236 {
238 }
239 
240 QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QStringList &attrNames, const QgsFields &fields )
241 {
242  if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) )
243  {
244  //attribute string list contains the all attributes flag, so we must fetch all attributes
245  return *this;
246  }
247 
249  mAttrs.clear();
250 
251  const auto constAttrNames = attrNames;
252  for ( const QString &attrName : constAttrNames )
253  {
254  const int attrNum = fields.lookupField( attrName );
255  if ( attrNum != -1 && !mAttrs.contains( attrNum ) )
256  mAttrs.append( attrNum );
257  }
258 
259  return *this;
260 }
261 
262 QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QSet<QString> &attrNames, const QgsFields &fields )
263 {
264  if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) )
265  {
266  //attribute string list contains the all attributes flag, so we must fetch all attributes
267  return *this;
268  }
269 
271  mAttrs.clear();
272 
273  const auto constAttrNames = attrNames;
274  for ( const QString &attrName : constAttrNames )
275  {
276  const int attrNum = fields.lookupField( attrName );
277  if ( attrNum != -1 && !mAttrs.contains( attrNum ) )
278  mAttrs.append( attrNum );
279  }
280 
281  return *this;
282 }
283 
285 {
287  return *this;
288 }
289 
290 
292 {
293  return mCrs;
294 }
295 
297 {
298  return mTransformContext;
299 }
300 
302 {
303  mCrs = crs;
304  mTransformContext = context;
305  return *this;
306 }
307 
308 QgsFeatureRequest &QgsFeatureRequest::setTransformErrorCallback( const std::function<void ( const QgsFeature & )> &callback )
309 {
310  mTransformErrorCallback = callback;
311  return *this;
312 }
313 
315 {
316  // check the attribute/id filter first, it's more likely to be faster than
317  // the spatial filter
318  switch ( mFilter )
319  {
321  break;
322 
324  if ( feature.id() != mFilterFid )
325  return false;
326  break;
327 
329  mExpressionContext.setFeature( feature );
330  if ( !mFilterExpression->evaluate( &mExpressionContext ).toBool() )
331  return false;
332  break;
333 
335  if ( !mFilterFids.contains( feature.id() ) )
336  return false;
337  break;
338  }
339 
340  switch ( mSpatialFilter )
341  {
343  break;
344 
346  if ( !feature.hasGeometry() ||
347  (
348  ( mFlags & ExactIntersect && !feature.geometry().intersects( mFilterRect ) )
349  ||
351  )
352  )
353  return false;
354  break;
355 
357  if ( !feature.hasGeometry()
360  || !mReferenceGeometryEngine->distanceWithin( feature.geometry().constGet(), mDistanceWithin )
361  )
362  return false;
363  break;
364  }
365 
366  return true;
367 }
368 
370 {
371  return mTimeout;
372 }
373 
375 {
377  return *this;
378 }
379 
381 {
382  return mTimeout;
383 }
384 
386 {
387  mTimeout = timeout;
388  return *this;
389 }
390 
392 {
393  return mRequestMayBeNested;
394 }
395 
397 {
399  return *this;
400 }
401 
403 {
405 }
406 
408 {
409  return mFeedback;
410 }
411 
412 
413 #include "qgsfeatureiterator.h"
414 #include "qgslogger.h"
415 
417 {
418  while ( !mActiveIterators.empty() )
419  {
421  QgsDebugMsgLevel( QStringLiteral( "closing active iterator" ), 2 );
422  it->close();
423  }
424 }
425 
427 {
428  mActiveIterators.insert( it );
429 }
430 
432 {
433  mActiveIterators.remove( it );
434 }
435 
436 
437 
438 QgsFeatureRequest::OrderByClause::OrderByClause( const QString &expression, bool ascending )
439  : mExpression( expression )
440  , mAscending( ascending )
441 {
442  // postgres behavior: default for ASC: NULLS LAST, default for DESC: NULLS FIRST
443  mNullsFirst = !ascending;
444 }
445 
446 QgsFeatureRequest::OrderByClause::OrderByClause( const QString &expression, bool ascending, bool nullsfirst )
447  : mExpression( expression )
448  , mAscending( ascending )
449  , mNullsFirst( nullsfirst )
450 {
451 }
452 
454  : mExpression( expression )
455  , mAscending( ascending )
456 {
457  // postgres behavior: default for ASC: NULLS LAST, default for DESC: NULLS FIRST
458  mNullsFirst = !ascending;
459 }
460 
461 QgsFeatureRequest::OrderByClause::OrderByClause( const QgsExpression &expression, bool ascending, bool nullsfirst )
462  : mExpression( expression )
463  , mAscending( ascending )
464  , mNullsFirst( nullsfirst )
465 {
466 
467 }
468 
470 {
471  return mAscending;
472 }
473 
475 {
476  mAscending = ascending;
477 }
478 
480 {
481  return mNullsFirst;
482 }
483 
485 {
486  mNullsFirst = nullsFirst;
487 }
488 
490 {
491  return QStringLiteral( "%1 %2 %3" )
492  .arg( mExpression.expression(),
493  mAscending ? "ASC" : "DESC",
494  mNullsFirst ? "NULLS FIRST" : "NULLS LAST" );
495 }
496 
498 {
499  return mExpression;
500 }
501 
503 {
504  return mExpression.prepare( context );
505 }
506 
508 
509 QgsFeatureRequest::OrderBy::OrderBy( const QList<QgsFeatureRequest::OrderByClause> &other )
510 {
511  const auto constOther = other;
512  for ( const QgsFeatureRequest::OrderByClause &clause : constOther )
513  {
514  append( clause );
515  }
516 }
517 
518 QList<QgsFeatureRequest::OrderByClause> QgsFeatureRequest::OrderBy::list() const
519 {
520  return *this;
521 }
522 
523 void QgsFeatureRequest::OrderBy::save( QDomElement &elem ) const
524 {
525  QDomDocument doc = elem.ownerDocument();
526  QList<OrderByClause>::ConstIterator it;
527  for ( it = constBegin(); it != constEnd(); ++it )
528  {
529  const OrderByClause &clause = *it;
530  QDomElement clauseElem = doc.createElement( QStringLiteral( "orderByClause" ) );
531  clauseElem.setAttribute( QStringLiteral( "asc" ), clause.ascending() );
532  clauseElem.setAttribute( QStringLiteral( "nullsFirst" ), clause.nullsFirst() );
533  clauseElem.appendChild( doc.createTextNode( clause.expression().expression() ) );
534 
535  elem.appendChild( clauseElem );
536  }
537 }
538 
539 void QgsFeatureRequest::OrderBy::load( const QDomElement &elem )
540 {
541  clear();
542 
543  const QDomNodeList clauses = elem.childNodes();
544 
545  for ( int i = 0; i < clauses.size(); ++i )
546  {
547  const QDomElement clauseElem = clauses.at( i ).toElement();
548  const QString expression = clauseElem.text();
549  const bool asc = clauseElem.attribute( QStringLiteral( "asc" ) ).toInt() != 0;
550  const bool nullsFirst = clauseElem.attribute( QStringLiteral( "nullsFirst" ) ).toInt() != 0;
551 
552  append( OrderByClause( expression, asc, nullsFirst ) );
553  }
554 }
555 
557 {
558  QSet<QString> usedAttributes;
559 
560  QList<OrderByClause>::ConstIterator it;
561  for ( it = constBegin(); it != constEnd(); ++it )
562  {
563  const OrderByClause &clause = *it;
564 
565  usedAttributes.unite( clause.expression().referencedColumns() );
566  }
567 
568  return usedAttributes;
569 }
570 
572 {
573  QSet<int> usedAttributeIdx;
574  for ( const OrderByClause &clause : *this )
575  {
576  const auto referencedColumns = clause.expression().referencedColumns();
577  for ( const QString &fieldName : referencedColumns )
578  {
579  const int idx = fields.lookupField( fieldName );
580  if ( idx >= 0 )
581  {
582  usedAttributeIdx.insert( idx );
583  }
584  }
585  }
586  return usedAttributeIdx;
587 }
588 
590 {
591  QStringList results;
592 
593  QList<OrderByClause>::ConstIterator it;
594  for ( it = constBegin(); it != constEnd(); ++it )
595  {
596  const OrderByClause &clause = *it;
597 
598  results << clause.dump();
599  }
600 
601  return results.join( QLatin1String( ", " ) );
602 }
QgsFeatureRequest::mSimplifyMethod
QgsSimplifyMethod mSimplifyMethod
Definition: qgsfeaturerequest.h:998
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
qgsfields.h
QgsFeatureRequest::OrderByClause
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
Definition: qgsfeaturerequest.h:152
QgsFeatureRequest::FilterFid
@ FilterFid
Filter using feature ID.
Definition: qgsfeaturerequest.h:116
QgsFeatureRequest::mFeedback
QgsFeedback * mFeedback
Definition: qgsfeaturerequest.h:1008
QgsFeatureRequest::OrderByClause::expression
QgsExpression expression() const
The expression.
Definition: qgsfeaturerequest.cpp:497
QgsFeatureRequest::mInvalidGeometryFilter
InvalidGeometryCheck mInvalidGeometryFilter
Definition: qgsfeaturerequest.h:1001
QgsFeatureRequest::setInvalidGeometryCheck
QgsFeatureRequest & setInvalidGeometryCheck(InvalidGeometryCheck check)
Sets invalid geometry checking behavior.
Definition: qgsfeaturerequest.cpp:155
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
qgsfeaturerequest.h
QgsSimplifyMethod
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
Definition: qgssimplifymethod.h:28
QgsFeatureRequest::mFilterFids
QgsFeatureIds mFilterFids
Definition: qgsfeaturerequest.h:993
QgsFeatureRequest::addOrderBy
QgsFeatureRequest & addOrderBy(const QString &expression, bool ascending=true)
Adds a new OrderByClause, appending it as the least important one.
Definition: qgsfeaturerequest.cpp:193
Qgis::SpatialFilterType::NoFilter
@ NoFilter
No spatial filtering of features.
QgsFeatureRequest::feedback
QgsFeedback * feedback() const
Returns the feedback object that can be queried regularly by the iterator to check if it should be ca...
Definition: qgsfeaturerequest.cpp:407
QgsFeatureRequest::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
Definition: qgsfeaturerequest.cpp:296
QgsFeatureRequest::ExactIntersect
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
Definition: qgsfeaturerequest.h:117
QgsFeatureRequest::acceptFeature
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
Definition: qgsfeaturerequest.cpp:314
QgsAbstractFeatureSource::~QgsAbstractFeatureSource
virtual ~QgsAbstractFeatureSource()
Definition: qgsfeaturerequest.cpp:416
QgsExpression::referencedColumns
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
Definition: qgsexpression.cpp:221
QgsFeatureRequest::OrderBy::OrderBy
CORE_EXPORT OrderBy()
Create a new empty order by.
QgsFeatureRequest::OrderByClause::setAscending
void setAscending(bool ascending)
Set if ascending order is requested.
Definition: qgsfeaturerequest.cpp:474
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsFeatureRequest::OrderBy::save
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
Definition: qgsfeaturerequest.cpp:523
QgsFeatureRequest::operator=
QgsFeatureRequest & operator=(const QgsFeatureRequest &rh)
Assignment operator.
Definition: qgsfeaturerequest.cpp:63
QgsFeatureRequest::mDistanceWithin
double mDistanceWithin
Maximum distance from reference geometry.
Definition: qgsfeaturerequest.h:990
QgsFeatureRequest::timeout
int timeout() const
Returns the timeout (in milliseconds) for the maximum time we should wait during feature requests bef...
Definition: qgsfeaturerequest.cpp:380
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsFeatureRequest::mCrs
QgsCoordinateReferenceSystem mCrs
Definition: qgsfeaturerequest.h:1004
qgsfeatureiterator.h
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsFeatureRequest::FilterFids
@ FilterFids
Filter using feature IDs.
Definition: qgsfeaturerequest.h:118
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:71
QgsAbstractFeatureSource::mActiveIterators
QSet< QgsAbstractFeatureIterator * > mActiveIterators
Definition: qgsfeaturerequest.h:1032
QgsFeatureRequest::mReferenceGeometry
QgsGeometry mReferenceGeometry
Reference geometry for Qgis::RequestSpatialFilter::DistanceWithin filtering.
Definition: qgsfeaturerequest.h:980
QgsFeatureRequest::filterRect
QgsRectangle filterRect() const
Returns the rectangle from which features will be taken.
Definition: qgsfeaturerequest.cpp:117
QgsFeatureRequest::setInvalidGeometryCallback
QgsFeatureRequest & setInvalidGeometryCallback(const std::function< void(const QgsFeature &)> &callback)
Sets a callback function to use when encountering an invalid geometry and invalidGeometryCheck() is s...
Definition: qgsfeaturerequest.cpp:161
QgsFeatureRequest::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for feature's geometries, or an invalid QgsCoordi...
Definition: qgsfeaturerequest.cpp:291
QgsFeatureRequest::setSubsetOfAttributes
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Definition: qgsfeaturerequest.cpp:228
QgsFeatureRequest::InvalidGeometryCheck
InvalidGeometryCheck
Handling of features with invalid geometries.
Definition: qgsfeaturerequest.h:122
QgsAttributeList
QList< int > QgsAttributeList
Definition: qgsfield.h:26
QgsFeatureRequest::OrderByClause::prepare
bool prepare(QgsExpressionContext *context)
Prepare the expression with the given context.
Definition: qgsfeaturerequest.cpp:502
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsFeatureRequest::SubsetOfAttributes
@ SubsetOfAttributes
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
Definition: qgsfeaturerequest.h:116
QgsFeatureRequest::OrderBy::usedAttributes
QSet< QString > CORE_EXPORT usedAttributes() const
Returns a set of used attributes.
Definition: qgsfeaturerequest.cpp:556
QgsFeatureRequest::mRequestMayBeNested
int mRequestMayBeNested
Definition: qgsfeaturerequest.h:1007
QgsFeatureRequest::setExpressionContext
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
Definition: qgsfeaturerequest.cpp:187
QgsFeatureRequest::setFilterFid
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
Definition: qgsfeaturerequest.cpp:141
QgsFeatureRequest::flags
Flags flags() const
Returns the flags which affect how features are fetched.
Definition: qgsfeaturerequest.h:673
QgsFeatureRequest::setDistanceWithin
QgsFeatureRequest & setDistanceWithin(const QgsGeometry &geometry, double distance)
Sets a reference geometry and a maximum distance from this geometry to retrieve features within.
Definition: qgsfeaturerequest.cpp:122
QgsFeatureRequest::setFilterExpression
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
Definition: qgsfeaturerequest.cpp:167
QgsFeatureRequest::OrderByClause::setNullsFirst
void setNullsFirst(bool nullsFirst)
Set if NULLS should be returned first.
Definition: qgsfeaturerequest.cpp:484
QgsFeatureRequest::QgsFeatureRequest
QgsFeatureRequest()
construct a default request: for all features get attributes and geometries
Definition: qgsfeaturerequest.cpp:26
QgsFeatureRequest::OrderByClause::dump
QString dump() const
Dumps the content to an SQL equivalent.
Definition: qgsfeaturerequest.cpp:489
QgsFeatureRequest::mExpressionContext
QgsExpressionContext mExpressionContext
Definition: qgsfeaturerequest.h:995
QgsFeatureRequest::setFilterRect
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
Definition: qgsfeaturerequest.cpp:101
QgsFeatureRequest::ALL_ATTRIBUTES
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
Definition: qgsfeaturerequest.h:317
QgsFeature::id
QgsFeatureId id
Definition: qgsfeature.h:68
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:83
qgsgeometryengine.h
QgsGeometry::intersects
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
Definition: qgsgeometry.cpp:1255
QgsFeatureRequest::setConnectionTimeout
Q_DECL_DEPRECATED QgsFeatureRequest & setConnectionTimeout(int connectionTimeout)
Sets the timeout (in milliseconds) for how long we should wait for a connection if none is available ...
Definition: qgsfeaturerequest.cpp:374
QgsFeatureRequest::mFilterExpression
std::unique_ptr< QgsExpression > mFilterExpression
Definition: qgsfeaturerequest.h:994
QgsFeatureRequest::combineFilterExpression
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
Definition: qgsfeaturerequest.cpp:174
QgsFeatureRequest::limit
long long limit() const
Returns the maximum number of features to request, or -1 if no limit set.
Definition: qgsfeaturerequest.h:656
QgsFeatureRequest::setTransformErrorCallback
QgsFeatureRequest & setTransformErrorCallback(const std::function< void(const QgsFeature &)> &callback)
Sets a callback function to use when encountering a transform error when iterating features and a des...
Definition: qgsfeaturerequest.cpp:308
QgsFeatureRequest::OrderByClause::ascending
bool ascending() const
Order ascending.
Definition: qgsfeaturerequest.cpp:469
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsFeatureRequest::OrderBy::load
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
Definition: qgsfeaturerequest.cpp:539
QgsFeatureRequest::mFlags
Flags mFlags
Definition: qgsfeaturerequest.h:996
QgsFeatureRequest::requestMayBeNested
bool requestMayBeNested() const
In case this request may be run nested within another already running iteration on the same connectio...
Definition: qgsfeaturerequest.cpp:391
QgsFeatureRequest::mOrderBy
OrderBy mOrderBy
Definition: qgsfeaturerequest.h:1000
QgsFeatureRequest::setFilterFids
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
Definition: qgsfeaturerequest.cpp:148
QgsGeometry::isEmpty
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Definition: qgsgeometry.cpp:379
QgsFeatureRequest::setFeedback
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the iterator to check if it should be cance...
Definition: qgsfeaturerequest.cpp:402
QgsFeatureRequest::mLimit
long long mLimit
Definition: qgsfeaturerequest.h:999
QgsAbstractFeatureSource::iteratorClosed
void iteratorClosed(QgsAbstractFeatureIterator *it)
Definition: qgsfeaturerequest.cpp:431
QgsFeatureRequest::mReferenceGeometryEngine
std::shared_ptr< QgsGeometryEngine > mReferenceGeometryEngine
Prepared geometry engine for mReferenceGeometry.
Definition: qgsfeaturerequest.h:985
QgsFeatureRequest::mFilterRect
QgsRectangle mFilterRect
Bounding box for spatial filtering.
Definition: qgsfeaturerequest.h:975
QgsFeatureRequest::mTransformContext
QgsCoordinateTransformContext mTransformContext
Definition: qgsfeaturerequest.h:1005
QgsFeatureRequest::setSimplifyMethod
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
Definition: qgsfeaturerequest.cpp:284
QgsFeatureRequest::FilterExpression
@ FilterExpression
Filter using expression.
Definition: qgsfeaturerequest.h:117
QgsRectangle::buffered
QgsRectangle buffered(double width) const
Gets rectangle enlarged by buffer.
Definition: qgsrectangle.h:325
QgsFeatureRequest::mFilterFid
QgsFeatureId mFilterFid
Definition: qgsfeaturerequest.h:992
QgsFeatureRequest::setTimeout
QgsFeatureRequest & setTimeout(int timeout)
Sets the timeout (in milliseconds) for the maximum time we should wait during feature requests before...
Definition: qgsfeaturerequest.cpp:385
QgsFeatureRequest::setNoAttributes
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
Definition: qgsfeaturerequest.cpp:235
QgsGeometry::constGet
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Definition: qgsgeometry.cpp:136
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsFeatureRequest::OrderBy::usedAttributeIndices
QSet< int > CORE_EXPORT usedAttributeIndices(const QgsFields &fields) const
Returns a set of used, validated attribute indices.
Definition: qgsfeaturerequest.cpp:571
QgsFeatureRequest::mInvalidGeometryCallback
std::function< void(const QgsFeature &) > mInvalidGeometryCallback
Definition: qgsfeaturerequest.h:1002
QgsFeatureRequest::~QgsFeatureRequest
~QgsFeatureRequest()
QgsFeatureRequest::OrderByClause::OrderByClause
OrderByClause(const QString &expression, bool ascending=true)
Creates a new OrderByClause for a QgsFeatureRequest.
Definition: qgsfeaturerequest.cpp:438
QgsGeometry::createGeometryEngine
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
Definition: qgsgeometry.cpp:3972
QgsFeatureRequest::OrderByClause::nullsFirst
bool nullsFirst() const
Set if NULLS should be returned first.
Definition: qgsfeaturerequest.cpp:479
QgsFeatureRequest::setRequestMayBeNested
QgsFeatureRequest & setRequestMayBeNested(bool requestMayBeNested)
In case this request may be run nested within another already running iteration on the same connectio...
Definition: qgsfeaturerequest.cpp:396
qgsgeometry.h
QgsFeatureRequest::OrderBy
Represents a list of OrderByClauses, with the most important first and the least important last.
Definition: qgsfeaturerequest.h:264
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsFeatureRequest::orderBy
OrderBy orderBy() const
Returns a list of order by clauses specified for this feature request.
Definition: qgsfeaturerequest.cpp:205
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:230
QgsFeatureRequest::setLimit
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
Definition: qgsfeaturerequest.cpp:216
Qgis::SpatialFilterType::BoundingBox
@ BoundingBox
Filter using a bounding box.
QgsFeatureRequest::OrderBy::list
QList< QgsFeatureRequest::OrderByClause > CORE_EXPORT list() const
Gets a copy as a list of OrderByClauses.
Definition: qgsfeaturerequest.cpp:518
QgsAbstractFeatureSource::iteratorOpened
void iteratorOpened(QgsAbstractFeatureIterator *it)
Definition: qgsfeaturerequest.cpp:426
QgsFeatureRequest::OrderBy::dump
QString CORE_EXPORT dump() const
Dumps the content to an SQL equivalent syntax.
Definition: qgsfeaturerequest.cpp:589
QgsFeatureRequest::mTransformErrorCallback
std::function< void(const QgsFeature &) > mTransformErrorCallback
Definition: qgsfeaturerequest.h:1003
QgsFeatureRequest::simplifyMethod
const QgsSimplifyMethod & simplifyMethod() const
Returns the simplification method for geometries that will be fetched.
Definition: qgsfeaturerequest.h:765
QgsFeatureRequest::setOrderBy
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
Definition: qgsfeaturerequest.cpp:210
QgsFeatureRequest::mSpatialFilter
Qgis::SpatialFilterType mSpatialFilter
Spatial filter type.
Definition: qgsfeaturerequest.h:970
QgsGeometry::boundingBox
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Definition: qgsgeometry.cpp:1080
QgsFeatureRequest::connectionTimeout
Q_DECL_DEPRECATED int connectionTimeout() const
Returns the timeout (in milliseconds) for how long we should wait for a connection if none is availab...
Definition: qgsfeaturerequest.cpp:369
QgsFeatureRequest::mAttrs
QgsAttributeList mAttrs
Definition: qgsfeaturerequest.h:997
Qgis
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:71
QgsFeatureRequest::FilterNone
@ FilterNone
No filter is applied.
Definition: qgsfeaturerequest.h:115
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsFeatureRequest::setDestinationCrs
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
Definition: qgsfeaturerequest.cpp:301
QgsFeatureRequest::mTimeout
int mTimeout
Definition: qgsfeaturerequest.h:1006
qgslogger.h
QgsFields::lookupField
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Definition: qgsfields.cpp:349
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings")....
Definition: qgsexpression.h:102
QgsFeatureRequest::setFlags
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
Definition: qgsfeaturerequest.cpp:222
QgsAbstractFeatureIterator
Internal feature iterator to be implemented within data providers.
Definition: qgsfeatureiterator.h:28
QgsExpression::expression
QString expression() const
Returns the original, unmodified expression string.
Definition: qgsexpression.cpp:60
QgsAbstractFeatureIterator::close
virtual bool close()=0
end of iterating: free the resources / lock
QgsRectangle::isNull
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
Definition: qgsrectangle.h:479
QgsGeometry::boundingBoxIntersects
bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
Definition: qgsgeometry.cpp:1283
QgsFeatureRequest::mFilter
FilterType mFilter
Attribute/ID filter type.
Definition: qgsfeaturerequest.h:963
Qgis::SpatialFilterType::DistanceWithin
@ DistanceWithin
Filter by distance to reference geometry.
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:525