QGIS API Documentation 4.1.0-Master (ca2ac17535b)
Loading...
Searching...
No Matches
qgsalgorithmgrid.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmgrid.cpp
3 ---------------------
4 begin : August 2019
5 copyright : (C) 2019 by Clemens Raffler
6 email : clemens dot raffler 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
18//Disclaimer:This feature was developed by: Michael Minn, 2010
19
20#include "qgsalgorithmgrid.h"
21
22#include "qgslinestring.h"
23#include "qgspolygon.h"
24#include "qgsvectorlayer.h"
25#include "qgswkbtypes.h"
26
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
32
33QString QgsGridAlgorithm::name() const
34{
35 return u"creategrid"_s;
36}
37
38QString QgsGridAlgorithm::displayName() const
39{
40 return QObject::tr( "Create grid" );
41}
42
43QStringList QgsGridAlgorithm::tags() const
44{
45 return QObject::tr( "grid,lines,polygons,vector,create,fishnet,diamond,hexagon" ).split( ',' );
46}
47
48QString QgsGridAlgorithm::group() const
49{
50 return QObject::tr( "Vector creation" );
51}
52
53QString QgsGridAlgorithm::groupId() const
54{
55 return u"vectorcreation"_s;
56}
57
58void QgsGridAlgorithm::initAlgorithm( const QVariantMap & )
59{
60 addParameter( new QgsProcessingParameterEnum(
61 u"TYPE"_s,
62 QObject::tr( "Grid type" ),
63 QStringList() << QObject::tr( "Point" ) << QObject::tr( "Line" ) << QObject::tr( "Rectangle (Polygon)" ) << QObject::tr( "Diamond (Polygon)" ) << QObject::tr( "Hexagon (Polygon)" ),
64 false,
65 0
66 ) );
67
68 addParameter( new QgsProcessingParameterExtent( u"EXTENT"_s, QObject::tr( "Grid extent" ) ) );
69
70 addParameter( new QgsProcessingParameterDistance( u"HSPACING"_s, QObject::tr( "Horizontal spacing" ), 1, u"CRS"_s, false, 0, 1000000000.0 ) );
71 addParameter( new QgsProcessingParameterDistance( u"VSPACING"_s, QObject::tr( "Vertical spacing" ), 1, u"CRS"_s, false, 0, 1000000000.0 ) );
72
73 addParameter( new QgsProcessingParameterDistance( u"HOVERLAY"_s, QObject::tr( "Horizontal overlay" ), 0, u"CRS"_s, false ) );
74 addParameter( new QgsProcessingParameterDistance( u"VOVERLAY"_s, QObject::tr( "Vertical overlay" ), 0, u"CRS"_s, false ) );
75
76 addParameter( new QgsProcessingParameterCrs( u"CRS"_s, QObject::tr( "Grid CRS" ), u"ProjectCrs"_s ) );
77
78 addParameter( new QgsProcessingParameterFeatureSink( u"OUTPUT"_s, QObject::tr( "Grid" ), Qgis::ProcessingSourceType::VectorAnyGeometry ) );
79}
80
81QString QgsGridAlgorithm::shortHelpString() const
82{
83 return QObject::tr(
84 "This algorithm creates a vector layer with a grid covering a given extent. "
85 "Elements in the grid can be points, lines or polygons. The size and/or "
86 "placement of each element in the grid is defined using a horizontal and "
87 "vertical spacing. The CRS of the output layer must be defined. The grid extent "
88 "and the spacing values must be expressed in the coordinates and units of "
89 "this CRS. The top-left point (minX, maxY) is used as the reference point. "
90 "That means that, at that point, an element is guaranteed to be placed. "
91 "Unless the width and height of the selected extent is a multiple of the "
92 "selected spacing, that is not true for the other points that define that extent."
93 );
94}
95QString QgsGridAlgorithm::shortDescription() const
96{
97 return QObject::tr( "Creates a vector layer with a grid covering a given extent." );
98}
99
100QgsGridAlgorithm *QgsGridAlgorithm::createInstance() const
101{
102 return new QgsGridAlgorithm();
103}
104
105bool QgsGridAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
106{
107 mIdx = parameterAsEnum( parameters, u"TYPE"_s, context );
108 mHSpacing = parameterAsDouble( parameters, u"HSPACING"_s, context );
109 mVSpacing = parameterAsDouble( parameters, u"VSPACING"_s, context );
110 mHOverlay = parameterAsDouble( parameters, u"HOVERLAY"_s, context );
111 mVOverlay = parameterAsDouble( parameters, u"VOVERLAY"_s, context );
112 mCrs = parameterAsCrs( parameters, u"CRS"_s, context );
113 mGridExtent = parameterAsExtent( parameters, u"EXTENT"_s, context, mCrs );
114
115 return true;
116}
117
118QVariantMap QgsGridAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
119{
120 if ( mHSpacing <= 0 || mVSpacing <= 0 )
121 throw QgsProcessingException( QObject::tr( "Invalid grid spacing. horizontal: '%1', vertical: '%2'" ).arg( mHSpacing ).arg( mVSpacing ) );
122
123 if ( mGridExtent.width() < mHSpacing ) //check if grid extent is smaller than horizontal spacing
124 throw QgsProcessingException( QObject::tr( "Horizontal spacing is too large for the covered area." ) );
125
126 if ( mGridExtent.height() < mVSpacing ) //check if grid extent is smaller than vertical spacing
127 throw QgsProcessingException( QObject::tr( "Vertical spacing is too large for the covered area." ) );
128
129 // if ( mHSpacing <= mHOverlay || mVSpacing <= mVOverlay )
130 // throw QgsProcessingException( QObject::tr( "Invalid overlay: horizontal: '%1', vertical: '%2'" ).arg( mHOverlay ).arg( mVOverlay ) );
131
132 QgsFields fields = QgsFields();
133 fields.append( QgsField( u"id"_s, QMetaType::Type::LongLong ) );
134 fields.append( QgsField( u"left"_s, QMetaType::Type::Double ) );
135 fields.append( QgsField( u"top"_s, QMetaType::Type::Double ) );
136 fields.append( QgsField( u"right"_s, QMetaType::Type::Double ) );
137 fields.append( QgsField( u"bottom"_s, QMetaType::Type::Double ) );
138
139 switch ( mIdx )
140 {
141 case 0: //point
142 case 2: //rectangle
143 case 4: //hexagon
144 fields.append( QgsField( u"row_index"_s, QMetaType::Type::LongLong ) );
145 fields.append( QgsField( u"col_index"_s, QMetaType::Type::LongLong ) );
146 break;
147 default:
148 break;
149 }
150
151
153 switch ( mIdx )
154 {
155 case 0:
156 outputWkb = Qgis::WkbType::Point;
157 break;
158 case 1:
159 outputWkb = Qgis::WkbType::LineString;
160 break;
161 }
162
163 QString dest;
164 std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, u"OUTPUT"_s, context, dest, fields, outputWkb, mCrs ) );
165 if ( !sink )
166 throw QgsProcessingException( invalidSinkError( parameters, u"OUTPUT"_s ) );
167
168 feedback->setProgress( 0 );
169
170 switch ( mIdx )
171 {
172 case 0: //point
173 createPointGrid( sink, feedback );
174 break;
175 case 1: //line
176 createLineGrid( sink, feedback );
177 break;
178 case 2: //rectangle
179 createRectangleGrid( sink, feedback );
180 break;
181 case 3: //diamond
182 createDiamondGrid( sink, feedback );
183 break;
184 case 4: //hexagon
185 createHexagonGrid( sink, feedback );
186 break;
187 }
188
189 sink->finalize();
190 feedback->featureSinkFinalized( u"OUTPUT"_s );
191 QVariantMap outputs;
192 outputs.insert( u"OUTPUT"_s, dest );
193 return outputs;
194}
195
196void QgsGridAlgorithm::createPointGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
197{
199
200 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( mHSpacing - mHOverlay ) ) );
201 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - mVOverlay ) ) );
202
203 long long id = 1;
204 long long cnt = 0;
205 const long long cellcnt = rows * cols;
206
207 int thisProgress = 0;
208 int lastProgress = 0;
209
210 for ( long long col = 0; col < cols; col++ )
211 {
212 const double x = mGridExtent.xMinimum() + ( col * mHSpacing - col * mHOverlay );
213
214 for ( long long row = 0; row < rows; row++ )
215 {
216 const double y = mGridExtent.yMaximum() - ( row * mVSpacing - row * mVOverlay );
217
218 f.setGeometry( QgsGeometry( new QgsPoint( x, y ) ) );
219 f.setAttributes( QgsAttributes() << id << x << y << x + mHSpacing << y + mVSpacing << row << col );
220 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
221 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
222 else
223 feedback->featureAddedToSink( u"OUTPUT"_s );
224
225 id++;
226 cnt++;
227
228 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
229 if ( feedback && thisProgress != lastProgress )
230 {
231 lastProgress = thisProgress;
232 feedback->setProgress( lastProgress );
233 }
234
235 if ( feedback && feedback->isCanceled() )
236 break;
237 }
238 if ( feedback && feedback->isCanceled() )
239 break;
240 }
241}
242
243void QgsGridAlgorithm::createLineGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
244{
246
247 double hSpace[2];
248 if ( mHOverlay > 0 )
249 {
250 hSpace[0] = mHSpacing - mHOverlay;
251 hSpace[1] = mHOverlay;
252 }
253 else
254 {
255 hSpace[0] = mHSpacing;
256 hSpace[1] = mHSpacing;
257 }
258
259 double vSpace[2];
260 if ( mVOverlay > 0 )
261 {
262 vSpace[0] = mVSpacing - mVOverlay;
263 vSpace[1] = mVOverlay;
264 }
265 else
266 {
267 vSpace[0] = mVSpacing;
268 vSpace[1] = mVSpacing;
269 }
270
271 long long cnt = 0;
272 long long id = 1;
273
274 //latitude lines
275 double cntMax = mGridExtent.height() / mVSpacing;
276
277 int thisProgress = 0;
278 int lastProgress = 0;
279
280 double y = mGridExtent.yMaximum();
281
282 while ( y >= mGridExtent.yMinimum() )
283 {
284 if ( feedback && feedback->isCanceled() )
285 break;
286
287 const QgsPoint pt1 = QgsPoint( mGridExtent.xMinimum(), y );
288 const QgsPoint pt2 = QgsPoint( mGridExtent.xMaximum(), y );
289
290 f.setGeometry( QgsGeometry( new QgsLineString( pt1, pt2 ) ) );
291 f.setAttributes( QgsAttributes() << id << mGridExtent.xMinimum() << y << mGridExtent.xMaximum() << y );
292 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
293 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
294 else
295 feedback->featureAddedToSink( u"OUTPUT"_s );
296 y = y - vSpace[cnt % 2];
297
298 id++;
299 cnt++;
300
301 //use 50 as count multiplicator because only half of the features are processed at this point
302 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / cntMax ) * 50 );
303 if ( feedback && thisProgress != lastProgress )
304 {
305 lastProgress = thisProgress;
306 feedback->setProgress( lastProgress );
307 }
308 }
309 //set progress to 50 manually in case the division doesn't amount to 50.
310 if ( feedback )
311 feedback->setProgress( 50 );
312
313 //longitude lines
314 cnt = 0;
315
316 //latitude lines
317 cntMax = mGridExtent.width() / mHSpacing;
318
319 lastProgress = 50;
320
321 double x = mGridExtent.xMinimum();
322
323 while ( x <= mGridExtent.xMaximum() )
324 {
325 if ( feedback && feedback->isCanceled() )
326 break;
327
328 const QgsPoint pt1 = QgsPoint( x, mGridExtent.yMaximum() );
329 const QgsPoint pt2 = QgsPoint( x, mGridExtent.yMinimum() );
330 f.setGeometry( QgsGeometry( new QgsLineString( pt1, pt2 ) ) );
331 f.setAttributes( QgsAttributes() << id << x << mGridExtent.yMaximum() << x << mGridExtent.yMinimum() );
332 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
333 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
334 else
335 feedback->featureAddedToSink( u"OUTPUT"_s );
336 x = x + hSpace[cnt % 2];
337
338 id++;
339 cnt++;
340
341 thisProgress = static_cast<int>( static_cast<double>( 50 ) + ( static_cast<double>( cnt ) / cntMax ) * 100 );
342 if ( feedback && thisProgress != lastProgress )
343 {
344 lastProgress = thisProgress;
345 feedback->setProgress( lastProgress );
346 }
347 }
348 if ( feedback )
349 feedback->setProgress( 100 );
350}
351
352void QgsGridAlgorithm::createRectangleGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
353{
355
356 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( mHSpacing - mHOverlay ) ) );
357 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - mVOverlay ) ) );
358
359 long long id = 1;
360 long long cnt = 0;
361 const long long cellcnt = rows * cols;
362
363 int thisProgress = 0;
364 int lastProgress = 0;
365 QVector<double> ringX( 5 );
366 QVector<double> ringY( 5 );
367
368 for ( long long col = 0; col < cols; col++ )
369 {
370 if ( feedback && feedback->isCanceled() )
371 break;
372
373 const double x1 = mGridExtent.xMinimum() + ( col * mHSpacing - col * mHOverlay );
374 const double x2 = x1 + mHSpacing;
375
376 for ( long long row = 0; row < rows; row++ )
377 {
378 const double y1 = mGridExtent.yMaximum() - ( row * mVSpacing - row * mVOverlay );
379 const double y2 = y1 - mVSpacing;
380
381 ringX = { x1, x2, x2, x1, x1 };
382 ringY = { y1, y1, y2, y2, y1 };
383 auto poly = std::make_unique<QgsPolygon>();
384 poly->setExteriorRing( new QgsLineString( ringX, ringY ) );
385 f.setGeometry( std::move( poly ) );
386 f.setAttributes( QgsAttributes() << id << x1 << y1 << x2 << y2 << row << col );
387 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
388 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
389 else
390 feedback->featureAddedToSink( u"OUTPUT"_s );
391
392 id++;
393 cnt++;
394
395 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
396 if ( feedback && thisProgress != lastProgress )
397 {
398 lastProgress = thisProgress;
399 feedback->setProgress( lastProgress );
400 }
401
402 if ( feedback && feedback->isCanceled() )
403 break;
404 }
405 }
406}
407
408void QgsGridAlgorithm::createDiamondGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
409{
411
412 const double halfHSpacing = mHSpacing / 2;
413 const double halfVSpacing = mVSpacing / 2;
414
415 const double halfHOverlay = mHOverlay / 2;
416 const double halfVOverlay = mVOverlay / 2;
417
418 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( halfHSpacing - halfHOverlay ) ) );
419 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - halfVOverlay ) ) );
420
421 long long id = 1;
422 long long cnt = 0;
423 const long long cellcnt = rows * cols;
424
425 int thisProgress = 0;
426 int lastProgress = 0;
427 QVector<double> ringX( 5 );
428 QVector<double> ringY( 5 );
429
430 for ( long long col = 0; col < cols; col++ )
431 {
432 if ( feedback && feedback->isCanceled() )
433 break;
434
435 const double x = mGridExtent.xMinimum() - ( col * halfHOverlay );
436 const double x1 = x + ( ( col + 0 ) * halfHSpacing );
437 const double x2 = x + ( ( col + 1 ) * halfHSpacing );
438 const double x3 = x + ( ( col + 2 ) * halfHSpacing );
439
440 for ( long long row = 0; row < rows; row++ )
441 {
442 const double y = mGridExtent.yMaximum() + ( row * halfVOverlay );
443
444 double y1;
445 double y2;
446 double y3;
447
448 if ( ( col % 2 ) == 0 )
449 {
450 y1 = y - ( ( ( row * 2 ) + 0 ) * halfVSpacing );
451 y2 = y - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
452 y3 = y - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
453 }
454 else
455 {
456 y1 = y - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
457 y2 = y - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
458 y3 = y - ( ( ( row * 2 ) + 3 ) * halfVSpacing );
459 }
460
461 ringX = { x1, x2, x3, x2, x1 };
462 ringY = { y2, y1, y2, y3, y2 };
463 auto poly = std::make_unique<QgsPolygon>();
464 poly->setExteriorRing( new QgsLineString( ringX, ringY ) );
465 f.setGeometry( std::move( poly ) );
466 f.setAttributes( QgsAttributes() << id << x1 << y1 << x3 << y3 );
467 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
468 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
469 else
470 feedback->featureAddedToSink( u"OUTPUT"_s );
471
472 id++;
473 cnt++;
474
475 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
476 if ( feedback && thisProgress != lastProgress )
477 {
478 lastProgress = thisProgress;
479 feedback->setProgress( lastProgress );
480 }
481
482 if ( feedback && feedback->isCanceled() )
483 break;
484 }
485 }
486}
487
488void QgsGridAlgorithm::createHexagonGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
489{
491
492 // To preserve symmetry, hspacing is fixed relative to vspacing
493 const double xVertexLo = 0.288675134594813 * mVSpacing;
494 const double xVertexHi = 0.577350269189626 * mVSpacing;
495
496 mHSpacing = xVertexLo + xVertexHi;
497
498 mHOverlay = mHSpacing - mHOverlay;
499
500 if ( mHOverlay < 0 )
501 {
503 QObject::tr( "To preserve symmetry, hspacing is fixed relative to vspacing\n hspacing is fixed at: %1 and hoverlay is fixed at: %2 hoverlay cannot be negative. Increase hoverlay." )
504 .arg( mHSpacing )
505 .arg( mHOverlay )
506 );
507 }
508
509 const double halfVSpacing = mVSpacing / 2;
510
511 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( mHOverlay ) ) );
512 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - mVOverlay ) ) );
513
514 long long id = 1;
515 long long cnt = 0;
516 const long long cellcnt = rows * cols;
517
518 int thisProgress = 0;
519 int lastProgress = 0;
520
521 QVector<double> ringX( 7 );
522 QVector<double> ringY( 7 );
523 for ( long long col = 0; col < cols; col++ )
524 {
525 if ( feedback && feedback->isCanceled() )
526 break;
527
528 // (column + 1) and (row + 1) calculation is used to maintain
529 // topology between adjacent shapes and avoid overlaps/holes
530 // due to rounding errors
531
532 const double x1 = mGridExtent.xMinimum() + ( col * mHOverlay );
533 const double x2 = x1 + ( xVertexHi - xVertexLo );
534 const double x3 = mGridExtent.xMinimum() + ( col * mHOverlay ) + mHSpacing;
535 const double x4 = x3 + ( xVertexHi - xVertexLo );
536
537 for ( long long row = 0; row < rows; row++ )
538 {
539 double y1;
540 double y2;
541 double y3;
542
543 if ( ( col % 2 ) == 0 )
544 {
545 y1 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 0 ) * halfVSpacing );
546 y2 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
547 y3 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
548 }
549 else
550 {
551 y1 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
552 y2 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
553 y3 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 3 ) * halfVSpacing );
554 }
555
556 ringX = { x1, x2, x3, x4, x3, x2, x1 };
557 ringY = { y2, y1, y1, y2, y3, y3, y2 };
558 auto poly = std::make_unique<QgsPolygon>();
559 poly->setExteriorRing( new QgsLineString( ringX, ringY ) );
560 f.setGeometry( std::move( poly ) );
561 f.setAttributes( QgsAttributes() << id << x1 << y1 << x4 << y3 << row << col );
562 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
563 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
564 else
565 feedback->featureAddedToSink( u"OUTPUT"_s );
566
567 id++;
568 cnt++;
569
570 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
571 if ( feedback && thisProgress != lastProgress )
572 {
573 lastProgress = thisProgress;
574 feedback->setProgress( lastProgress );
575 }
576
577 if ( feedback && feedback->isCanceled() )
578 break;
579 }
580 }
581}
582
@ VectorAnyGeometry
Any vector layer with geometry.
Definition qgis.h:3714
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
@ Point
Point.
Definition qgis.h:296
@ LineString
LineString.
Definition qgis.h:297
@ Polygon
Polygon.
Definition qgis.h:298
A vector of attributes.
@ 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
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
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
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:56
Container of fields for a vector layer.
Definition qgsfields.h:46
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
Definition qgsfields.cpp:75
A geometry is the spatial representation of a feature.
Line string geometry type, with support for z-dimension and m-values.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
Contains information about the context in which a processing algorithm is executed.
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.
void featureSinkFinalized(const QString &output)
Reports that a feature sink has been finalized.
A coordinate reference system parameter for processing algorithms.
A double numeric parameter for distance values.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
A rectangular map extent parameter for processing algorithms.
A feature sink output for processing algorithms.