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