QGIS API Documentation 4.3.0-Master (18b5e825726)
Loading...
Searching...
No Matches
qgsalgorithmdetectdatasetchanges.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmdetectdatasetchanges.cpp
3 -----------------------------------------
4 begin : December 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include "qgsgeometryfactory.h"
21#include "qgsspatialindex.h"
22#include "qgsvectorlayer.h"
23
24#include <QString>
25
26using namespace Qt::StringLiterals;
27
29
30QString QgsDetectVectorChangesAlgorithm::name() const
31{
32 return u"detectvectorchanges"_s;
33}
34
35QString QgsDetectVectorChangesAlgorithm::displayName() const
36{
37 return QObject::tr( "Detect dataset changes" );
38}
39
40QStringList QgsDetectVectorChangesAlgorithm::tags() const
41{
42 return QObject::tr( "added,dropped,new,deleted,features,geometries,difference,delta,revised,original,version" ).split( ',' );
43}
44
45QString QgsDetectVectorChangesAlgorithm::group() const
46{
47 return QObject::tr( "Vector general" );
48}
49
50QString QgsDetectVectorChangesAlgorithm::groupId() const
51{
52 return u"vectorgeneral"_s;
53}
54
55void QgsDetectVectorChangesAlgorithm::initAlgorithm( const QVariantMap & )
56{
57 addParameter( new QgsProcessingParameterFeatureSource( u"ORIGINAL"_s, QObject::tr( "Original layer" ) ) );
58 addParameter( new QgsProcessingParameterFeatureSource( u"REVISED"_s, QObject::tr( "Revised layer" ) ) );
59
60 auto compareAttributesParam = std::make_unique<
61 QgsProcessingParameterField>( u"COMPARE_ATTRIBUTES"_s, QObject::tr( "Attributes to consider for match (or none to compare geometry only)" ), QVariant(), u"ORIGINAL"_s, Qgis::ProcessingFieldParameterDataType::Any, true, true );
62 compareAttributesParam->setDefaultToAllFields( true );
63 addParameter( compareAttributesParam.release() );
64
65 std::unique_ptr<QgsProcessingParameterDefinition> matchTypeParam = std::make_unique<
66 QgsProcessingParameterEnum>( u"MATCH_TYPE"_s, QObject::tr( "Geometry comparison behavior" ), QStringList() << QObject::tr( "Exact Match" ) << QObject::tr( "Tolerant Match (Topological Equality)" ), false, 1 );
67 matchTypeParam->setFlags( matchTypeParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
68 addParameter( matchTypeParam.release() );
69
70 addParameter( new QgsProcessingParameterFeatureSink( u"UNCHANGED"_s, QObject::tr( "Unchanged features" ), Qgis::ProcessingSourceType::VectorAnyGeometry, QVariant(), true, true ) );
71 addParameter( new QgsProcessingParameterFeatureSink( u"ADDED"_s, QObject::tr( "Added features" ), Qgis::ProcessingSourceType::VectorAnyGeometry, QVariant(), true, true ) );
72 addParameter( new QgsProcessingParameterFeatureSink( u"DELETED"_s, QObject::tr( "Deleted features" ), Qgis::ProcessingSourceType::VectorAnyGeometry, QVariant(), true, true ) );
73
74 addOutput( new QgsProcessingOutputNumber( u"UNCHANGED_COUNT"_s, QObject::tr( "Count of unchanged features" ) ) );
75 addOutput( new QgsProcessingOutputNumber( u"ADDED_COUNT"_s, QObject::tr( "Count of features added in revised layer" ) ) );
76 addOutput( new QgsProcessingOutputNumber( u"DELETED_COUNT"_s, QObject::tr( "Count of features deleted from original layer" ) ) );
77}
78
79QString QgsDetectVectorChangesAlgorithm::shortHelpString() const
80{
81 return QObject::tr(
82 "This algorithm compares two vector layers, and determines which features are unchanged, added or deleted between "
83 "the two. It is designed for comparing two different versions of the same dataset.\n\n"
84 "When comparing features, the original and revised feature geometries will be compared against each other. Depending "
85 "on the Geometry Comparison Behavior setting, the comparison will either be made using an exact comparison (where "
86 "geometries must be an exact match for each other, including the order and count of vertices) or a topological "
87 "comparison only (where geometries are considered equal if all of their component edges overlap. E.g. "
88 "lines with the same vertex locations but opposite direction will be considered equal by this method). If the topological "
89 "comparison is selected then any z or m values present in the geometries will not be compared.\n\n"
90 "By default, the algorithm compares all attributes from the original and revised features. If the Attributes to Consider for Match "
91 "parameter is changed, then only the selected attributes will be compared (e.g. allowing users to ignore a timestamp or ID field "
92 "which is expected to change between the revisions).\n\n"
93 "If any features in the original or revised layers do not have an associated geometry, then care must be taken to ensure "
94 "that these features have a unique set of attributes selected for comparison. If this condition is not met, warnings will be "
95 "raised and the resultant outputs may be misleading.\n\n"
96 "The algorithm outputs three layers, one containing all features which are considered to be unchanged between the revisions, "
97 "one containing features deleted from the original layer which are not present in the revised layer, and one containing features "
98 "added to the revised layer which are not present in the original layer."
99 );
100}
101
102QString QgsDetectVectorChangesAlgorithm::shortDescription() const
103{
104 return QObject::tr( "Calculates features which are unchanged, added or deleted between two dataset versions." );
105}
106
107QgsDetectVectorChangesAlgorithm *QgsDetectVectorChangesAlgorithm::createInstance() const
108{
109 return new QgsDetectVectorChangesAlgorithm();
110}
111
112bool QgsDetectVectorChangesAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
113{
114 mOriginal.reset( parameterAsSource( parameters, u"ORIGINAL"_s, context ) );
115 if ( !mOriginal )
116 throw QgsProcessingException( invalidSourceError( parameters, u"ORIGINAL"_s ) );
117
118 mRevised.reset( parameterAsSource( parameters, u"REVISED"_s, context ) );
119 if ( !mRevised )
120 throw QgsProcessingException( invalidSourceError( parameters, u"REVISED"_s ) );
121
122 mMatchType = static_cast<GeometryMatchType>( parameterAsEnum( parameters, u"MATCH_TYPE"_s, context ) );
123
124 switch ( mMatchType )
125 {
126 case Exact:
127 if ( mOriginal->wkbType() != mRevised->wkbType() )
129 QObject::tr( "Geometry type of revised layer (%1) does not match the original layer (%2). Consider using the \"Tolerant Match\" option instead." )
130 .arg( QgsWkbTypes::displayString( mRevised->wkbType() ), QgsWkbTypes::displayString( mOriginal->wkbType() ) )
131 );
132 break;
133
134 case Topological:
135 if ( QgsWkbTypes::geometryType( mOriginal->wkbType() ) != QgsWkbTypes::geometryType( mRevised->wkbType() ) )
137 QObject::tr( "Geometry type of revised layer (%1) does not match the original layer (%2)" )
139 );
140 break;
141 }
142
143 if ( mOriginal->sourceCrs() != mRevised->sourceCrs() )
144 feedback->reportError(
145 QObject::tr( "CRS for revised layer (%1) does not match the original layer (%2) - reprojection accuracy may affect geometry matching" )
146 .arg( mOriginal->sourceCrs().userFriendlyIdentifier(), mRevised->sourceCrs().userFriendlyIdentifier() ),
147 false
148 );
149
150 mFieldsToCompare = parameterAsStrings( parameters, u"COMPARE_ATTRIBUTES"_s, context );
151 mOriginalFieldsToCompareIndices.reserve( mFieldsToCompare.size() );
152 mRevisedFieldsToCompareIndices.reserve( mFieldsToCompare.size() );
153 QStringList missingOriginalFields;
154 QStringList missingRevisedFields;
155 for ( const QString &field : mFieldsToCompare )
156 {
157 const int originalIndex = mOriginal->fields().lookupField( field );
158 mOriginalFieldsToCompareIndices.append( originalIndex );
159 if ( originalIndex < 0 )
160 missingOriginalFields << field;
161
162 const int revisedIndex = mRevised->fields().lookupField( field );
163 if ( revisedIndex < 0 )
164 missingRevisedFields << field;
165 mRevisedFieldsToCompareIndices.append( revisedIndex );
166 }
167
168 if ( !missingOriginalFields.empty() )
169 throw QgsProcessingException( QObject::tr( "Original layer missing selected comparison attributes: %1" ).arg( missingOriginalFields.join( ',' ) ) );
170 if ( !missingRevisedFields.empty() )
171 throw QgsProcessingException( QObject::tr( "Revised layer missing selected comparison attributes: %1" ).arg( missingRevisedFields.join( ',' ) ) );
172
173 return true;
174}
175
176QVariantMap QgsDetectVectorChangesAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
177{
178 QString unchangedDestId;
179 std::unique_ptr<QgsFeatureSink> unchangedSink( parameterAsSink( parameters, u"UNCHANGED"_s, context, unchangedDestId, mOriginal->fields(), mOriginal->wkbType(), mOriginal->sourceCrs() ) );
180 if ( !unchangedSink && parameters.value( u"UNCHANGED"_s ).isValid() )
181 throw QgsProcessingException( invalidSinkError( parameters, u"UNCHANGED"_s ) );
182
183 QString addedDestId;
184 std::unique_ptr<QgsFeatureSink> addedSink( parameterAsSink( parameters, u"ADDED"_s, context, addedDestId, mRevised->fields(), mRevised->wkbType(), mRevised->sourceCrs() ) );
185 if ( !addedSink && parameters.value( u"ADDED"_s ).isValid() )
186 throw QgsProcessingException( invalidSinkError( parameters, u"ADDED"_s ) );
187
188 QString deletedDestId;
189 std::unique_ptr<QgsFeatureSink> deletedSink( parameterAsSink( parameters, u"DELETED"_s, context, deletedDestId, mOriginal->fields(), mOriginal->wkbType(), mOriginal->sourceCrs() ) );
190 if ( !deletedSink && parameters.value( u"DELETED"_s ).isValid() )
191 throw QgsProcessingException( invalidSinkError( parameters, u"DELETED"_s ) );
192
193 // first iteration: we loop through the entire original layer, building up a spatial index of ALL original geometries
194 // and collecting the original geometries themselves along with the attributes to compare
195 QgsFeatureRequest request;
196 request.setSubsetOfAttributes( mOriginalFieldsToCompareIndices );
197
198 QgsFeatureIterator it = mOriginal->getFeatures( request );
199
200 double step = mOriginal->featureCount() > 0 ? 100.0 / mOriginal->featureCount() : 0;
201 QHash<QgsFeatureId, QgsGeometry> originalGeometries;
202 QHash<QgsFeatureId, QgsAttributes> originalAttributes;
203 QHash<QgsAttributes, QgsFeatureId> originalNullGeometryAttributes;
204 QHash<QgsAttributes, QgsFeatureId> originalEmptyGeometryAttributes;
205 long current = 0;
206
207 QgsAttributes attrs;
208 attrs.resize( mFieldsToCompare.size() );
209
210 const QgsSpatialIndex index( it, [&]( const QgsFeature &f ) -> bool {
211 if ( feedback->isCanceled() )
212 return false;
213
214 if ( !mFieldsToCompare.empty() )
215 {
216 int idx = 0;
217 for ( const int field : mOriginalFieldsToCompareIndices )
218 {
219 attrs[idx++] = f.attributes().at( field );
220 }
221 originalAttributes.insert( f.id(), attrs );
222 }
223
224 if ( f.hasGeometry() && !f.geometry().isEmpty() )
225 {
226 originalGeometries.insert( f.id(), f.geometry() );
227 }
228 else if ( f.hasGeometry() && f.geometry().isEmpty() )
229 {
230 auto emptyGeomIt = originalEmptyGeometryAttributes.constFind( attrs );
231 if ( emptyGeomIt != originalEmptyGeometryAttributes.constEnd() )
232 {
233 feedback->reportError(
234 QObject::tr(
235 "A non-unique set of comparison attributes was found for "
236 "one or more features with EMPTY geometries - results may be misleading (features %1 and %2)"
237 )
238 .arg( f.id() )
239 .arg( emptyGeomIt.value() )
240 );
241 }
242 else
243 {
244 originalEmptyGeometryAttributes.insert( attrs, f.id() );
245 }
246 }
247 else // no geometry
248 {
249 if ( originalNullGeometryAttributes.contains( attrs ) )
250 {
251 feedback->reportError(
252 QObject::tr(
253 "A non-unique set of comparison attributes was found for "
254 "one or more features without geometries - results may be misleading (features %1 and %2)"
255 )
256 .arg( f.id() )
257 .arg( originalNullGeometryAttributes.value( attrs ) )
258 );
259 }
260 else
261 {
262 originalNullGeometryAttributes.insert( attrs, f.id() );
263 }
264 }
265
266 // overall this loop takes about 10% of time
267 current++;
268 feedback->setProgress( 0.10 * current * step );
269 return true;
270 } );
271
272 QSet<QgsFeatureId> unchangedOriginalIds;
273 QSet<QgsFeatureId> addedRevisedIds;
274 current = 0;
275
276 // second iteration: we loop through ALL revised features, checking whether each is a match for a geometry from the
277 // original set. If so, check if the feature is unchanged. If there's no match with the original features, we mark it as an "added" feature
278 step = mRevised->featureCount() > 0 ? 100.0 / mRevised->featureCount() : 0;
279 QgsFeatureRequest revisedRequest = QgsFeatureRequest().setDestinationCrs( mOriginal->sourceCrs(), context.transformContext() );
280 revisedRequest.setSubsetOfAttributes( mRevisedFieldsToCompareIndices );
281 it = mRevised->getFeatures( revisedRequest );
282 QgsFeature revisedFeature;
283 while ( it.nextFeature( revisedFeature ) )
284 {
285 if ( feedback->isCanceled() )
286 break;
287
288 int idx = 0;
289 for ( const int field : mRevisedFieldsToCompareIndices )
290 {
291 attrs[idx++] = revisedFeature.attributes().at( field );
292 }
293
294 bool matched = false;
295
296 if ( !revisedFeature.hasGeometry() )
297 {
298 if ( originalNullGeometryAttributes.contains( attrs ) )
299 {
300 // found a match for feature
301 unchangedOriginalIds.insert( originalNullGeometryAttributes.value( attrs ) );
302 matched = true;
303 }
304 }
305 else if ( revisedFeature.hasGeometry() && revisedFeature.geometry().isEmpty() )
306 {
307 auto emptyIt = originalEmptyGeometryAttributes.constFind( attrs );
308 if ( emptyIt != originalEmptyGeometryAttributes.constEnd() )
309 {
310 // found a match for feature
311 unchangedOriginalIds.insert( emptyIt.value() );
312 matched = true;
313 }
314 }
315 else // revised feature has non-empty geometry
316 {
317 // can we match this feature?
318 const QList<QgsFeatureId> candidates = index.intersects( revisedFeature.geometry().boundingBox() );
319
320 // lazy evaluate -- there may be NO candidates!
321 QgsGeometry revised;
322
323 for ( const QgsFeatureId candidateId : candidates )
324 {
325 if ( unchangedOriginalIds.contains( candidateId ) )
326 {
327 // already matched this original feature
328 continue;
329 }
330
331 // attribute comparison is faster to do first, if desired
332 if ( !mFieldsToCompare.empty() )
333 {
334 if ( attrs != originalAttributes[candidateId] )
335 {
336 // attributes don't match, so candidates is not a match
337 continue;
338 }
339 }
340
341 QgsGeometry original = originalGeometries.value( candidateId );
342 // lazy evaluation
343 if ( revised.isNull() )
344 {
345 revised = revisedFeature.geometry();
346 // drop z/m if not wanted for match
347 switch ( mMatchType )
348 {
349 case Topological:
350 {
351 revised.get()->dropMValue();
352 revised.get()->dropZValue();
353 original.get()->dropMValue();
354 original.get()->dropZValue();
355 break;
356 }
357
358 case Exact:
359 break;
360 }
361 }
362
363 bool geometryMatch = false;
364 switch ( mMatchType )
365 {
366 case Topological:
367 {
368 geometryMatch = revised.isTopologicallyEqual( original );
369 break;
370 }
371
372 case Exact:
373 geometryMatch = revised.isExactlyEqual( original );
374 break;
375 }
376
377 if ( geometryMatch )
378 {
379 // candidate is a match for feature
380 unchangedOriginalIds.insert( candidateId );
381 matched = true;
382 break;
383 }
384 }
385 }
386
387 if ( !matched )
388 {
389 // new feature
390 addedRevisedIds.insert( revisedFeature.id() );
391 }
392
393 current++;
394 feedback->setProgress( 0.70 * current * step + 10 ); // takes about 70% of time
395 }
396
397 // third iteration: iterate back over the original features, and direct them to the appropriate sink.
398 // If they were marked as unchanged during the second iteration, we put them in the unchanged sink. Otherwise
399 // they are placed into the deleted sink.
400 step = mOriginal->featureCount() > 0 ? 100.0 / mOriginal->featureCount() : 0;
401
403 it = mOriginal->getFeatures( request );
404 current = 0;
405 long deleted = 0;
406 QgsFeature f;
407 QgsGeometry g;
408 QList<QgsFeatureId> emptyGeometryIds = originalEmptyGeometryAttributes.values();
409
410 while ( it.nextFeature( f ) )
411 {
412 if ( feedback->isCanceled() )
413 break;
414
415 // attempt to use already fetched geometry or use Null/Empty geometry
416 g = originalGeometries.value( f.id(), QgsGeometry() );
417 if ( g.isNull() && emptyGeometryIds.contains( f.id() ) )
418 {
419 g = QgsGeometry( QgsGeometryFactory::geomFromWkbType( mOriginal->wkbType() ) );
420 }
421 f.setGeometry( g );
422
423 if ( unchangedOriginalIds.contains( f.id() ) )
424 {
425 // unchanged
426 if ( unchangedSink )
427 {
428 if ( !unchangedSink->addFeature( f, QgsFeatureSink::FastInsert ) )
429 throw QgsProcessingException( writeFeatureError( unchangedSink.get(), parameters, u"UNCHANGED"_s ) );
430 else
431 feedback->featureAddedToSink( u"UNCHANGED"_s );
432 }
433 }
434 else
435 {
436 // deleted feature
437 if ( deletedSink )
438 {
439 if ( !deletedSink->addFeature( f, QgsFeatureSink::FastInsert ) )
440 throw QgsProcessingException( writeFeatureError( deletedSink.get(), parameters, u"DELETED"_s ) );
441 else
442 feedback->featureAddedToSink( u"DELETED"_s );
443 }
444 deleted++;
445 }
446
447 current++;
448 feedback->setProgress( 0.10 * current * step + 80 ); // takes about 10% of time
449 }
450
451 // forth iteration: collect all added features and add them to the added sink
452 // NOTE: while we could potentially do this as part of the second iteration and save some time, we instead
453 // do this here using a brand new request because the second iteration
454 // is fetching reprojected features and we ideally want geometries from the revised layer's actual CRS only here!
455 // also, the second iteration is only fetching the actual attributes used in the comparison, whereas we want
456 // to include all attributes in the "added" output
457 if ( addedSink )
458 {
459 step = addedRevisedIds.size() > 0 ? 100.0 / addedRevisedIds.size() : 0;
460 it = mRevised->getFeatures( QgsFeatureRequest().setFilterFids( addedRevisedIds ) );
461 current = 0;
462 while ( it.nextFeature( f ) )
463 {
464 if ( feedback->isCanceled() )
465 break;
466
467 // added feature
468 if ( !addedSink->addFeature( f, QgsFeatureSink::FastInsert ) )
469 throw QgsProcessingException( writeFeatureError( addedSink.get(), parameters, u"ADDED"_s ) );
470 else
471 feedback->featureAddedToSink( u"ADDED"_s );
472
473 current++;
474 feedback->setProgress( 0.10 * current * step + 90 ); // takes about 10% of time
475 }
476 }
477 feedback->setProgress( 100 );
478
479 feedback->pushInfo( QObject::tr( "%n feature(s) unchanged", nullptr, unchangedOriginalIds.size() ) );
480 feedback->pushInfo( QObject::tr( "%n feature(s) added", nullptr, addedRevisedIds.size() ) );
481 feedback->pushInfo( QObject::tr( "%n feature(s) deleted", nullptr, deleted ) );
482
483 if ( unchangedSink )
484 {
485 unchangedSink->finalize();
486 feedback->featureSinkFinalized( u"UNCHANGED"_s );
487 }
488 if ( addedSink )
489 {
490 addedSink->finalize();
491 feedback->featureSinkFinalized( u"ADDED"_s );
492 }
493 if ( deletedSink )
494 {
495 deletedSink->finalize();
496 feedback->featureSinkFinalized( u"DELETED"_s );
497 }
498
499 QVariantMap outputs;
500 outputs.insert( u"UNCHANGED"_s, unchangedDestId );
501 outputs.insert( u"ADDED"_s, addedDestId );
502 outputs.insert( u"DELETED"_s, deletedDestId );
503 outputs.insert( u"UNCHANGED_COUNT"_s, static_cast<long long>( unchangedOriginalIds.size() ) );
504 outputs.insert( u"ADDED_COUNT"_s, static_cast<long long>( addedRevisedIds.size() ) );
505 outputs.insert( u"DELETED_COUNT"_s, static_cast<long long>( deleted ) );
506
507 return outputs;
508}
509
@ VectorAnyGeometry
Any vector layer with geometry.
Definition qgis.h:3728
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Definition qgis.h:2343
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
Definition qgis.h:3961
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
A vector of attributes.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
QgsAttributes attributes
Definition qgsfeature.h:64
QgsFeatureId id
Definition qgsfeature.h:63
QgsGeometry geometry
Definition qgsfeature.h:66
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool isCanceled() const
Tells whether the operation has been canceled already.
Definition qgsfeedback.h:56
void setProgress(double progress)
Sets the current progress for the feedback object.
Definition qgsfeedback.h:65
static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType(Qgis::WkbType t)
Returns empty geometry from wkb type.
A geometry is the spatial representation of a feature.
bool isExactlyEqual(const QgsGeometry &geometry, Qgis::GeometryBackend backend=Qgis::GeometryBackend::QGIS) const
Compares the geometry with another geometry using the specified backend.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
bool isTopologicallyEqual(const QgsGeometry &geometry, Qgis::GeometryBackend backend=Qgis::GeometryBackend::GEOS) const
Compares the geometry with another geometry using the specified backend.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Contains information about the context in which a processing algorithm is executed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
void featureAddedToSink(const QString &output)
Reports that a feature was added to the the sink associated with the specified algorithm output.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
void featureSinkFinalized(const QString &output)
Reports that a feature sink has been finalized.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
A numeric output for processing algorithms.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
A feature sink output for processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
A vector layer or feature source field parameter for processing algorithms.
void setDefaultToAllFields(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
A spatial index for QgsFeature objects.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static Q_INVOKABLE QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
static Q_INVOKABLE QString geometryDisplayString(Qgis::GeometryType type)
Returns a display string for a geometry type.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features