QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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 <memory>
18
19#include "qgsfields.h"
20#include "qgsgeometry.h"
21#include "qgsgeometryengine.h"
22
23#include <QString>
24#include <QStringList>
25
26using namespace Qt::StringLiterals;
27
28//constants
29const QString QgsFeatureRequest::ALL_ATTRIBUTES = u"#!allattributes!#"_s;
30
34
36
38 : mFilter( Qgis::FeatureRequestFilterType::Fid )
39 , mFilterFid( fid )
40{
41}
42
44 : mFilter( Qgis::FeatureRequestFilterType::Fids )
45 , mFilterFids( fids )
46{
47
48}
49
51 : mSpatialFilter( !rect.isNull() ? Qgis::SpatialFilterType::BoundingBox : Qgis::SpatialFilterType::NoFilter )
52 , mFilterRect( rect )
53{
54}
55
57 : mFilter( Qgis::FeatureRequestFilterType::Expression )
58 , mFilterExpression( new QgsExpression( expr ) )
59 , mExpressionContext( context )
60{
61}
62
64//****** IMPORTANT! editing this? make sure you update the move constructor too! *****
65 : mFilter( rh.mFilter )
75 , mFlags( rh.mFlags )
76 , mAttrs( rh.mAttrs )
77 //****** IMPORTANT! editing this? make sure you update the move constructor too! *****
79 , mLimit( rh.mLimit )
80 , mOrderBy( rh.mOrderBy )
85 , mCrs( rh.mCrs )
87 , mTimeout( rh.mTimeout )
89 , mFeedback( rh.mFeedback )
90 //****** IMPORTANT! editing this? make sure you update the move constructor too! *****
91{
92
93}
94
96 : mFilter( rh.mFilter )
98 , mFilterRect( std::move( rh.mFilterRect ) )
99 , mReferenceGeometry( std::move( rh.mReferenceGeometry ) )
102 , mFilterFid( rh.mFilterFid )
103 , mFilterFids( std::move( rh.mFilterFids ) )
104 , mFilterExpression( std::move( rh.mFilterExpression ) )
105 , mExpressionContext( std::move( rh.mExpressionContext ) )
106 , mFlags( rh.mFlags )
107 , mAttrs( std::move( rh.mAttrs ) )
108 , mSimplifyMethod( std::move( rh.mSimplifyMethod ) )
109 , mLimit( rh.mLimit )
110 , mOrderBy( std::move( rh.mOrderBy ) )
114 , mTransform( std::move( rh.mTransform ) )
115 , mCrs( std::move( rh.mCrs ) )
116 , mTransformContext( std::move( rh.mTransformContext ) )
117 , mTimeout( rh.mTimeout )
119 , mFeedback( rh.mFeedback )
120{
121
122}
123
125{
126 //****** IMPORTANT! editing this? make sure you update the move assignment operator too! *****
127 if ( &rh == this )
128 return *this;
129
130 mFlags = rh.mFlags;
131 mFilter = rh.mFilter;
139 if ( rh.mFilterExpression )
140 {
141 mFilterExpression = std::make_unique<QgsExpression>( *rh.mFilterExpression );
142 }
143 else
144 {
145 mFilterExpression.reset( nullptr );
146 }
147 //****** IMPORTANT! editing this? make sure you update the move assignment operator too! *****
151 mAttrs = rh.mAttrs;
153 mLimit = rh.mLimit;
154 mOrderBy = rh.mOrderBy;
156 mCrs = rh.mCrs;
159 mTimeout = rh.mTimeout;
161 mFeedback = rh.mFeedback;
162 return *this;
163 //****** IMPORTANT! editing this? make sure you update the move assignment operator too! *****
164}
165
166
168{
169 if ( &rh == this )
170 return *this;
171
172 mFlags = rh.mFlags;
173 mFilter = rh.mFilter;
174 mSpatialFilter = rh.mSpatialFilter;
175 mFilterRect = std::move( rh.mFilterRect );
176 mReferenceGeometry = std::move( rh.mReferenceGeometry );
177 mReferenceGeometryEngine = std::move( rh.mReferenceGeometryEngine );
178 mDistanceWithin = rh.mDistanceWithin;
179 mFilterFid = rh.mFilterFid;
180 mFilterFids = std::move( rh.mFilterFids );
181 mFilterExpression = std::move( rh.mFilterExpression );
182 mInvalidGeometryFilter = std::move( rh.mInvalidGeometryFilter );
183 mInvalidGeometryCallback = std::move( rh.mInvalidGeometryCallback );
184 mExpressionContext = std::move( rh.mExpressionContext );
185 mAttrs = std::move( rh.mAttrs );
186 mSimplifyMethod = std::move( rh.mSimplifyMethod );
187 mLimit = rh.mLimit;
188 mOrderBy = std::move( rh.mOrderBy );
189 mTransform = std::move( rh.mTransform );
190 mCrs = std::move( rh.mCrs );
191 mTransformContext = std::move( rh.mTransformContext );
192 mTransformErrorCallback = std::move( rh.mTransformErrorCallback );
193 mTimeout = rh.mTimeout;
194 mRequestMayBeNested = rh.mRequestMayBeNested;
195 mFeedback = rh.mFeedback;
196 return *this;
197}
198
199// Relaxed Equality operator
201{
202 if ( &rh == this )
203 return true;
204
205 return mFlags == rh.mFlags &&
206 mFilter == rh.mFilter &&
208 mFilterRect == rh.mFilterRect &&
209 ( ( mReferenceGeometry.isNull() && rh.mReferenceGeometry.isNull() ) || mReferenceGeometry.equals( rh.mReferenceGeometry ) ) &&
211 mFilterFid == rh.mFilterFid &&
212 mFilterFids == rh.mFilterFids &&
215 mAttrs == rh.mAttrs &&
217 mLimit == rh.mLimit &&
218 mOrderBy == rh.mOrderBy &&
219 mTransform == rh.mTransform &&
220 mCrs == rh.mCrs &&
222 mTimeout == rh.mTimeout &&
224}
225
226
228{
229 mFilterRect = rect;
231 mDistanceWithin = 0;
232 if ( mFilterRect.isNull() )
233 {
235 }
236 else
237 {
239 }
240 return *this;
241}
242
247
249{
250 mReferenceGeometry = geometry;
251 if ( !mReferenceGeometry.isEmpty() )
252 {
254 mReferenceGeometryEngine->prepareGeometry();
255 }
256 else
257 {
259 }
260 mDistanceWithin = distance;
262 mFilterRect = mReferenceGeometry.boundingBox().buffered( mDistanceWithin );
263
264 return *this;
265}
266
273
280
286
287QgsFeatureRequest &QgsFeatureRequest::setInvalidGeometryCallback( const std::function<void ( const QgsFeature & )> &callback )
288{
289 mInvalidGeometryCallback = callback;
290 return *this;
291}
292
294{
296 mFilterExpression = std::make_unique<QgsExpression>( expression );
297 return *this;
298}
299
301{
302 if ( mFilterExpression )
303 {
304 setFilterExpression( u"(%1) AND (%2)"_s.arg( mFilterExpression->expression(), expression ) );
305 }
306 else
307 {
308 setFilterExpression( expression );
309 }
310 return *this;
311}
312
314{
315 mExpressionContext = context;
316 return *this;
317}
318
319QgsFeatureRequest &QgsFeatureRequest::addOrderBy( const QString &expression, bool ascending )
320{
321 mOrderBy.append( OrderByClause( expression, ascending ) );
322 return *this;
323}
324
325QgsFeatureRequest &QgsFeatureRequest::addOrderBy( const QString &expression, bool ascending, bool nullsfirst )
326{
327 mOrderBy.append( OrderByClause( expression, ascending, nullsfirst ) );
328 return *this;
329}
330
335
341
343{
344 mLimit = limit;
345 return *this;
346}
347
353
360
365
366QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QStringList &attrNames, const QgsFields &fields )
367{
368 if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) )
369 {
370 //attribute string list contains the all attributes flag, so we must fetch all attributes
371 return *this;
372 }
373
375 mAttrs.clear();
376
377 const auto constAttrNames = attrNames;
378 for ( const QString &attrName : constAttrNames )
379 {
380 const int attrNum = fields.lookupField( attrName );
381 if ( attrNum != -1 && !mAttrs.contains( attrNum ) )
382 mAttrs.append( attrNum );
383 }
384
385 return *this;
386}
387
388QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QSet<QString> &attrNames, const QgsFields &fields )
389{
390 if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) )
391 {
392 //attribute string list contains the all attributes flag, so we must fetch all attributes
393 return *this;
394 }
395
397 mAttrs.clear();
398
399 const auto constAttrNames = attrNames;
400 for ( const QString &attrName : constAttrNames )
401 {
402 const int attrNum = fields.lookupField( attrName );
403 if ( attrNum != -1 && !mAttrs.contains( attrNum ) )
404 mAttrs.append( attrNum );
405 }
406
407 return *this;
408}
409
415
420
425
430
432{
433 if ( mTransform.isValid() )
434 {
435 return mTransform;
436 }
437 else if ( sourceCrs.isValid() && mCrs != sourceCrs )
438 {
439 return QgsCoordinateTransform( sourceCrs, mCrs, mTransformContext );
440 }
441 return QgsCoordinateTransform();
442}
443
445{
446 mTransform = transform;
447 return *this;
448}
449
451{
452 mCrs = crs;
453 mTransformContext = context;
454 return *this;
455}
456
457QgsFeatureRequest &QgsFeatureRequest::setTransformErrorCallback( const std::function<void ( const QgsFeature & )> &callback )
458{
459 mTransformErrorCallback = callback;
460 return *this;
461}
462
464{
465 // check the attribute/id filter first, it's more likely to be faster than
466 // the spatial filter
467 switch ( mFilter )
468 {
470 break;
471
473 if ( feature.id() != mFilterFid )
474 return false;
475 break;
476
478 mExpressionContext.setFeature( feature );
479 if ( !mFilterExpression->evaluate( &mExpressionContext ).toBool() )
480 return false;
481 break;
482
484 if ( !mFilterFids.contains( feature.id() ) )
485 return false;
486 break;
487 }
488
489 switch ( mSpatialFilter )
490 {
492 break;
493
495 if ( !feature.hasGeometry() ||
496 (
498 ||
500 )
501 )
502 return false;
503 break;
504
506 if ( !feature.hasGeometry()
509 || !mReferenceGeometryEngine->distanceWithin( feature.geometry().constGet(), mDistanceWithin )
510 )
511 return false;
512 break;
513 }
514
515 return true;
516}
517
519{
520 return mTimeout;
521}
522
528
530{
531 return mTimeout;
532}
533
535{
537 return *this;
538}
539
544
550
555
557{
558 return mFeedback;
559}
560
561
562#include "qgsfeatureiterator.h"
563#include "qgslogger.h"
564
566{
567 while ( !mActiveIterators.empty() )
568 {
570 QgsDebugMsgLevel( u"closing active iterator"_s, 2 );
571 it->close();
572 }
573}
574
579
584
585
586
588 : mExpression( expression )
589 , mAscending( ascending )
590{
591 // postgres behavior: default for ASC: NULLS LAST, default for DESC: NULLS FIRST
592 mNullsFirst = !ascending;
593}
594
596 : mExpression( expression )
597 , mAscending( ascending )
598 , mNullsFirst( nullsfirst )
599{
600}
601
603 : mExpression( expression )
604 , mAscending( ascending )
605{
606 // postgres behavior: default for ASC: NULLS LAST, default for DESC: NULLS FIRST
607 mNullsFirst = !ascending;
608}
609
611 : mExpression( expression )
612 , mAscending( ascending )
613 , mNullsFirst( nullsfirst )
614{
615
616}
617
619{
620 return mAscending;
621}
622
627
629{
630 return mNullsFirst;
631}
632
637
639{
640 return u"%1 %2 %3"_s
641 .arg( mExpression.expression(),
642 mAscending ? "ASC" : "DESC",
643 mNullsFirst ? "NULLS FIRST" : "NULLS LAST" );
644}
645
647{
648 return mExpression;
649}
650
652{
653 return mExpression.prepare( context );
654}
655
657
658QgsFeatureRequest::OrderBy::OrderBy( const QList<QgsFeatureRequest::OrderByClause> &other )
659{
660 const auto constOther = other;
661 for ( const QgsFeatureRequest::OrderByClause &clause : constOther )
662 {
663 append( clause );
664 }
665}
666
668{
669 if ( this == &other )
670 return true;
671 if ( size() != other.size() )
672 return false;
673 for ( int i = 0; i < size(); ++i )
674 {
675 if ( at( i ) != other.at( i ) )
676 return false;
677 }
678 return true;
679}
680
682{
683 return !operator==( other );
684}
685
686QList<QgsFeatureRequest::OrderByClause> QgsFeatureRequest::OrderBy::list() const
687{
688 return *this;
689}
690
691void QgsFeatureRequest::OrderBy::save( QDomElement &elem ) const
692{
693 QDomDocument doc = elem.ownerDocument();
694 QList<OrderByClause>::ConstIterator it;
695 for ( it = constBegin(); it != constEnd(); ++it )
696 {
697 const OrderByClause &clause = *it;
698 QDomElement clauseElem = doc.createElement( u"orderByClause"_s );
699 clauseElem.setAttribute( u"asc"_s, clause.ascending() );
700 clauseElem.setAttribute( u"nullsFirst"_s, clause.nullsFirst() );
701 clauseElem.appendChild( doc.createTextNode( clause.expression().expression() ) );
702
703 elem.appendChild( clauseElem );
704 }
705}
706
707void QgsFeatureRequest::OrderBy::load( const QDomElement &elem )
708{
709 clear();
710
711 const QDomNodeList clauses = elem.childNodes();
712
713 for ( int i = 0; i < clauses.size(); ++i )
714 {
715 const QDomElement clauseElem = clauses.at( i ).toElement();
716 const QString expression = clauseElem.text();
717 const bool asc = clauseElem.attribute( u"asc"_s ).toInt() != 0;
718 const bool nullsFirst = clauseElem.attribute( u"nullsFirst"_s ).toInt() != 0;
719
720 append( OrderByClause( expression, asc, nullsFirst ) );
721 }
722}
723
725{
726 QSet<QString> usedAttributes;
727
728 QList<OrderByClause>::ConstIterator it;
729 for ( it = constBegin(); it != constEnd(); ++it )
730 {
731 const OrderByClause &clause = *it;
732
733 usedAttributes.unite( clause.expression().referencedColumns() );
734 }
735
736 return usedAttributes;
737}
738
740{
741 QSet<int> usedAttributeIdx;
742 for ( const OrderByClause &clause : *this )
743 {
744 const auto referencedColumns = clause.expression().referencedColumns();
745 for ( const QString &fieldName : referencedColumns )
746 {
747 const int idx = fields.lookupField( fieldName );
748 if ( idx >= 0 )
749 {
750 usedAttributeIdx.insert( idx );
751 }
752 }
753 }
754 return usedAttributeIdx;
755}
756
758{
759 QStringList results;
760
761 QList<OrderByClause>::ConstIterator it;
762 for ( it = constBegin(); it != constEnd(); ++it )
763 {
764 const OrderByClause &clause = *it;
765
766 results << clause.dump();
767 }
768
769 return results.join( ", "_L1 );
770}
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:59
@ Fid
Filter using feature ID.
Definition qgis.h:2282
@ Fids
Filter using feature IDs.
Definition qgis.h:2284
@ Expression
Filter using expression.
Definition qgis.h:2283
@ NoFilter
No filter is applied.
Definition qgis.h:2281
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
Definition qgis.h:2256
@ SubsetOfAttributes
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag).
Definition qgis.h:2255
@ DistanceWithin
Filter by distance to reference geometry.
Definition qgis.h:2312
@ BoundingBox
Filter using a bounding box.
Definition qgis.h:2311
@ NoFilter
No spatial filtering of features.
Definition qgis.h:2310
QFlags< FeatureRequestFlag > FeatureRequestFlags
Flags for controlling feature requests.
Definition qgis.h:2269
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
Definition qgis.h:2296
Internal feature iterator to be implemented within data providers.
virtual bool close()=0
Call to end the iteration.
void iteratorOpened(QgsAbstractFeatureIterator *it)
void iteratorClosed(QgsAbstractFeatureIterator *it)
QSet< QgsAbstractFeatureIterator * > mActiveIterators
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Contains information about the context in which a coordinate transform is executed.
Handles coordinate transforms between two coordinate systems.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Handles parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QString expression() const
Returns the original, unmodified expression string.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
OrderByClause(const QString &expression, bool ascending=true)
Creates a new OrderByClause for a QgsFeatureRequest.
QString dump() const
Dumps the content to an SQL equivalent.
QgsExpression expression() const
The expression.
bool ascending() const
Order ascending.
bool nullsFirst() const
Set if NULLS should be returned first.
void setAscending(bool ascending)
Set if ascending order is requested.
bool prepare(QgsExpressionContext *context)
Prepare the expression with the given context.
void setNullsFirst(bool nullsFirst)
Set if NULLS should be returned first.
Represents a list of OrderByClauses, with the most important first and the least important last.
QSet< int > CORE_EXPORT usedAttributeIndices(const QgsFields &fields) const
Returns a set of used, validated attribute indices.
CORE_EXPORT bool operator==(const OrderBy &v) const
Equality operator.
QSet< QString > CORE_EXPORT usedAttributes() const
Returns a set of used attributes.
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
QList< QgsFeatureRequest::OrderByClause > CORE_EXPORT list() const
Gets a copy as a list of OrderByClauses.
QString CORE_EXPORT dump() const
Dumps the content to an SQL equivalent syntax.
CORE_EXPORT OrderBy()
Create a new empty order by.
CORE_EXPORT bool operator!=(const OrderBy &v) const
Inequality operator.
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
std::unique_ptr< QgsExpression > mFilterExpression
QgsCoordinateReferenceSystem mCrs
QgsFeatureRequest & setCoordinateTransform(const QgsCoordinateTransform &transform)
Sets the coordinate transform which will be used to transform the feature's geometries.
Qgis::InvalidGeometryCheck mInvalidGeometryFilter
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
Qgis::FeatureRequestFlags mFlags
QgsRectangle filterRect() const
Returns the rectangle from which features will be taken.
QgsCoordinateTransformContext mTransformContext
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 ...
QgsCoordinateTransform mTransform
QgsRectangle mFilterRect
Bounding box for spatial filtering.
Qgis::SpatialFilterType mSpatialFilter
Spatial filter type.
Qgis::FeatureRequestFilterType mFilter
Attribute/ID filter type.
QgsFeedback * feedback() const
Returns the feedback object that can be queried regularly by the iterator to check if it should be ca...
QgsFeatureRequest & setRequestMayBeNested(bool requestMayBeNested)
In case this request may be run nested within another already running iteration on the same connectio...
long long limit() const
Returns the maximum number of features to request, or -1 if no limit set.
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
OrderBy orderBy() const
Returns a list of order by clauses specified for this feature request.
QgsFeatureIds mFilterFids
QgsGeometry mReferenceGeometry
Reference geometry for Qgis::RequestSpatialFilter::DistanceWithin filtering.
QgsFeatureRequest & addOrderBy(const QString &expression, bool ascending=true)
Adds a new OrderByClause, appending it as the least important one.
QgsFeatureRequest & setTimeout(int timeout)
Sets the timeout (in milliseconds) for the maximum time we should wait during feature requests before...
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
QgsExpressionContext mExpressionContext
Qgis::FeatureRequestFlags flags() const
Returns the flags which affect how features are fetched.
QgsSimplifyMethod mSimplifyMethod
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
int timeout() const
Returns the timeout (in milliseconds) for the maximum time we should wait during feature requests bef...
std::function< void(const QgsFeature &) > mTransformErrorCallback
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
QgsFeatureRequest & setInvalidGeometryCheck(Qgis::InvalidGeometryCheck check)
Sets invalid geometry checking behavior.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the iterator to check if it should be cance...
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for feature's geometries, or an invalid QgsCoordi...
QgsCoordinateTransform coordinateTransform() const
Returns the coordinate transform which will be used to transform the feature's geometries.
QgsAttributeList mAttrs
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
std::shared_ptr< QgsGeometryEngine > mReferenceGeometryEngine
Prepared geometry engine for mReferenceGeometry.
const QgsSimplifyMethod & simplifyMethod() const
Returns the simplification method for geometries that will be fetched.
std::function< void(const QgsFeature &) > mInvalidGeometryCallback
Q_DECL_DEPRECATED int connectionTimeout() const
Returns the timeout (in milliseconds) for how long we should wait for a connection if none is availab...
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
QgsCoordinateTransform calculateTransform(const QgsCoordinateReferenceSystem &sourceCrs) const
Calculates the coordinate transform to use to transform geometries when they are originally in source...
QgsFeatureRequest & setInvalidGeometryCallback(const std::function< void(const QgsFeature &)> &callback)
Sets a callback function to use when encountering an invalid geometry and invalidGeometryCheck() is s...
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
QgsFeatureRequest & operator=(const QgsFeatureRequest &rh)
QgsFeatureRequest & setOrderBy(const OrderBy &orderBy)
Set a list of order by clauses.
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...
double mDistanceWithin
Maximum distance from reference geometry.
bool requestMayBeNested() const
In case this request may be run nested within another already running iteration on the same connectio...
bool compare(const QgsFeatureRequest &other) const
Compare two requests for equality, ignoring Expression Context, Transform Error Callback,...
QgsFeatureRequest()
construct a default request: for all features get attributes and geometries
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
QgsFeatureRequest & setDistanceWithin(const QgsGeometry &geometry, double distance)
Sets a reference geometry and a maximum distance from this geometry to retrieve features within.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
QgsFeatureId id
Definition qgsfeature.h:68
QgsGeometry geometry
Definition qgsfeature.h:71
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Container of fields for a vector layer.
Definition qgsfields.h:46
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
A geometry is the spatial representation of a feature.
bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
A rectangle specified with double values.
Contains information about how to simplify geometries fetched from a QgsFeatureIterator.
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QList< int > QgsAttributeList
Definition qgsfield.h:30
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:63