QGIS API Documentation 4.3.0-Master (ffcfc20b9b4)
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 QGS_MARK_ALGORITHM_SOURCE
121
122 if ( mHSpacing <= 0 || mVSpacing <= 0 )
123 throw QgsProcessingException( QObject::tr( "Invalid grid spacing. horizontal: '%1', vertical: '%2'" ).arg( mHSpacing ).arg( mVSpacing ) );
124
125 if ( mGridExtent.width() < mHSpacing ) //check if grid extent is smaller than horizontal spacing
126 throw QgsProcessingException( QObject::tr( "Horizontal spacing is too large for the covered area." ) );
127
128 if ( mGridExtent.height() < mVSpacing ) //check if grid extent is smaller than vertical spacing
129 throw QgsProcessingException( QObject::tr( "Vertical spacing is too large for the covered area." ) );
130
131 // if ( mHSpacing <= mHOverlay || mVSpacing <= mVOverlay )
132 // throw QgsProcessingException( QObject::tr( "Invalid overlay: horizontal: '%1', vertical: '%2'" ).arg( mHOverlay ).arg( mVOverlay ) );
133
134 QgsFields fields = QgsFields();
135 fields.append( QgsField( u"id"_s, QMetaType::Type::LongLong ) );
136 fields.append( QgsField( u"left"_s, QMetaType::Type::Double ) );
137 fields.append( QgsField( u"top"_s, QMetaType::Type::Double ) );
138 fields.append( QgsField( u"right"_s, QMetaType::Type::Double ) );
139 fields.append( QgsField( u"bottom"_s, QMetaType::Type::Double ) );
140
141 switch ( mIdx )
142 {
143 case 0: //point
144 case 2: //rectangle
145 case 4: //hexagon
146 fields.append( QgsField( u"row_index"_s, QMetaType::Type::LongLong ) );
147 fields.append( QgsField( u"col_index"_s, QMetaType::Type::LongLong ) );
148 break;
149 default:
150 break;
151 }
152
153
155 switch ( mIdx )
156 {
157 case 0:
158 outputWkb = Qgis::WkbType::Point;
159 break;
160 case 1:
161 outputWkb = Qgis::WkbType::LineString;
162 break;
163 }
164
165 QString dest;
166 std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, u"OUTPUT"_s, context, dest, fields, outputWkb, mCrs ) );
167 if ( !sink )
168 throw QgsProcessingException( invalidSinkError( parameters, u"OUTPUT"_s ) );
169
170 feedback->setProgress( 0 );
171
172 switch ( mIdx )
173 {
174 case 0: //point
175 createPointGrid( sink, feedback );
176 break;
177 case 1: //line
178 createLineGrid( sink, feedback );
179 break;
180 case 2: //rectangle
181 createRectangleGrid( sink, feedback );
182 break;
183 case 3: //diamond
184 createDiamondGrid( sink, feedback );
185 break;
186 case 4: //hexagon
187 createHexagonGrid( sink, feedback );
188 break;
189 }
190
191 sink->finalize();
192 feedback->featureSinkFinalized( u"OUTPUT"_s );
193 QVariantMap outputs;
194 outputs.insert( u"OUTPUT"_s, dest );
195 return outputs;
196}
197
198void QgsGridAlgorithm::createPointGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
199{
201
202 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( mHSpacing - mHOverlay ) ) );
203 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - mVOverlay ) ) );
204
205 long long id = 1;
206 long long cnt = 0;
207 const long long cellcnt = rows * cols;
208
209 int thisProgress = 0;
210 int lastProgress = 0;
211
212 for ( long long col = 0; col < cols; col++ )
213 {
214 const double x = mGridExtent.xMinimum() + ( col * mHSpacing - col * mHOverlay );
215
216 for ( long long row = 0; row < rows; row++ )
217 {
218 const double y = mGridExtent.yMaximum() - ( row * mVSpacing - row * mVOverlay );
219
220 f.setGeometry( QgsGeometry( new QgsPoint( x, y ) ) );
221 f.setAttributes( QgsAttributes() << id << x << y << x + mHSpacing << y + mVSpacing << row << col );
222 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
223 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
224 else
225 feedback->featureAddedToSink( u"OUTPUT"_s );
226
227 id++;
228 cnt++;
229
230 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
231 if ( feedback && thisProgress != lastProgress )
232 {
233 lastProgress = thisProgress;
234 feedback->setProgress( lastProgress );
235 }
236
237 if ( feedback && feedback->isCanceled() )
238 break;
239 }
240 if ( feedback && feedback->isCanceled() )
241 break;
242 }
243}
244
245void QgsGridAlgorithm::createLineGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
246{
248
249 double hSpace[2];
250 if ( mHOverlay > 0 )
251 {
252 hSpace[0] = mHSpacing - mHOverlay;
253 hSpace[1] = mHOverlay;
254 }
255 else
256 {
257 hSpace[0] = mHSpacing;
258 hSpace[1] = mHSpacing;
259 }
260
261 double vSpace[2];
262 if ( mVOverlay > 0 )
263 {
264 vSpace[0] = mVSpacing - mVOverlay;
265 vSpace[1] = mVOverlay;
266 }
267 else
268 {
269 vSpace[0] = mVSpacing;
270 vSpace[1] = mVSpacing;
271 }
272
273 long long cnt = 0;
274 long long id = 1;
275
276 //latitude lines
277 double cntMax = mGridExtent.height() / mVSpacing;
278
279 int thisProgress = 0;
280 int lastProgress = 0;
281
282 double y = mGridExtent.yMaximum();
283
284 while ( y >= mGridExtent.yMinimum() )
285 {
286 if ( feedback && feedback->isCanceled() )
287 break;
288
289 const QgsPoint pt1 = QgsPoint( mGridExtent.xMinimum(), y );
290 const QgsPoint pt2 = QgsPoint( mGridExtent.xMaximum(), y );
291
292 f.setGeometry( QgsGeometry( new QgsLineString( pt1, pt2 ) ) );
293 f.setAttributes( QgsAttributes() << id << mGridExtent.xMinimum() << y << mGridExtent.xMaximum() << y );
294 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
295 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
296 else
297 feedback->featureAddedToSink( u"OUTPUT"_s );
298 y = y - vSpace[cnt % 2];
299
300 id++;
301 cnt++;
302
303 //use 50 as count multiplicator because only half of the features are processed at this point
304 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / cntMax ) * 50 );
305 if ( feedback && thisProgress != lastProgress )
306 {
307 lastProgress = thisProgress;
308 feedback->setProgress( lastProgress );
309 }
310 }
311 //set progress to 50 manually in case the division doesn't amount to 50.
312 if ( feedback )
313 feedback->setProgress( 50 );
314
315 //longitude lines
316 cnt = 0;
317
318 //latitude lines
319 cntMax = mGridExtent.width() / mHSpacing;
320
321 lastProgress = 50;
322
323 double x = mGridExtent.xMinimum();
324
325 while ( x <= mGridExtent.xMaximum() )
326 {
327 if ( feedback && feedback->isCanceled() )
328 break;
329
330 const QgsPoint pt1 = QgsPoint( x, mGridExtent.yMaximum() );
331 const QgsPoint pt2 = QgsPoint( x, mGridExtent.yMinimum() );
332 f.setGeometry( QgsGeometry( new QgsLineString( pt1, pt2 ) ) );
333 f.setAttributes( QgsAttributes() << id << x << mGridExtent.yMaximum() << x << mGridExtent.yMinimum() );
334 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
335 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
336 else
337 feedback->featureAddedToSink( u"OUTPUT"_s );
338 x = x + hSpace[cnt % 2];
339
340 id++;
341 cnt++;
342
343 thisProgress = static_cast<int>( static_cast<double>( 50 ) + ( static_cast<double>( cnt ) / cntMax ) * 100 );
344 if ( feedback && thisProgress != lastProgress )
345 {
346 lastProgress = thisProgress;
347 feedback->setProgress( lastProgress );
348 }
349 }
350 if ( feedback )
351 feedback->setProgress( 100 );
352}
353
354void QgsGridAlgorithm::createRectangleGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
355{
357
358 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( mHSpacing - mHOverlay ) ) );
359 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - mVOverlay ) ) );
360
361 long long id = 1;
362 long long cnt = 0;
363 const long long cellcnt = rows * cols;
364
365 int thisProgress = 0;
366 int lastProgress = 0;
367 QVector<double> ringX( 5 );
368 QVector<double> ringY( 5 );
369
370 for ( long long col = 0; col < cols; col++ )
371 {
372 if ( feedback && feedback->isCanceled() )
373 break;
374
375 const double x1 = mGridExtent.xMinimum() + ( col * mHSpacing - col * mHOverlay );
376 const double x2 = x1 + mHSpacing;
377
378 for ( long long row = 0; row < rows; row++ )
379 {
380 const double y1 = mGridExtent.yMaximum() - ( row * mVSpacing - row * mVOverlay );
381 const double y2 = y1 - mVSpacing;
382
383 ringX = { x1, x2, x2, x1, x1 };
384 ringY = { y1, y1, y2, y2, y1 };
385 auto poly = std::make_unique<QgsPolygon>();
386 poly->setExteriorRing( new QgsLineString( ringX, ringY ) );
387 f.setGeometry( std::move( poly ) );
388 f.setAttributes( QgsAttributes() << id << x1 << y1 << x2 << y2 << row << col );
389 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
390 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
391 else
392 feedback->featureAddedToSink( u"OUTPUT"_s );
393
394 id++;
395 cnt++;
396
397 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
398 if ( feedback && thisProgress != lastProgress )
399 {
400 lastProgress = thisProgress;
401 feedback->setProgress( lastProgress );
402 }
403
404 if ( feedback && feedback->isCanceled() )
405 break;
406 }
407 }
408}
409
410void QgsGridAlgorithm::createDiamondGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
411{
413
414 const double halfHSpacing = mHSpacing / 2;
415 const double halfVSpacing = mVSpacing / 2;
416
417 const double halfHOverlay = mHOverlay / 2;
418 const double halfVOverlay = mVOverlay / 2;
419
420 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( halfHSpacing - halfHOverlay ) ) );
421 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - halfVOverlay ) ) );
422
423 long long id = 1;
424 long long cnt = 0;
425 const long long cellcnt = rows * cols;
426
427 int thisProgress = 0;
428 int lastProgress = 0;
429 QVector<double> ringX( 5 );
430 QVector<double> ringY( 5 );
431
432 for ( long long col = 0; col < cols; col++ )
433 {
434 if ( feedback && feedback->isCanceled() )
435 break;
436
437 const double x = mGridExtent.xMinimum() - ( col * halfHOverlay );
438 const double x1 = x + ( ( col + 0 ) * halfHSpacing );
439 const double x2 = x + ( ( col + 1 ) * halfHSpacing );
440 const double x3 = x + ( ( col + 2 ) * halfHSpacing );
441
442 for ( long long row = 0; row < rows; row++ )
443 {
444 const double y = mGridExtent.yMaximum() + ( row * halfVOverlay );
445
446 double y1;
447 double y2;
448 double y3;
449
450 if ( ( col % 2 ) == 0 )
451 {
452 y1 = y - ( ( ( row * 2 ) + 0 ) * halfVSpacing );
453 y2 = y - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
454 y3 = y - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
455 }
456 else
457 {
458 y1 = y - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
459 y2 = y - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
460 y3 = y - ( ( ( row * 2 ) + 3 ) * halfVSpacing );
461 }
462
463 ringX = { x1, x2, x3, x2, x1 };
464 ringY = { y2, y1, y2, y3, y2 };
465 auto poly = std::make_unique<QgsPolygon>();
466 poly->setExteriorRing( new QgsLineString( ringX, ringY ) );
467 f.setGeometry( std::move( poly ) );
468 f.setAttributes( QgsAttributes() << id << x1 << y1 << x3 << y3 );
469 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
470 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
471 else
472 feedback->featureAddedToSink( u"OUTPUT"_s );
473
474 id++;
475 cnt++;
476
477 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
478 if ( feedback && thisProgress != lastProgress )
479 {
480 lastProgress = thisProgress;
481 feedback->setProgress( lastProgress );
482 }
483
484 if ( feedback && feedback->isCanceled() )
485 break;
486 }
487 }
488}
489
490void QgsGridAlgorithm::createHexagonGrid( std::unique_ptr<QgsFeatureSink> &sink, QgsProcessingFeedback *feedback )
491{
493
494 // To preserve symmetry, hspacing is fixed relative to vspacing
495 const double xVertexLo = 0.288675134594813 * mVSpacing;
496 const double xVertexHi = 0.577350269189626 * mVSpacing;
497
498 mHSpacing = xVertexLo + xVertexHi;
499
500 mHOverlay = mHSpacing - mHOverlay;
501
502 if ( mHOverlay < 0 )
503 {
505 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." )
506 .arg( mHSpacing )
507 .arg( mHOverlay )
508 );
509 }
510
511 const double halfVSpacing = mVSpacing / 2;
512
513 const long long cols = static_cast<long long>( std::ceil( mGridExtent.width() / ( mHOverlay ) ) );
514 const long long rows = static_cast<long long>( std::ceil( mGridExtent.height() / ( mVSpacing - mVOverlay ) ) );
515
516 long long id = 1;
517 long long cnt = 0;
518 const long long cellcnt = rows * cols;
519
520 int thisProgress = 0;
521 int lastProgress = 0;
522
523 QVector<double> ringX( 7 );
524 QVector<double> ringY( 7 );
525 for ( long long col = 0; col < cols; col++ )
526 {
527 if ( feedback && feedback->isCanceled() )
528 break;
529
530 // (column + 1) and (row + 1) calculation is used to maintain
531 // topology between adjacent shapes and avoid overlaps/holes
532 // due to rounding errors
533
534 const double x1 = mGridExtent.xMinimum() + ( col * mHOverlay );
535 const double x2 = x1 + ( xVertexHi - xVertexLo );
536 const double x3 = mGridExtent.xMinimum() + ( col * mHOverlay ) + mHSpacing;
537 const double x4 = x3 + ( xVertexHi - xVertexLo );
538
539 for ( long long row = 0; row < rows; row++ )
540 {
541 double y1;
542 double y2;
543 double y3;
544
545 if ( ( col % 2 ) == 0 )
546 {
547 y1 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 0 ) * halfVSpacing );
548 y2 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
549 y3 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
550 }
551 else
552 {
553 y1 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 1 ) * halfVSpacing );
554 y2 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 2 ) * halfVSpacing );
555 y3 = mGridExtent.yMaximum() + ( row * mVOverlay ) - ( ( ( row * 2 ) + 3 ) * halfVSpacing );
556 }
557
558 ringX = { x1, x2, x3, x4, x3, x2, x1 };
559 ringY = { y2, y1, y1, y2, y3, y3, y2 };
560 auto poly = std::make_unique<QgsPolygon>();
561 poly->setExteriorRing( new QgsLineString( ringX, ringY ) );
562 f.setGeometry( std::move( poly ) );
563 f.setAttributes( QgsAttributes() << id << x1 << y1 << x4 << y3 << row << col );
564 if ( !sink->addFeature( f, QgsFeatureSink::FastInsert ) )
565 throw QgsProcessingException( writeFeatureError( sink.get(), QVariantMap(), u"OUTPUT"_s ) );
566 else
567 feedback->featureAddedToSink( u"OUTPUT"_s );
568
569 id++;
570 cnt++;
571
572 thisProgress = static_cast<int>( ( static_cast<double>( cnt ) / static_cast<double>( cellcnt ) ) * 100 );
573 if ( feedback && thisProgress != lastProgress )
574 {
575 lastProgress = thisProgress;
576 feedback->setProgress( lastProgress );
577 }
578
579 if ( feedback && feedback->isCanceled() )
580 break;
581 }
582 }
583}
584
@ VectorAnyGeometry
Any vector layer with geometry.
Definition qgis.h:3749
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:45
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.