QGIS API Documentation 4.1.0-Master (60fea48833c)
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
33
35
37 : mFilter( Qgis::FeatureRequestFilterType::Fid )
38 , mFilterFid( fid )
39{}
40
42 : mFilter( Qgis::FeatureRequestFilterType::Fids )
43 , mFilterFids( fids )
44{}
45
47 : mSpatialFilter( !rect.isNull() ? Qgis::SpatialFilterType::BoundingBox : Qgis::SpatialFilterType::NoFilter )
48 , mFilterRect( rect )
49{}
50
52 : mFilter( Qgis::FeatureRequestFilterType::Expression )
53 , mFilterExpression( new QgsExpression( expr ) )
54 , mExpressionContext( context )
55{}
56
58 //****** IMPORTANT! editing this? make sure you update the move constructor too! *****
59 : mFilter( rh.mFilter )
69 , mFlags( rh.mFlags )
70 , mAttrs( rh.mAttrs )
71 //****** IMPORTANT! editing this? make sure you update the move constructor too! *****
73 , mLimit( rh.mLimit )
74 , mOrderBy( rh.mOrderBy )
79 , mCrs( rh.mCrs )
81 , mTimeout( rh.mTimeout )
83 , mFeedback( rh.mFeedback )
84//****** IMPORTANT! editing this? make sure you update the move constructor too! *****
85{}
86
88 : mFilter( rh.mFilter )
90 , mFilterRect( std::move( rh.mFilterRect ) )
91 , mReferenceGeometry( std::move( rh.mReferenceGeometry ) )
95 , mFilterFids( std::move( rh.mFilterFids ) )
96 , mFilterExpression( std::move( rh.mFilterExpression ) )
97 , mExpressionContext( std::move( rh.mExpressionContext ) )
98 , mFlags( rh.mFlags )
99 , mAttrs( std::move( rh.mAttrs ) )
100 , mSimplifyMethod( std::move( rh.mSimplifyMethod ) )
101 , mLimit( rh.mLimit )
102 , mOrderBy( std::move( rh.mOrderBy ) )
106 , mTransform( std::move( rh.mTransform ) )
107 , mCrs( std::move( rh.mCrs ) )
108 , mTransformContext( std::move( rh.mTransformContext ) )
109 , mTimeout( rh.mTimeout )
111 , mFeedback( rh.mFeedback )
112{}
113
115{
116 //****** IMPORTANT! editing this? make sure you update the move assignment operator too! *****
117 if ( &rh == this )
118 return *this;
119
120 mFlags = rh.mFlags;
121 mFilter = rh.mFilter;
129 if ( rh.mFilterExpression )
130 {
131 mFilterExpression = std::make_unique<QgsExpression>( *rh.mFilterExpression );
132 }
133 else
134 {
135 mFilterExpression.reset( nullptr );
136 }
137 //****** IMPORTANT! editing this? make sure you update the move assignment operator too! *****
141 mAttrs = rh.mAttrs;
143 mLimit = rh.mLimit;
144 mOrderBy = rh.mOrderBy;
146 mCrs = rh.mCrs;
149 mTimeout = rh.mTimeout;
151 mFeedback = rh.mFeedback;
152 return *this;
153 //****** IMPORTANT! editing this? make sure you update the move assignment operator too! *****
154}
155
156
158{
159 if ( &rh == this )
160 return *this;
161
162 mFlags = rh.mFlags;
163 mFilter = rh.mFilter;
164 mSpatialFilter = rh.mSpatialFilter;
165 mFilterRect = std::move( rh.mFilterRect );
166 mReferenceGeometry = std::move( rh.mReferenceGeometry );
167 mReferenceGeometryEngine = std::move( rh.mReferenceGeometryEngine );
168 mDistanceWithin = rh.mDistanceWithin;
169 mFilterFid = rh.mFilterFid;
170 mFilterFids = std::move( rh.mFilterFids );
171 mFilterExpression = std::move( rh.mFilterExpression );
172 mInvalidGeometryFilter = std::move( rh.mInvalidGeometryFilter );
173 mInvalidGeometryCallback = std::move( rh.mInvalidGeometryCallback );
174 mExpressionContext = std::move( rh.mExpressionContext );
175 mAttrs = std::move( rh.mAttrs );
176 mSimplifyMethod = std::move( rh.mSimplifyMethod );
177 mLimit = rh.mLimit;
178 mOrderBy = std::move( rh.mOrderBy );
179 mTransform = std::move( rh.mTransform );
180 mCrs = std::move( rh.mCrs );
181 mTransformContext = std::move( rh.mTransformContext );
182 mTransformErrorCallback = std::move( rh.mTransformErrorCallback );
183 mTimeout = rh.mTimeout;
184 mRequestMayBeNested = rh.mRequestMayBeNested;
185 mFeedback = rh.mFeedback;
186 return *this;
187}
188
189// Relaxed Equality operator
191{
192 if ( &rh == this )
193 return true;
194
195 return mFlags == rh.mFlags
196 && mFilter == rh.mFilter
198 && mFilterRect == rh.mFilterRect
199 && ( ( mReferenceGeometry.isNull() && rh.mReferenceGeometry.isNull() ) || mReferenceGeometry.equals( rh.mReferenceGeometry ) )
201 && mFilterFid == rh.mFilterFid
202 && mFilterFids == rh.mFilterFids
205 && mAttrs == rh.mAttrs
207 && mLimit == rh.mLimit
208 && mOrderBy == rh.mOrderBy
209 && mTransform == rh.mTransform
210 && mCrs == rh.mCrs
212 && mTimeout == rh.mTimeout
214}
215
216
218{
219 mFilterRect = rect;
221 mDistanceWithin = 0;
222 if ( mFilterRect.isNull() )
223 {
225 }
226 else
227 {
229 }
230 return *this;
231}
232
237
239{
240 mReferenceGeometry = geometry;
241 if ( !mReferenceGeometry.isEmpty() )
242 {
244 mReferenceGeometryEngine->prepareGeometry();
245 }
246 else
247 {
249 }
250 mDistanceWithin = distance;
252 mFilterRect = mReferenceGeometry.boundingBox().buffered( mDistanceWithin );
253
254 return *this;
255}
256
263
270
276
277QgsFeatureRequest &QgsFeatureRequest::setInvalidGeometryCallback( const std::function<void( const QgsFeature & )> &callback )
278{
279 mInvalidGeometryCallback = callback;
280 return *this;
281}
282
284{
286 mFilterExpression = std::make_unique<QgsExpression>( expression );
287 return *this;
288}
289
291{
292 if ( mFilterExpression )
293 {
294 setFilterExpression( u"(%1) AND (%2)"_s.arg( mFilterExpression->expression(), expression ) );
295 }
296 else
297 {
298 setFilterExpression( expression );
299 }
300 return *this;
301}
302
304{
305 mExpressionContext = context;
306 return *this;
307}
308
309QgsFeatureRequest &QgsFeatureRequest::addOrderBy( const QString &expression, bool ascending )
310{
311 mOrderBy.append( OrderByClause( expression, ascending ) );
312 return *this;
313}
314
315QgsFeatureRequest &QgsFeatureRequest::addOrderBy( const QString &expression, bool ascending, bool nullsfirst )
316{
317 mOrderBy.append( OrderByClause( expression, ascending, nullsfirst ) );
318 return *this;
319}
320
325
331
333{
334 mLimit = limit;
335 return *this;
336}
337
343
350
355
356QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QStringList &attrNames, const QgsFields &fields )
357{
358 if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) )
359 {
360 //attribute string list contains the all attributes flag, so we must fetch all attributes
361 return *this;
362 }
363
365 mAttrs.clear();
366
367 const auto constAttrNames = attrNames;
368 for ( const QString &attrName : constAttrNames )
369 {
370 const int attrNum = fields.lookupField( attrName );
371 if ( attrNum != -1 && !mAttrs.contains( attrNum ) )
372 mAttrs.append( attrNum );
373 }
374
375 return *this;
376}
377
378QgsFeatureRequest &QgsFeatureRequest::setSubsetOfAttributes( const QSet<QString> &attrNames, const QgsFields &fields )
379{
380 if ( attrNames.contains( QgsFeatureRequest::ALL_ATTRIBUTES ) )
381 {
382 //attribute string list contains the all attributes flag, so we must fetch all attributes
383 return *this;
384 }
385
387 mAttrs.clear();
388
389 const auto constAttrNames = attrNames;
390 for ( const QString &attrName : constAttrNames )
391 {
392 const int attrNum = fields.lookupField( attrName );
393 if ( attrNum != -1 && !mAttrs.contains( attrNum ) )
394 mAttrs.append( attrNum );
395 }
396
397 return *this;
398}
399
405
410
415
420
422{
423 if ( mTransform.isValid() )
424 {
425 return mTransform;
426 }
427 else if ( sourceCrs.isValid() && mCrs != sourceCrs )
428 {
429 return QgsCoordinateTransform( sourceCrs, mCrs, mTransformContext );
430 }
431 return QgsCoordinateTransform();
432}
433
435{
436 mTransform = transform;
437 return *this;
438}
439
441{
442 mCrs = crs;
443 mTransformContext = context;
444 return *this;
445}
446
447QgsFeatureRequest &QgsFeatureRequest::setTransformErrorCallback( const std::function<void( const QgsFeature & )> &callback )
448{
449 mTransformErrorCallback = callback;
450 return *this;
451}
452
454{
455 // check the attribute/id filter first, it's more likely to be faster than
456 // the spatial filter
457 switch ( mFilter )
458 {
460 break;
461
463 if ( feature.id() != mFilterFid )
464 return false;
465 break;
466
468 mExpressionContext.setFeature( feature );
469 if ( !mFilterExpression->evaluate( &mExpressionContext ).toBool() )
470 return false;
471 break;
472
474 if ( !mFilterFids.contains( feature.id() ) )
475 return false;
476 break;
477 }
478
479 switch ( mSpatialFilter )
480 {
482 break;
483
485 if ( !feature.hasGeometry() ||
486 (
488 ||
490 )
491 )
492 return false;
493 break;
494
496 if ( !feature.hasGeometry()
499 || !mReferenceGeometryEngine->distanceWithin( feature.geometry().constGet(), mDistanceWithin ) )
500 return false;
501 break;
502 }
503
504 return true;
505}
506
508{
509 return mTimeout;
510}
511
517
519{
520 return mTimeout;
521}
522
524{
526 return *this;
527}
528
533
539
544
546{
547 return mFeedback;
548}
549
550
551#include "qgsfeatureiterator.h"
552#include "qgslogger.h"
553
555{
556 while ( !mActiveIterators.empty() )
557 {
559 QgsDebugMsgLevel( u"closing active iterator"_s, 2 );
560 it->close();
561 }
562}
563
568
573
574
576 : mExpression( expression )
577 , mAscending( ascending )
578{
579 // postgres behavior: default for ASC: NULLS LAST, default for DESC: NULLS FIRST
580 mNullsFirst = !ascending;
581}
582
584 : mExpression( expression )
585 , mAscending( ascending )
586 , mNullsFirst( nullsfirst )
587{}
588
590 : mExpression( expression )
591 , mAscending( ascending )
592{
593 // postgres behavior: default for ASC: NULLS LAST, default for DESC: NULLS FIRST
594 mNullsFirst = !ascending;
595}
596
598 : mExpression( expression )
599 , mAscending( ascending )
600 , mNullsFirst( nullsfirst )
601{}
602
604{
605 return mAscending;
606}
607
612
614{
615 return mNullsFirst;
616}
617
622
624{
625 return u"%1 %2 %3"_s.arg( mExpression.expression(), mAscending ? "ASC" : "DESC", mNullsFirst ? "NULLS FIRST" : "NULLS LAST" );
626}
627
629{
630 return mExpression;
631}
632
634{
635 return mExpression.prepare( context );
636}
637
639
640QgsFeatureRequest::OrderBy::OrderBy( const QList<QgsFeatureRequest::OrderByClause> &other )
641{
642 const auto constOther = other;
643 for ( const QgsFeatureRequest::OrderByClause &clause : constOther )
644 {
645 append( clause );
646 }
647}
648
650{
651 if ( this == &other )
652 return true;
653 if ( size() != other.size() )
654 return false;
655 for ( int i = 0; i < size(); ++i )
656 {
657 if ( at( i ) != other.at( i ) )
658 return false;
659 }
660 return true;
661}
662
664{
665 return !operator==( other );
666}
667
668QList<QgsFeatureRequest::OrderByClause> QgsFeatureRequest::OrderBy::list() const
669{
670 return *this;
671}
672
673void QgsFeatureRequest::OrderBy::save( QDomElement &elem ) const
674{
675 QDomDocument doc = elem.ownerDocument();
676 QList<OrderByClause>::ConstIterator it;
677 for ( it = constBegin(); it != constEnd(); ++it )
678 {
679 const OrderByClause &clause = *it;
680 QDomElement clauseElem = doc.createElement( u"orderByClause"_s );
681 clauseElem.setAttribute( u"asc"_s, clause.ascending() );
682 clauseElem.setAttribute( u"nullsFirst"_s, clause.nullsFirst() );
683 clauseElem.appendChild( doc.createTextNode( clause.expression().expression() ) );
684
685 elem.appendChild( clauseElem );
686 }
687}
688
689void QgsFeatureRequest::OrderBy::load( const QDomElement &elem )
690{
691 clear();
692
693 const QDomNodeList clauses = elem.childNodes();
694
695 for ( int i = 0; i < clauses.size(); ++i )
696 {
697 const QDomElement clauseElem = clauses.at( i ).toElement();
698 const QString expression = clauseElem.text();
699 const bool asc = clauseElem.attribute( u"asc"_s ).toInt() != 0;
700 const bool nullsFirst = clauseElem.attribute( u"nullsFirst"_s ).toInt() != 0;
701
702 append( OrderByClause( expression, asc, nullsFirst ) );
703 }
704}
705
707{
708 QSet<QString> usedAttributes;
709
710 QList<OrderByClause>::ConstIterator it;
711 for ( it = constBegin(); it != constEnd(); ++it )
712 {
713 const OrderByClause &clause = *it;
714
715 usedAttributes.unite( clause.expression().referencedColumns() );
716 }
717
718 return usedAttributes;
719}
720
722{
723 QSet<int> usedAttributeIdx;
724 for ( const OrderByClause &clause : *this )
725 {
726 const auto referencedColumns = clause.expression().referencedColumns();
727 for ( const QString &fieldName : referencedColumns )
728 {
729 const int idx = fields.lookupField( fieldName );
730 if ( idx >= 0 )
731 {
732 usedAttributeIdx.insert( idx );
733 }
734 }
735 }
736 return usedAttributeIdx;
737}
738
740{
741 QStringList results;
742
743 QList<OrderByClause>::ConstIterator it;
744 for ( it = constBegin(); it != constEnd(); ++it )
745 {
746 const OrderByClause &clause = *it;
747
748 results << clause.dump();
749 }
750
751 return results.join( ", "_L1 );
752}
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
@ Fid
Filter using feature ID.
Definition qgis.h:2305
@ Fids
Filter using feature IDs.
Definition qgis.h:2307
@ Expression
Filter using expression.
Definition qgis.h:2306
@ NoFilter
No filter is applied.
Definition qgis.h:2304
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
Definition qgis.h:2278
@ SubsetOfAttributes
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag).
Definition qgis.h:2277
@ DistanceWithin
Filter by distance to reference geometry.
Definition qgis.h:2335
@ BoundingBox
Filter using a bounding box.
Definition qgis.h:2334
@ NoFilter
No spatial filtering of features.
Definition qgis.h:2333
QFlags< FeatureRequestFlag > FeatureRequestFlags
Flags for controlling feature requests.
Definition qgis.h:2292
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
Definition qgis.h:2319
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