QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsprocessingalgorithm.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingalgorithm.cpp
3  --------------------------
4  begin : December 2016
5  copyright : (C) 2016 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 
18 #include "qgsprocessingalgorithm.h"
19 #include "qgsapplication.h"
20 #include "qgsprocessingprovider.h"
22 #include "qgsprocessingoutputs.h"
23 #include "qgsrectangle.h"
24 #include "qgsprocessingcontext.h"
25 #include "qgsprocessingutils.h"
26 #include "qgsexception.h"
27 #include "qgsmessagelog.h"
28 #include "qgsvectorlayer.h"
29 #include "qgsprocessingfeedback.h"
30 #include "qgsmeshlayer.h"
32 
33 
35 {
36  qDeleteAll( mParameters );
37  qDeleteAll( mOutputs );
38 }
39 
40 QgsProcessingAlgorithm *QgsProcessingAlgorithm::create( const QVariantMap &configuration ) const
41 {
42  std::unique_ptr< QgsProcessingAlgorithm > creation( createInstance() );
43  if ( ! creation )
44  throw QgsProcessingException( QObject::tr( "Error creating algorithm from createInstance()" ) );
45  creation->setProvider( provider() );
46  creation->initAlgorithm( configuration );
47  return creation.release();
48 }
49 
51 {
52  if ( mProvider )
53  return QStringLiteral( "%1:%2" ).arg( mProvider->id(), name() );
54  else
55  return name();
56 }
57 
59 {
60  return QString();
61 }
62 
64 {
65  return QString();
66 }
67 
69 {
70  return QString();
71 }
72 
74 {
75  return QString();
76 }
77 
79 {
80  return QgsApplication::getThemeIcon( "/processingAlgorithm.svg" );
81 }
82 
84 {
85  return QgsApplication::iconPath( QStringLiteral( "processingAlgorithm.svg" ) );
86 }
87 
88 QgsProcessingAlgorithm::Flags QgsProcessingAlgorithm::flags() const
89 {
91 }
92 
93 bool QgsProcessingAlgorithm::canExecute( QString * ) const
94 {
95  return true;
96 }
97 
98 bool QgsProcessingAlgorithm::checkParameterValues( const QVariantMap &parameters, QgsProcessingContext &context, QString *message ) const
99 {
100  for ( const QgsProcessingParameterDefinition *def : mParameters )
101  {
102  if ( !def->checkValueIsAcceptable( parameters.value( def->name() ), &context ) )
103  {
104  if ( message )
105  {
106  // TODO QGIS 4 - move the message handling to the parameter subclasses (but this
107  // requires a change in signature for the virtual checkValueIsAcceptable method)
108  if ( def->type() == QgsProcessingParameterFeatureSource::typeName() )
109  *message = invalidSourceError( parameters, def->name() );
110  else if ( def->type() == QgsProcessingParameterFeatureSink::typeName() )
111  *message = invalidSinkError( parameters, def->name() );
112  else if ( def->type() == QgsProcessingParameterRasterLayer::typeName() )
113  *message = invalidRasterError( parameters, def->name() );
114  else
115  *message = QObject::tr( "Incorrect parameter value for %1" ).arg( def->name() );
116  }
117  return false;
118  }
119  }
120  return true;
121 }
122 
123 QVariantMap QgsProcessingAlgorithm::preprocessParameters( const QVariantMap &parameters )
124 {
125  return parameters;
126 }
127 
129 {
130  return mProvider;
131 }
132 
134 {
135  mProvider = provider;
136 
137  if ( mProvider && !mProvider->supportsNonFileBasedOutput() )
138  {
139  // need to update all destination parameters to turn off non file based outputs
140  for ( const QgsProcessingParameterDefinition *definition : std::as_const( mParameters ) )
141  {
142  if ( definition->isDestination() )
143  {
144  const QgsProcessingDestinationParameter *destParam = static_cast< const QgsProcessingDestinationParameter *>( definition );
145  const_cast< QgsProcessingDestinationParameter *>( destParam )->setSupportsNonFileBasedOutput( false );
146  }
147  }
148  }
149 }
150 
152 {
153  return nullptr;
154 }
155 
157  QgsProcessingContext &context, QgsProcessingFeatureSource *source ) const
158 {
159  // start with context's expression context
161 
162  // If there's a source capable of generating a context scope, use it
163  if ( source )
164  {
166  if ( scope )
167  c << scope;
168  }
169  else if ( c.scopeCount() == 0 )
170  {
171  //empty scope, populate with initial scopes
174  }
175 
176  c << QgsExpressionContextUtils::processingAlgorithmScope( this, parameters, context );
177  return c;
178 }
179 
180 bool QgsProcessingAlgorithm::validateInputCrs( const QVariantMap &parameters, QgsProcessingContext &context ) const
181 {
182  if ( !( flags() & FlagRequiresMatchingCrs ) )
183  {
184  // I'm a well behaved algorithm - I take work AWAY from users!
185  return true;
186  }
187 
188  bool foundCrs = false;
190  for ( const QgsProcessingParameterDefinition *def : mParameters )
191  {
193  {
194  QgsMapLayer *layer = QgsProcessingParameters::parameterAsLayer( def, parameters, context );
195  if ( layer )
196  {
197  if ( foundCrs && layer->crs().isValid() && crs != layer->crs() )
198  {
199  return false;
200  }
201  else if ( !foundCrs && layer->crs().isValid() )
202  {
203  foundCrs = true;
204  crs = layer->crs();
205  }
206  }
207  }
208  else if ( def->type() == QgsProcessingParameterFeatureSource::typeName() )
209  {
210  std::unique_ptr< QgsFeatureSource > source( QgsProcessingParameters::parameterAsSource( def, parameters, context ) );
211  if ( source )
212  {
213  if ( foundCrs && source->sourceCrs().isValid() && crs != source->sourceCrs() )
214  {
215  return false;
216  }
217  else if ( !foundCrs && source->sourceCrs().isValid() )
218  {
219  foundCrs = true;
220  crs = source->sourceCrs();
221  }
222  }
223  }
224  else if ( def->type() == QgsProcessingParameterMultipleLayers::typeName() )
225  {
226  QList< QgsMapLayer *> layers = QgsProcessingParameters::parameterAsLayerList( def, parameters, context );
227  const auto constLayers = layers;
228  for ( QgsMapLayer *layer : constLayers )
229  {
230  if ( !layer )
231  continue;
232 
233  if ( foundCrs && layer->crs().isValid() && crs != layer->crs() )
234  {
235  return false;
236  }
237  else if ( !foundCrs && layer->crs().isValid() )
238  {
239  foundCrs = true;
240  crs = layer->crs();
241  }
242  }
243  }
244  else if ( def->type() == QgsProcessingParameterExtent::typeName() )
245  {
246  QgsCoordinateReferenceSystem extentCrs = QgsProcessingParameters::parameterAsExtentCrs( def, parameters, context );
247  if ( foundCrs && extentCrs.isValid() && crs != extentCrs )
248  {
249  return false;
250  }
251  else if ( !foundCrs && extentCrs.isValid() )
252  {
253  foundCrs = true;
254  crs = extentCrs;
255  }
256  }
257  else if ( def->type() == QgsProcessingParameterPoint::typeName() )
258  {
259  QgsCoordinateReferenceSystem pointCrs = QgsProcessingParameters::parameterAsPointCrs( def, parameters, context );
260  if ( foundCrs && pointCrs.isValid() && crs != pointCrs )
261  {
262  return false;
263  }
264  else if ( !foundCrs && pointCrs.isValid() )
265  {
266  foundCrs = true;
267  crs = pointCrs;
268  }
269  }
270  else if ( def->type() == QgsProcessingParameterGeometry::typeName() )
271  {
273  if ( foundCrs && geomCrs.isValid() && crs != geomCrs )
274  {
275  return false;
276  }
277  else if ( !foundCrs && geomCrs.isValid() )
278  {
279  foundCrs = true;
280  crs = geomCrs;
281  }
282  }
283 
284  }
285  return true;
286 }
287 
288 QString QgsProcessingAlgorithm::asPythonCommand( const QVariantMap &parameters, QgsProcessingContext &context ) const
289 {
290  QString s = QStringLiteral( "processing.run(\"%1\"," ).arg( id() );
291 
292  QStringList parts;
293  for ( const QgsProcessingParameterDefinition *def : mParameters )
294  {
296  continue;
297 
298  if ( !parameters.contains( def->name() ) )
299  continue;
300 
301  parts << QStringLiteral( "'%1':%2" ).arg( def->name(), def->valueAsPythonString( parameters.value( def->name() ), context ) );
302  }
303 
304  s += QStringLiteral( " {%1})" ).arg( parts.join( ',' ) );
305  return s;
306 }
307 
309 {
310  if ( !definition )
311  return false;
312 
313  // check for duplicate named parameters
315  if ( existingDef && existingDef->name() == definition->name() ) // parameterDefinition is case-insensitive, but we DO allow case-different duplicate names
316  {
317  QgsMessageLog::logMessage( QObject::tr( "Duplicate parameter %1 registered for alg %2" ).arg( definition->name(), id() ), QObject::tr( "Processing" ) );
318  delete definition;
319  return false;
320  }
321 
322  if ( definition->isDestination() && mProvider )
323  {
324  QgsProcessingDestinationParameter *destParam = static_cast< QgsProcessingDestinationParameter *>( definition );
325  if ( !mProvider->supportsNonFileBasedOutput() )
326  destParam->setSupportsNonFileBasedOutput( false );
327  }
328 
329  mParameters << definition;
330  definition->mAlgorithm = this;
331 
332  if ( createOutput )
333  return createAutoOutputForParameter( definition );
334  else
335  return true;
336 }
337 
338 void QgsProcessingAlgorithm::removeParameter( const QString &name )
339 {
341  if ( def )
342  {
343  delete def;
344  mParameters.removeAll( def );
345 
346  // remove output automatically created when adding parameter
348  if ( outputDef && outputDef->autoCreated() )
349  {
350  delete outputDef;
351  mOutputs.removeAll( outputDef );
352  }
353  }
354 }
355 
357 {
358  if ( !definition )
359  return false;
360 
361  // check for duplicate named outputs
362  if ( QgsProcessingAlgorithm::outputDefinition( definition->name() ) )
363  {
364  QgsMessageLog::logMessage( QObject::tr( "Duplicate output %1 registered for alg %2" ).arg( definition->name(), id() ), QObject::tr( "Processing" ) );
365  delete definition;
366  return false;
367  }
368 
369  mOutputs << definition;
370  return true;
371 }
372 
374 {
375  return true;
376 }
377 
379 {
380  return QVariantMap();
381 }
382 
384 {
385  // first pass - case sensitive match
386  for ( const QgsProcessingParameterDefinition *def : mParameters )
387  {
388  if ( def->name() == name )
389  return def;
390  }
391 
392  // second pass - case insensitive
393  for ( const QgsProcessingParameterDefinition *def : mParameters )
394  {
395  if ( def->name().compare( name, Qt::CaseInsensitive ) == 0 )
396  return def;
397  }
398  return nullptr;
399 }
400 
402 {
403  int count = 0;
404  for ( const QgsProcessingParameterDefinition *def : mParameters )
405  {
406  if ( !( def->flags() & QgsProcessingParameterDefinition::FlagHidden ) )
407  count++;
408  }
409  return count;
410 }
411 
413 {
415  for ( const QgsProcessingParameterDefinition *def : mParameters )
416  {
417  if ( def->isDestination() )
418  result << def;
419  }
420  return result;
421 }
422 
424 {
425  for ( const QgsProcessingOutputDefinition *def : mOutputs )
426  {
427  if ( def->name().compare( name, Qt::CaseInsensitive ) == 0 )
428  return def;
429  }
430  return nullptr;
431 }
432 
434 {
435  for ( const QgsProcessingOutputDefinition *def : mOutputs )
436  {
437  if ( def->type() == QLatin1String( "outputHtml" ) )
438  return true;
439  }
440  return false;
441 }
442 
443 QgsProcessingAlgorithm::VectorProperties QgsProcessingAlgorithm::sinkProperties( const QString &, const QVariantMap &, QgsProcessingContext &, const QMap<QString, QgsProcessingAlgorithm::VectorProperties> & ) const
444 {
445  return VectorProperties();
446 }
447 
448 QVariantMap QgsProcessingAlgorithm::run( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback, bool *ok, const QVariantMap &configuration, bool catchExceptions ) const
449 {
450  std::unique_ptr< QgsProcessingAlgorithm > alg( create( configuration ) );
451  if ( ok )
452  *ok = false;
453 
454  bool res = alg->prepare( parameters, context, feedback );
455  if ( !res )
456  return QVariantMap();
457 
458  QVariantMap runRes;
459  try
460  {
461  runRes = alg->runPrepared( parameters, context, feedback );
462  }
463  catch ( QgsProcessingException &e )
464  {
465  if ( !catchExceptions )
466  throw e;
467 
468  QgsMessageLog::logMessage( e.what(), QObject::tr( "Processing" ), Qgis::MessageLevel::Critical );
469  feedback->reportError( e.what() );
470  return QVariantMap();
471  }
472 
473  if ( ok )
474  *ok = true;
475 
476  QVariantMap ppRes = alg->postProcess( context, feedback );
477  if ( !ppRes.isEmpty() )
478  return ppRes;
479  else
480  return runRes;
481 }
482 
483 bool QgsProcessingAlgorithm::prepare( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
484 {
485  Q_ASSERT_X( QThread::currentThread() == context.temporaryLayerStore()->thread(), "QgsProcessingAlgorithm::prepare", "prepare() must be called from the same thread as context was created in" );
486  Q_ASSERT_X( !mHasPrepared, "QgsProcessingAlgorithm::prepare", "prepare() has already been called for the algorithm instance" );
487  try
488  {
489  mHasPrepared = prepareAlgorithm( parameters, context, feedback );
490  return mHasPrepared;
491  }
492  catch ( QgsProcessingException &e )
493  {
494  QgsMessageLog::logMessage( e.what(), QObject::tr( "Processing" ), Qgis::MessageLevel::Critical );
495  feedback->reportError( e.what() );
496  return false;
497  }
498 }
499 
500 QVariantMap QgsProcessingAlgorithm::runPrepared( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
501 {
502  Q_ASSERT_X( mHasPrepared, "QgsProcessingAlgorithm::runPrepared", QStringLiteral( "prepare() was not called for the algorithm instance %1" ).arg( name() ).toLatin1() );
503  Q_ASSERT_X( !mHasExecuted, "QgsProcessingAlgorithm::runPrepared", "runPrepared() was already called for this algorithm instance" );
504 
505  // Hey kids, let's all be thread safe! It's the fun thing to do!
506  //
507  // First, let's see if we're going to run into issues.
508  QgsProcessingContext *runContext = nullptr;
509  if ( context.thread() == QThread::currentThread() )
510  {
511  // OH. No issues. Seems you're running everything in the same thread, so go about your business. Sorry about
512  // the intrusion, we're just making sure everything's nice and safe here. We like to keep a clean and tidy neighbourhood,
513  // you know, for the kids and dogs and all.
514  runContext = &context;
515  }
516  else
517  {
518  // HA! I knew things looked a bit suspicious - seems you're running this algorithm in a different thread
519  // from that which the passed context has an affinity for. That's fine and all, but we need to make sure
520  // we proceed safely...
521 
522  // So first we create a temporary local context with affinity for the current thread
523  mLocalContext.reset( new QgsProcessingContext() );
524  // copy across everything we can safely do from the passed context
525  mLocalContext->copyThreadSafeSettings( context );
526  // and we'll run the actual algorithm processing using the local thread safe context
527  runContext = mLocalContext.get();
528  }
529 
530  try
531  {
532  QVariantMap runResults = processAlgorithm( parameters, *runContext, feedback );
533 
534  mHasExecuted = true;
535  if ( mLocalContext )
536  {
537  // ok, time to clean things up. We need to push the temporary context back into
538  // the thread that the passed context is associated with (we can only push from the
539  // current thread, so we HAVE to do this here)
540  mLocalContext->pushToThread( context.thread() );
541  }
542  return runResults;
543  }
544  catch ( QgsProcessingException & )
545  {
546  if ( mLocalContext )
547  {
548  // see above!
549  mLocalContext->pushToThread( context.thread() );
550  }
551  //rethrow
552  throw;
553  }
554 }
555 
557 {
558  Q_ASSERT_X( QThread::currentThread() == context.temporaryLayerStore()->thread(), "QgsProcessingAlgorithm::postProcess", "postProcess() must be called from the same thread the context was created in" );
559  Q_ASSERT_X( mHasExecuted, "QgsProcessingAlgorithm::postProcess", QStringLiteral( "algorithm instance %1 was not executed" ).arg( name() ).toLatin1() );
560  Q_ASSERT_X( !mHasPostProcessed, "QgsProcessingAlgorithm::postProcess", "postProcess() was already called for this algorithm instance" );
561 
562  if ( mLocalContext )
563  {
564  // algorithm was processed using a temporary thread safe context. So now we need
565  // to take the results from that temporary context, and smash them into the passed
566  // context
567  context.takeResultsFrom( *mLocalContext );
568  // now get lost, we don't need you anymore
569  mLocalContext.reset();
570  }
571 
572  mHasPostProcessed = true;
573  try
574  {
575  return postProcessAlgorithm( context, feedback );
576  }
577  catch ( QgsProcessingException &e )
578  {
579  QgsMessageLog::logMessage( e.what(), QObject::tr( "Processing" ), Qgis::MessageLevel::Critical );
580  feedback->reportError( e.what() );
581  return QVariantMap();
582  }
583 }
584 
585 QString QgsProcessingAlgorithm::parameterAsString( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
586 {
587  return QgsProcessingParameters::parameterAsString( parameterDefinition( name ), parameters, context );
588 }
589 
590 QString QgsProcessingAlgorithm::parameterAsExpression( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
591 {
593 }
594 
595 double QgsProcessingAlgorithm::parameterAsDouble( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
596 {
597  return QgsProcessingParameters::parameterAsDouble( parameterDefinition( name ), parameters, context );
598 }
599 
600 int QgsProcessingAlgorithm::parameterAsInt( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
601 {
602  return QgsProcessingParameters::parameterAsInt( parameterDefinition( name ), parameters, context );
603 }
604 
605 QList<int> QgsProcessingAlgorithm::parameterAsInts( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
606 {
607  return QgsProcessingParameters::parameterAsInts( parameterDefinition( name ), parameters, context );
608 }
609 
610 int QgsProcessingAlgorithm::parameterAsEnum( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
611 {
612  return QgsProcessingParameters::parameterAsEnum( parameterDefinition( name ), parameters, context );
613 }
614 
615 QList<int> QgsProcessingAlgorithm::parameterAsEnums( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
616 {
617  return QgsProcessingParameters::parameterAsEnums( parameterDefinition( name ), parameters, context );
618 }
619 
620 QString QgsProcessingAlgorithm::parameterAsEnumString( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
621 {
623 }
624 
625 QStringList QgsProcessingAlgorithm::parameterAsEnumStrings( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
626 {
628 }
629 
630 bool QgsProcessingAlgorithm::parameterAsBool( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
631 {
632  return QgsProcessingParameters::parameterAsBool( parameterDefinition( name ), parameters, context );
633 }
634 
635 bool QgsProcessingAlgorithm::parameterAsBoolean( const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context ) const
636 {
637  return QgsProcessingParameters::parameterAsBool( parameterDefinition( name ), parameters, context );
638 }
639 
640 QgsFeatureSink *QgsProcessingAlgorithm::parameterAsSink( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsFeatureSink::SinkFlags sinkFlags, const QVariantMap &createOptions, const QStringList &datasourceOptions, const QStringList &layerOptions ) const
641 {
642  if ( !parameterDefinition( name ) )
643  throw QgsProcessingException( QObject::tr( "No parameter definition for the sink '%1'" ).arg( name ) );
644 
645  return QgsProcessingParameters::parameterAsSink( parameterDefinition( name ), parameters, fields, geometryType, crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
646 }
647 
648 QgsProcessingFeatureSource *QgsProcessingAlgorithm::parameterAsSource( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
649 {
650  return QgsProcessingParameters::parameterAsSource( parameterDefinition( name ), parameters, context );
651 }
652 
653 QString QgsProcessingAlgorithm::parameterAsCompatibleSourceLayerPath( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback )
654 {
655  return QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( parameterDefinition( name ), parameters, context, compatibleFormats, preferredFormat, feedback );
656 }
657 
658 QString QgsProcessingAlgorithm::parameterAsCompatibleSourceLayerPathAndLayerName( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName )
659 {
660  return QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( parameterDefinition( name ), parameters, context, compatibleFormats, preferredFormat, feedback, layerName );
661 }
662 
663 QgsMapLayer *QgsProcessingAlgorithm::parameterAsLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
664 {
665  return QgsProcessingParameters::parameterAsLayer( parameterDefinition( name ), parameters, context );
666 }
667 
668 QgsRasterLayer *QgsProcessingAlgorithm::parameterAsRasterLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
669 {
671 }
672 
673 QgsMeshLayer *QgsProcessingAlgorithm::parameterAsMeshLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
674 {
676 }
677 
678 QString QgsProcessingAlgorithm::parameterAsOutputLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
679 {
681 }
682 
683 QString QgsProcessingAlgorithm::parameterAsFileOutput( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
684 {
686 }
687 
688 QgsVectorLayer *QgsProcessingAlgorithm::parameterAsVectorLayer( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
689 {
691 }
692 
693 QgsCoordinateReferenceSystem QgsProcessingAlgorithm::parameterAsCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
694 {
695  return QgsProcessingParameters::parameterAsCrs( parameterDefinition( name ), parameters, context );
696 }
697 
698 QgsCoordinateReferenceSystem QgsProcessingAlgorithm::parameterAsExtentCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
699 {
701 }
702 
703 QgsRectangle QgsProcessingAlgorithm::parameterAsExtent( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs ) const
704 {
705  return QgsProcessingParameters::parameterAsExtent( parameterDefinition( name ), parameters, context, crs );
706 }
707 
708 QgsGeometry QgsProcessingAlgorithm::parameterAsExtentGeometry( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs )
709 {
711 }
712 
713 QgsPointXY QgsProcessingAlgorithm::parameterAsPoint( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs ) const
714 {
715  return QgsProcessingParameters::parameterAsPoint( parameterDefinition( name ), parameters, context, crs );
716 }
717 
718 QgsCoordinateReferenceSystem QgsProcessingAlgorithm::parameterAsPointCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
719 {
721 }
722 
723 QgsGeometry QgsProcessingAlgorithm::parameterAsGeometry( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs ) const
724 {
726 }
727 
728 QgsCoordinateReferenceSystem QgsProcessingAlgorithm::parameterAsGeometryCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
729 {
731 }
732 
733 QString QgsProcessingAlgorithm::parameterAsFile( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
734 {
735  return QgsProcessingParameters::parameterAsFile( parameterDefinition( name ), parameters, context );
736 }
737 
738 QVariantList QgsProcessingAlgorithm::parameterAsMatrix( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
739 {
740  return QgsProcessingParameters::parameterAsMatrix( parameterDefinition( name ), parameters, context );
741 }
742 
743 QList<QgsMapLayer *> QgsProcessingAlgorithm::parameterAsLayerList( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
744 {
746 }
747 
748 QStringList QgsProcessingAlgorithm::parameterAsFileList( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
749 {
751 }
752 
753 QList<double> QgsProcessingAlgorithm::parameterAsRange( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
754 {
755  return QgsProcessingParameters::parameterAsRange( parameterDefinition( name ), parameters, context );
756 }
757 
758 QStringList QgsProcessingAlgorithm::parameterAsFields( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
759 {
760  return QgsProcessingParameters::parameterAsFields( parameterDefinition( name ), parameters, context );
761 }
762 
763 QgsPrintLayout *QgsProcessingAlgorithm::parameterAsLayout( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
764 {
765  return QgsProcessingParameters::parameterAsLayout( parameterDefinition( name ), parameters, context );
766 }
767 
768 QgsLayoutItem *QgsProcessingAlgorithm::parameterAsLayoutItem( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QgsPrintLayout *layout )
769 {
770  return QgsProcessingParameters::parameterAsLayoutItem( parameterDefinition( name ), parameters, context, layout );
771 }
772 
773 QColor QgsProcessingAlgorithm::parameterAsColor( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
774 {
775  return QgsProcessingParameters::parameterAsColor( parameterDefinition( name ), parameters, context );
776 }
777 
778 QString QgsProcessingAlgorithm::parameterAsConnectionName( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
779 {
781 }
782 
783 QDateTime QgsProcessingAlgorithm::parameterAsDateTime( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
784 {
786 }
787 
788 QString QgsProcessingAlgorithm::parameterAsSchema( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
789 {
790  return QgsProcessingParameters::parameterAsSchema( parameterDefinition( name ), parameters, context );
791 }
792 
793 QString QgsProcessingAlgorithm::parameterAsDatabaseTableName( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
794 {
796 }
797 
798 QString QgsProcessingAlgorithm::invalidSourceError( const QVariantMap &parameters, const QString &name )
799 {
800  if ( !parameters.contains( name ) )
801  return QObject::tr( "Could not load source layer for %1: no value specified for parameter" ).arg( name );
802  else
803  {
804  QVariant var = parameters.value( name );
805  if ( var.canConvert<QgsProcessingFeatureSourceDefinition>() )
806  {
807  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( var );
808  var = fromVar.source;
809  }
810  else if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
811  {
812  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
813  var = fromVar.sink;
814  }
815  if ( var.canConvert<QgsProperty>() )
816  {
817  QgsProperty p = var.value< QgsProperty >();
819  {
820  var = p.staticValue();
821  }
822  }
823  if ( !var.toString().isEmpty() )
824  return QObject::tr( "Could not load source layer for %1: %2 not found" ).arg( name, var.toString() );
825  else
826  return QObject::tr( "Could not load source layer for %1: invalid value" ).arg( name );
827  }
828 }
829 
830 QString QgsProcessingAlgorithm::invalidRasterError( const QVariantMap &parameters, const QString &name )
831 {
832  if ( !parameters.contains( name ) )
833  return QObject::tr( "Could not load source layer for %1: no value specified for parameter" ).arg( name );
834  else
835  {
836  QVariant var = parameters.value( name );
837  if ( var.canConvert<QgsProperty>() )
838  {
839  QgsProperty p = var.value< QgsProperty >();
841  {
842  var = p.staticValue();
843  }
844  }
845  if ( !var.toString().isEmpty() )
846  return QObject::tr( "Could not load source layer for %1: %2 not found" ).arg( name, var.toString() );
847  else
848  return QObject::tr( "Could not load source layer for %1: invalid value" ).arg( name );
849  }
850 }
851 
852 QString QgsProcessingAlgorithm::invalidSinkError( const QVariantMap &parameters, const QString &name )
853 {
854  if ( !parameters.contains( name ) )
855  return QObject::tr( "Could not create destination layer for %1: no value specified for parameter" ).arg( name );
856  else
857  {
858  QVariant var = parameters.value( name );
859  if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
860  {
861  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
862  var = fromVar.sink;
863  }
864  if ( var.canConvert<QgsProperty>() )
865  {
866  QgsProperty p = var.value< QgsProperty >();
868  {
869  var = p.staticValue();
870  }
871  }
872  if ( !var.toString().isEmpty() )
873  return QObject::tr( "Could not create destination layer for %1: %2" ).arg( name, var.toString() );
874  else
875  return QObject::tr( "Could not create destination layer for %1: invalid value" ).arg( name );
876  }
877 }
878 
880 {
881  Q_UNUSED( layer )
882  return false;
883 }
884 
885 
886 bool QgsProcessingAlgorithm::createAutoOutputForParameter( QgsProcessingParameterDefinition *parameter )
887 {
888  if ( !parameter->isDestination() )
889  return true; // nothing created, but nothing went wrong - so return true
890 
891  QgsProcessingDestinationParameter *dest = static_cast< QgsProcessingDestinationParameter * >( parameter );
893  if ( !output )
894  return true; // nothing created - but nothing went wrong - so return true
895  output->setAutoCreated( true );
896 
897  if ( !addOutput( output ) )
898  {
899  // couldn't add output - probably a duplicate name
900  return false;
901  }
902  else
903  {
904  return true;
905  }
906 }
907 
908 
909 //
910 // QgsProcessingFeatureBasedAlgorithm
911 //
912 
913 QgsProcessingAlgorithm::Flags QgsProcessingFeatureBasedAlgorithm::flags() const
914 {
915  Flags f = QgsProcessingAlgorithm::flags();
917  return f;
918 }
919 
920 void QgsProcessingFeatureBasedAlgorithm::initAlgorithm( const QVariantMap &config )
921 {
923  initParameters( config );
924  addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), outputName(), outputLayerType(), QVariant(), false, true, true ) );
925 }
926 
928 {
929  return QStringLiteral( "INPUT" );
930 }
931 
933 {
934  return QObject::tr( "Input layer" );
935 }
936 
938 {
939  return QList<int>();
940 }
941 
943 {
945 }
946 
948 {
949  return static_cast<QgsProcessingFeatureSource::Flag>( 0 );
950 }
951 
952 QgsFeatureSink::SinkFlags QgsProcessingFeatureBasedAlgorithm::sinkFlags() const
953 {
954  return QgsFeatureSink::SinkFlags();
955 }
956 
958 {
959  return inputWkbType;
960 }
961 
963 {
964  return inputFields;
965 }
966 
968 {
969  return inputCrs;
970 }
971 
973 {
974 }
975 
977 {
978  if ( mSource )
979  return mSource->sourceCrs();
980  else
982 }
983 
984 QVariantMap QgsProcessingFeatureBasedAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
985 {
986  prepareSource( parameters, context );
987  QString dest;
988  std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest,
989  outputFields( mSource->fields() ),
990  outputWkbType( mSource->wkbType() ),
991  outputCrs( mSource->sourceCrs() ),
992  sinkFlags() ) );
993  if ( !sink )
994  throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );
995 
996  // prepare expression context for feature iteration
997  QgsExpressionContext prevContext = context.expressionContext();
998  QgsExpressionContext algContext = prevContext;
999 
1000  algContext.appendScopes( createExpressionContext( parameters, context, mSource.get() ).takeScopes() );
1001  context.setExpressionContext( algContext );
1002 
1003  long count = mSource->featureCount();
1004 
1005  QgsFeature f;
1006  QgsFeatureIterator it = mSource->getFeatures( request(), sourceFlags() );
1007 
1008  double step = count > 0 ? 100.0 / count : 1;
1009  int current = 0;
1010  while ( it.nextFeature( f ) )
1011  {
1012  if ( feedback->isCanceled() )
1013  {
1014  break;
1015  }
1016 
1017  context.expressionContext().setFeature( f );
1018  const QgsFeatureList transformed = processFeature( f, context, feedback );
1019  for ( QgsFeature transformedFeature : transformed )
1020  sink->addFeature( transformedFeature, QgsFeatureSink::FastInsert );
1021 
1022  feedback->setProgress( current * step );
1023  current++;
1024  }
1025 
1026  mSource.reset();
1027 
1028  // probably not necessary - context's aren't usually recycled, but can't hurt
1029  context.setExpressionContext( prevContext );
1030 
1031  QVariantMap outputs;
1032  outputs.insert( QStringLiteral( "OUTPUT" ), dest );
1033  return outputs;
1034 }
1035 
1037 {
1038  return QgsFeatureRequest();
1039 }
1040 
1042 {
1043  const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
1044  if ( !layer )
1045  return false;
1046 
1047  QgsWkbTypes::GeometryType inPlaceGeometryType = layer->geometryType();
1048  if ( !inputLayerTypes().empty() &&
1049  !inputLayerTypes().contains( QgsProcessing::TypeVector ) &&
1051  ( ( inPlaceGeometryType == QgsWkbTypes::PolygonGeometry && !inputLayerTypes().contains( QgsProcessing::TypeVectorPolygon ) ) ||
1052  ( inPlaceGeometryType == QgsWkbTypes::LineGeometry && !inputLayerTypes().contains( QgsProcessing::TypeVectorLine ) ) ||
1053  ( inPlaceGeometryType == QgsWkbTypes::PointGeometry && !inputLayerTypes().contains( QgsProcessing::TypeVectorPoint ) ) ) )
1054  return false;
1055 
1057  if ( inPlaceGeometryType == QgsWkbTypes::PointGeometry )
1058  type = QgsWkbTypes::Point;
1059  else if ( inPlaceGeometryType == QgsWkbTypes::LineGeometry )
1060  type = QgsWkbTypes::LineString;
1061  else if ( inPlaceGeometryType == QgsWkbTypes::PolygonGeometry )
1062  type = QgsWkbTypes::Polygon;
1063 
1064  if ( QgsWkbTypes::geometryType( outputWkbType( type ) ) != inPlaceGeometryType )
1065  return false;
1066 
1067  return true;
1068 }
1069 
1070 void QgsProcessingFeatureBasedAlgorithm::prepareSource( const QVariantMap &parameters, QgsProcessingContext &context )
1071 {
1072  if ( ! mSource )
1073  {
1074  mSource.reset( parameterAsSource( parameters, inputParameterName(), context ) );
1075  if ( !mSource )
1077  }
1078 }
1079 
1080 
1081 QgsProcessingAlgorithm::VectorProperties QgsProcessingFeatureBasedAlgorithm::sinkProperties( const QString &sink, const QVariantMap &parameters, QgsProcessingContext &context, const QMap<QString, QgsProcessingAlgorithm::VectorProperties> &sourceProperties ) const
1082 {
1084  if ( sink == QLatin1String( "OUTPUT" ) )
1085  {
1086  if ( sourceProperties.value( QStringLiteral( "INPUT" ) ).availability == QgsProcessingAlgorithm::Available )
1087  {
1088  const VectorProperties inputProps = sourceProperties.value( QStringLiteral( "INPUT" ) );
1089  result.fields = outputFields( inputProps.fields );
1090  result.crs = outputCrs( inputProps.crs );
1091  result.wkbType = outputWkbType( inputProps.wkbType );
1092  result.availability = Available;
1093  return result;
1094  }
1095  else
1096  {
1097  std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
1098  if ( source )
1099  {
1100  result.fields = outputFields( source->fields() );
1101  result.crs = outputCrs( source->sourceCrs() );
1102  result.wkbType = outputWkbType( source->wkbType() );
1103  result.availability = Available;
1104  return result;
1105  }
1106  }
1107  }
1108  return result;
1109 }
1110 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString what() const
Definition: qgsexception.h:48
Single scope for storing variables and functions for use within a QgsExpressionContext.
static QgsExpressionContextScope * processingAlgorithmScope(const QgsProcessingAlgorithm *algorithm, const QVariantMap &parameters, QgsProcessingContext &context)
Creates a new scope which contains variables and functions relating to a processing algorithm,...
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QList< QgsExpressionContextScope * > takeScopes()
Returns all scopes from this context and remove them, leaving this context without any context.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
An interface for objects which accept features via addFeature(s) methods.
@ 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:56
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
Definition: qgsfeedback.h:54
void setProgress(double progress)
Sets the current progress for the feedback object.
Definition: qgsfeedback.h:63
Container of fields for a vector layer.
Definition: qgsfields.h:45
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
Base class for graphical items within a QgsLayout.
Base class for all map layer types.
Definition: qgsmaplayer.h:70
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:76
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:95
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
A class to represent a 2D point.
Definition: qgspointxy.h:59
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Abstract base class for processing algorithms.
QString parameterAsCompatibleSourceLayerPath(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching name to a source vector layer file path of compatible format.
QVariantMap runPrepared(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Runs the algorithm, which has been prepared by an earlier call to prepare().
const QgsProcessingOutputDefinition * outputDefinition(const QString &name) const
Returns a matching output by name.
QgsMapLayer * parameterAsLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a map layer.
QgsRasterLayer * parameterAsRasterLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a raster layer.
QString parameterAsDatabaseTableName(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Evaluates the parameter with matching name to a database table name string.
@ Available
Properties are available.
QgsCoordinateReferenceSystem parameterAsExtentCrs(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
int parameterAsInt(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static integer value.
virtual QString helpUrl() const
Returns a url pointing to the algorithm's help page.
int parameterAsEnum(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a enum value.
virtual Flags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
void setProvider(QgsProcessingProvider *provider)
Associates this algorithm with its provider.
virtual QIcon icon() const
Returns an icon for the algorithm.
virtual QString shortHelpString() const
Returns a localised short helper string for the algorithm.
virtual bool validateInputCrs(const QVariantMap &parameters, QgsProcessingContext &context) const
Checks whether the coordinate reference systems for the specified set of parameters are valid for the...
QString parameterAsConnectionName(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Evaluates the parameter with matching name to a connection name string.
QString parameterAsCompatibleSourceLayerPathAndLayerName(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr, QString *layerName=nullptr)
Evaluates the parameter with matching name to a source vector layer file path and layer name of compa...
virtual QString shortDescription() const
Returns an optional translated short description of the algorithm.
QStringList parameterAsFields(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of fields.
QColor parameterAsColor(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Evaluates the parameter with matching name to a color, or returns an invalid color if the parameter w...
QgsProcessingFeatureSource * parameterAsSource(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a feature source.
int countVisibleParameters() const
Returns the number of visible (non-hidden) parameters defined by this algorithm.
QString parameterAsFile(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a file/folder name.
QString id() const
Returns the unique ID for the algorithm, which is a combination of the algorithm provider's ID and th...
virtual QVariantMap preprocessParameters(const QVariantMap &parameters)
Pre-processes a set of parameters, allowing the algorithm to clean their values.
static QString invalidRasterError(const QVariantMap &parameters, const QString &name)
Returns a user-friendly string to use as an error when a raster layer input could not be loaded.
QgsVectorLayer * parameterAsVectorLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a vector layer.
@ FlagSupportsInPlaceEdits
Algorithm supports in-place editing.
@ FlagCanCancel
Algorithm can be canceled.
@ FlagSupportsBatch
Algorithm supports batch mode.
@ FlagRequiresMatchingCrs
Algorithm requires that all input layers have matching coordinate reference systems.
virtual QVariantMap processAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)=0
Runs the algorithm using the specified parameters.
QStringList parameterAsFileList(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of files (for QgsProcessingParameterMultipleLaye...
bool prepare(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Prepares the algorithm for execution.
QString parameterAsExpression(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to an expression.
void removeParameter(const QString &name)
Removes the parameter with matching name from the algorithm, and deletes any existing definition.
QgsCoordinateReferenceSystem parameterAsGeometryCrs(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Returns the coordinate reference system associated with a geometry parameter value.
bool addParameter(QgsProcessingParameterDefinition *parameterDefinition, bool createOutput=true)
Adds a parameter definition to the algorithm.
QgsGeometry parameterAsGeometry(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const
Evaluates the parameter with matching name to a geometry.
QgsFeatureSink * parameterAsSink(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QString &destinationIdentifier, const QgsFields &fields, QgsWkbTypes::Type geometryType=QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList()) const SIP_THROW(QgsProcessingException)
Evaluates the parameter with matching name to a feature sink.
bool parameterAsBoolean(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static boolean value.
QString parameterAsSchema(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Evaluates the parameter with matching name to a database schema name string.
QList< double > parameterAsRange(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a range of values.
QVariantList parameterAsMatrix(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a matrix/table of values.
QgsProcessingAlgorithm * create(const QVariantMap &configuration=QVariantMap()) const SIP_THROW(QgsProcessingException)
Creates a copy of the algorithm, ready for execution.
virtual bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Prepares the algorithm to run using the specified parameters.
virtual QgsExpressionContext createExpressionContext(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeatureSource *source=nullptr) const
Creates an expression context relating to the algorithm.
QgsProcessingParameterDefinitions destinationParameterDefinitions() const
Returns a list of destination parameters definitions utilized by the algorithm.
virtual QgsProcessingAlgorithm * createInstance() const =0
Creates a new instance of the algorithm class.
static QString invalidSinkError(const QVariantMap &parameters, const QString &name)
Returns a user-friendly string to use as an error when a sink parameter could not be created.
bool hasHtmlOutputs() const
Returns true if this algorithm generates HTML outputs.
bool addOutput(QgsProcessingOutputDefinition *outputDefinition)
Adds an output definition to the algorithm.
double parameterAsDouble(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static double value.
QVariantMap postProcess(QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Should be called in the main thread following the completion of runPrepared().
QString parameterAsString(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static string value.
QgsRectangle parameterAsExtent(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const
Evaluates the parameter with matching name to a rectangular extent.
QgsPrintLayout * parameterAsLayout(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Evaluates the parameter with matching name to a print layout.
QgsCoordinateReferenceSystem parameterAsCrs(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a coordinate reference system.
QString parameterAsFileOutput(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a file based output destination.
QgsLayoutItem * parameterAsLayoutItem(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching name to a print layout item, taken from the specified layout.
const QgsProcessingParameterDefinition * parameterDefinition(const QString &name) const
Returns a matching parameter by name.
virtual QString svgIconPath() const
Returns a path to an SVG version of the algorithm's icon.
virtual Q_DECL_DEPRECATED QString helpString() const
Returns a localised help string for the algorithm.
QStringList parameterAsEnumStrings(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to list of static enum strings.
QgsPointXY parameterAsPoint(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) const
Evaluates the parameter with matching name to a point.
virtual QWidget * createCustomParametersWidget(QWidget *parent=nullptr) const
If an algorithm subclass implements a custom parameters widget, a copy of this widget should be const...
QList< QgsMapLayer * > parameterAsLayerList(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of map layers.
virtual QgsProcessingAlgorithm::VectorProperties sinkProperties(const QString &sink, const QVariantMap &parameters, QgsProcessingContext &context, const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties) const
Returns the vector properties which will be used for the sink with matching name.
virtual QVariantMap postProcessAlgorithm(QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Allows the algorithm to perform any required cleanup tasks.
QgsMeshLayer * parameterAsMeshLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a mesh layer.
virtual QString asPythonCommand(const QVariantMap &parameters, QgsProcessingContext &context) const
Returns a Python command string which can be executed to run the algorithm using the specified parame...
QString parameterAsEnumString(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static enum string.
QgsGeometry parameterAsExtentGeometry(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching name to a rectangular extent, and returns a geometry covering t...
virtual bool canExecute(QString *errorMessage=nullptr) const
Returns true if the algorithm can execute.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
QList< int > parameterAsInts(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a list of integer values.
virtual bool supportInPlaceEdit(const QgsMapLayer *layer) const
Checks whether this algorithm supports in-place editing on the given layer Default implementation ret...
bool parameterAsBool(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to a static boolean value.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
QList< int > parameterAsEnums(const QVariantMap &parameters, const QString &name, const QgsProcessingContext &context) const
Evaluates the parameter with matching name to list of enum values.
QgsCoordinateReferenceSystem parameterAsPointCrs(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
QDateTime parameterAsDateTime(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context)
Evaluates the parameter with matching name to a DateTime, or returns an invalid date time if the para...
virtual bool checkParameterValues(const QVariantMap &parameters, QgsProcessingContext &context, QString *message=nullptr) const
Checks the supplied parameter values to verify that they satisfy the requirements of this algorithm i...
QVariantMap run(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback, bool *ok=nullptr, const QVariantMap &configuration=QVariantMap(), bool catchExceptions=true) const SIP_THROW(QgsProcessingException)
Executes the algorithm using the specified parameters.
static QString invalidSourceError(const QVariantMap &parameters, const QString &name)
Returns a user-friendly string to use as an error when a source parameter could not be loaded.
QString parameterAsOutputLayer(const QVariantMap &parameters, const QString &name, QgsProcessingContext &context) const
Evaluates the parameter with matching name to a output layer destination.
Contains information about the context in which a processing algorithm is executed.
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution.
void takeResultsFrom(QgsProcessingContext &context)
Takes the results from another context and merges them with the results currently stored in this cont...
QgsExpressionContext & expressionContext()
Returns the expression context.
QThread * thread()
Returns the thread in which the context lives.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Base class for all parameter definitions which represent file or layer destinations,...
virtual QgsProcessingOutputDefinition * toOutputDefinition() const =0
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
void setSupportsNonFileBasedOutput(bool supportsNonFileBasedOutput)
Sets whether the destination parameter supports non filed-based outputs, such as memory layers or dir...
Custom exception class for processing related exceptions.
Definition: qgsexception.h:83
virtual QgsFeatureRequest request() const
Returns the feature request used for fetching features to process from the source layer.
bool supportInPlaceEdit(const QgsMapLayer *layer) const override
Checks whether this algorithm supports in-place editing on the given layer Default implementation for...
virtual QString inputParameterName() const
Returns the name of the parameter corresponding to the input layer.
QgsProcessingAlgorithm::VectorProperties sinkProperties(const QString &sink, const QVariantMap &parameters, QgsProcessingContext &context, const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties) const override
Returns the vector properties which will be used for the sink with matching name.
virtual void initParameters(const QVariantMap &configuration=QVariantMap())
Initializes any extra parameters added by the algorithm subclass.
QVariantMap processAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) override SIP_THROW(QgsProcessingException)
Runs the algorithm using the specified parameters.
virtual QgsWkbTypes::Type outputWkbType(QgsWkbTypes::Type inputWkbType) const
Maps the input WKB geometry type (inputWkbType) to the corresponding output WKB type generated by the...
virtual QgsCoordinateReferenceSystem outputCrs(const QgsCoordinateReferenceSystem &inputCrs) const
Maps the input source coordinate reference system (inputCrs) to a corresponding output CRS generated ...
void prepareSource(const QVariantMap &parameters, QgsProcessingContext &context)
Read the source from parameters and context and set it.
virtual QgsFields outputFields(const QgsFields &inputFields) const
Maps the input source fields (inputFields) to corresponding output fields generated by the algorithm.
virtual QString outputName() const =0
Returns the translated, user visible name for any layers created by this algorithm.
virtual QString inputParameterDescription() const
Returns the translated description of the parameter corresponding to the input layer.
virtual QgsProcessing::SourceType outputLayerType() const
Returns the layer type for layers generated by this algorithm, if this is possible to determine in ad...
virtual QgsFeatureSink::SinkFlags sinkFlags() const
Returns the feature sink flags to be used for the output.
virtual QgsFeatureList processFeature(const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)=0
Processes an individual input feature from the source.
void initAlgorithm(const QVariantMap &configuration=QVariantMap()) override
Initializes the algorithm using the specified configuration.
QgsProcessingAlgorithm::Flags flags() const override
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
virtual QgsProcessingFeatureSource::Flag sourceFlags() const
Returns the processing feature source flags to be used in the algorithm.
virtual QList< int > inputLayerTypes() const
Returns the valid input layer types for the source layer for this algorithm.
QgsCoordinateReferenceSystem sourceCrs() const
Returns the source's coordinate reference system.
Encapsulates settings relating to a feature source input to a processing algorithm.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
QgsExpressionContextScope * createExpressionContextScope() const
Returns an expression context scope suitable for this source.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
Base class for the definition of processing outputs.
QString name() const
Returns the name of the output.
bool autoCreated() const
Returns true if the output was automatically created when adding a parameter.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
QgsProperty sink
Sink/layer definition.
Base class for the definition of processing parameters.
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
virtual bool isDestination() const
Returns true if this parameter represents a file or layer destination, e.g.
@ FlagHidden
Parameter is hidden and should not be shown to users.
QString name() const
Returns the name of the parameter.
static QString typeName()
Returns the type name for the parameter class.
A feature sink output for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
An input feature source (such as vector layers) parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QgsCoordinateReferenceSystem parameterAsGeometryCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Returns the coordinate reference system associated with a geometry parameter value.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint=QgsProcessingUtils::LayerHint::UnknownType)
Evaluates the parameter with matching definition to a map layer.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList())
Evaluates the parameter with matching definition to a feature sink.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QString parameterAsCompatibleSourceLayerPathAndLayerName(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr, QString *layerName=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path and layer name of...
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QStringList parameterAsFileList(const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultip...
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Abstract base class for processing providers.
virtual QString id() const =0
Returns the unique provider id, used for identifying the provider.
virtual bool supportsNonFileBasedOutput() const
Returns true if the provider supports non-file based outputs (such as memory layers or direct databas...
SourceType
Data source types enum.
Definition: qgsprocessing.h:46
@ TypeVectorLine
Vector line layers.
Definition: qgsprocessing.h:50
@ TypeVectorPolygon
Vector polygon layers.
Definition: qgsprocessing.h:51
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
Definition: qgsprocessing.h:54
@ TypeVectorPoint
Vector point layers.
Definition: qgsprocessing.h:49
@ TypeVectorAnyGeometry
Any vector layer with geometry.
Definition: qgsprocessing.h:48
A store for object properties.
Definition: qgsproperty.h:232
@ StaticProperty
Static property (QgsStaticProperty)
Definition: qgsproperty.h:239
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
QVariant staticValue() const
Returns the current static value for the property.
Type propertyType() const
Returns the property type.
Represents a raster layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Definition: qgswkbtypes.h:938
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:736
QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions
List of processing parameters.
const QgsCoordinateReferenceSystem & crs
Properties of a vector source or sink used in an algorithm.
QgsCoordinateReferenceSystem crs
Coordinate Reference System.
QgsWkbTypes::Type wkbType
Geometry (WKB) type.
QgsProcessingAlgorithm::PropertyAvailability availability
Availability of the properties. By default properties are not available.