QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsprocessingparameters.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingparameters.cpp
3  ---------------------------
4  begin : April 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
19 #include "qgsprocessingprovider.h"
20 #include "qgsprocessingcontext.h"
21 #include "qgsprocessingutils.h"
22 #include "qgsprocessingalgorithm.h"
24 #include "qgsprocessingoutputs.h"
25 #include "qgssettings.h"
26 #include "qgsvectorfilewriter.h"
27 #include "qgsreferencedgeometry.h"
28 #include "qgsprocessingregistry.h"
30 #include "qgsrasterfilewriter.h"
31 #include "qgsvectorlayer.h"
32 #include "qgsmeshlayer.h"
33 #include "qgsapplication.h"
34 #include "qgslayoutmanager.h"
35 #include "qgsprintlayout.h"
36 #include "qgssymbollayerutils.h"
37 #include "qgsfileutils.h"
38 #include "qgsproviderregistry.h"
39 #include <functional>
40 
41 
43 {
44  QVariantMap map;
45  map.insert( QStringLiteral( "source" ), source.toVariant() );
46  map.insert( QStringLiteral( "selected_only" ), selectedFeaturesOnly );
47  map.insert( QStringLiteral( "feature_limit" ), featureLimit );
48  map.insert( QStringLiteral( "flags" ), static_cast< int >( flags ) );
49  map.insert( QStringLiteral( "geometry_check" ), static_cast< int >( geometryCheck ) );
50  return map;
51 }
52 
54 {
55  source.loadVariant( map.value( QStringLiteral( "source" ) ) );
56  selectedFeaturesOnly = map.value( QStringLiteral( "selected_only" ), false ).toBool();
57  featureLimit = map.value( QStringLiteral( "feature_limit" ), -1 ).toLongLong();
58  flags = static_cast< Flags >( map.value( QStringLiteral( "flags" ), 0 ).toInt() );
59  geometryCheck = static_cast< QgsFeatureRequest::InvalidGeometryCheck >( map.value( QStringLiteral( "geometry_check" ), QgsFeatureRequest::GeometryAbortOnInvalid ).toInt() );
60  return true;
61 }
62 
63 
64 //
65 // QgsProcessingOutputLayerDefinition
66 //
67 
69 {
70  mUseRemapping = true;
71  mRemappingDefinition = definition;
72 }
73 
75 {
76  QVariantMap map;
77  map.insert( QStringLiteral( "sink" ), sink.toVariant() );
78  map.insert( QStringLiteral( "create_options" ), createOptions );
79  if ( mUseRemapping )
80  map.insert( QStringLiteral( "remapping" ), QVariant::fromValue( mRemappingDefinition ) );
81  return map;
82 }
83 
85 {
86  sink.loadVariant( map.value( QStringLiteral( "sink" ) ) );
87  createOptions = map.value( QStringLiteral( "create_options" ) ).toMap();
88  if ( map.contains( QStringLiteral( "remapping" ) ) )
89  {
90  mUseRemapping = true;
91  mRemappingDefinition = map.value( QStringLiteral( "remapping" ) ).value< QgsRemappingSinkDefinition >();
92  }
93  else
94  {
95  mUseRemapping = false;
96  }
97  return true;
98 }
99 
101 {
103  && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
104 }
105 
107 {
108  return !( *this == other );
109 }
110 
111 bool QgsProcessingParameters::isDynamic( const QVariantMap &parameters, const QString &name )
112 {
113  QVariant val = parameters.value( name );
114  if ( val.canConvert<QgsProperty>() )
115  return val.value< QgsProperty >().propertyType() != QgsProperty::StaticProperty;
116  else
117  return false;
118 }
119 
120 QString QgsProcessingParameters::parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
121 {
122  if ( !definition )
123  return QString();
124 
125  return parameterAsString( definition, parameters.value( definition->name() ), context );
126 }
127 
128 QString QgsProcessingParameters::parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
129 {
130  if ( !definition )
131  return QString();
132 
133  QVariant val = value;
134  if ( val.canConvert<QgsProperty>() )
135  return val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
136 
137  if ( !val.isValid() )
138  {
139  // fall back to default
140  val = definition->defaultValue();
141  }
142 
143  if ( val == QgsProcessing::TEMPORARY_OUTPUT )
144  {
145  if ( const QgsProcessingDestinationParameter *destParam = dynamic_cast< const QgsProcessingDestinationParameter * >( definition ) )
146  return destParam->generateTemporaryDestination();
147  }
148 
149  return val.toString();
150 }
151 
152 QString QgsProcessingParameters::parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
153 {
154  if ( !definition )
155  return QString();
156 
157  return parameterAsExpression( definition, parameters.value( definition->name() ), context );
158 }
159 
160 QString QgsProcessingParameters::parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
161 {
162  if ( !definition )
163  return QString();
164 
165  QVariant val = value;
166  if ( val.canConvert<QgsProperty>() )
167  return val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
168 
169  if ( val.isValid() && !val.toString().isEmpty() )
170  {
171  QgsExpression e( val.toString() );
172  if ( e.isValid() )
173  return val.toString();
174  }
175 
176  // fall back to default
177  return definition->defaultValue().toString();
178 }
179 
180 double QgsProcessingParameters::parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
181 {
182  if ( !definition )
183  return 0;
184 
185  return parameterAsDouble( definition, parameters.value( definition->name() ), context );
186 }
187 
188 double QgsProcessingParameters::parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
189 {
190  if ( !definition )
191  return 0;
192 
193  QVariant val = value;
194  if ( val.canConvert<QgsProperty>() )
195  return val.value< QgsProperty >().valueAsDouble( context.expressionContext(), definition->defaultValue().toDouble() );
196 
197  bool ok = false;
198  double res = val.toDouble( &ok );
199  if ( ok )
200  return res;
201 
202  // fall back to default
203  val = definition->defaultValue();
204  return val.toDouble();
205 }
206 
207 int QgsProcessingParameters::parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
208 {
209  if ( !definition )
210  return 0;
211 
212  return parameterAsInt( definition, parameters.value( definition->name() ), context );
213 }
214 
215 int QgsProcessingParameters::parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
216 {
217  if ( !definition )
218  return 0;
219 
220  QVariant val = value;
221  if ( val.canConvert<QgsProperty>() )
222  return val.value< QgsProperty >().valueAsInt( context.expressionContext(), definition->defaultValue().toInt() );
223 
224  bool ok = false;
225  double dbl = val.toDouble( &ok );
226  if ( !ok )
227  {
228  // fall back to default
229  val = definition->defaultValue();
230  dbl = val.toDouble( &ok );
231  }
232 
233  //String representations of doubles in QVariant will not convert to int
234  //work around this by first converting to double, and then checking whether the double is convertible to int
235  if ( ok )
236  {
237  double round = std::round( dbl );
238  if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
239  {
240  //double too large to fit in int
241  return 0;
242  }
243  return static_cast< int >( std::round( dbl ) );
244  }
245 
246  return val.toInt();
247 }
248 
249 QList< int > QgsProcessingParameters::parameterAsInts( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
250 {
251  if ( !definition )
252  return QList< int >();
253 
254  return parameterAsInts( definition, parameters.value( definition->name() ), context );
255 }
256 
257 QList< int > QgsProcessingParameters::parameterAsInts( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
258 {
259  if ( !definition )
260  return QList< int >();
261 
262  QList< int > resultList;
263  QVariant val = value;
264  if ( val.isValid() )
265  {
266  if ( val.canConvert<QgsProperty>() )
267  resultList << val.value< QgsProperty >().valueAsInt( context.expressionContext(), definition->defaultValue().toInt() );
268  else if ( val.type() == QVariant::List )
269  {
270  QVariantList list = val.toList();
271  for ( auto it = list.constBegin(); it != list.constEnd(); ++it )
272  resultList << it->toInt();
273  }
274  else
275  {
276  QStringList parts = val.toString().split( ';' );
277  for ( auto it = parts.constBegin(); it != parts.constEnd(); ++it )
278  resultList << it->toInt();
279  }
280  }
281 
282  if ( ( resultList.isEmpty() || resultList.at( 0 ) == 0 ) )
283  {
284  resultList.clear();
285  // check default
286  if ( definition->defaultValue().isValid() )
287  {
288  if ( definition->defaultValue().type() == QVariant::List )
289  {
290  QVariantList list = definition->defaultValue().toList();
291  for ( auto it = list.constBegin(); it != list.constEnd(); ++it )
292  resultList << it->toInt();
293  }
294  else
295  {
296  QStringList parts = definition->defaultValue().toString().split( ';' );
297  for ( auto it = parts.constBegin(); it != parts.constEnd(); ++it )
298  resultList << it->toInt();
299  }
300  }
301  }
302 
303  return resultList;
304 }
305 
306 QDateTime QgsProcessingParameters::parameterAsDateTime( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
307 {
308  if ( !definition )
309  return QDateTime();
310 
311  return parameterAsDateTime( definition, parameters.value( definition->name() ), context );
312 }
313 
314 QDateTime QgsProcessingParameters::parameterAsDateTime( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
315 {
316  if ( !definition )
317  return QDateTime();
318 
319  QVariant val = value;
320  if ( val.canConvert<QgsProperty>() )
321  val = val.value< QgsProperty >().value( context.expressionContext(), definition->defaultValue() );
322 
323  QDateTime d = val.toDateTime();
324  if ( !d.isValid() && val.type() == QVariant::String )
325  {
326  d = QDateTime::fromString( val.toString() );
327  }
328 
329  if ( !d.isValid() )
330  {
331  // fall back to default
332  val = definition->defaultValue();
333  d = val.toDateTime();
334  }
335  if ( !d.isValid() && val.type() == QVariant::String )
336  {
337  d = QDateTime::fromString( val.toString() );
338  }
339 
340  return d;
341 }
342 
343 QDate QgsProcessingParameters::parameterAsDate( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
344 {
345  if ( !definition )
346  return QDate();
347 
348  return parameterAsDate( definition, parameters.value( definition->name() ), context );
349 }
350 
351 QDate QgsProcessingParameters::parameterAsDate( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
352 {
353  if ( !definition )
354  return QDate();
355 
356  QVariant val = value;
357  if ( val.canConvert<QgsProperty>() )
358  val = val.value< QgsProperty >().value( context.expressionContext(), definition->defaultValue() );
359 
360  QDate d = val.toDate();
361  if ( !d.isValid() && val.type() == QVariant::String )
362  {
363  d = QDate::fromString( val.toString() );
364  }
365 
366  if ( !d.isValid() )
367  {
368  // fall back to default
369  val = definition->defaultValue();
370  d = val.toDate();
371  }
372  if ( !d.isValid() && val.type() == QVariant::String )
373  {
374  d = QDate::fromString( val.toString() );
375  }
376 
377  return d;
378 }
379 
380 QTime QgsProcessingParameters::parameterAsTime( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
381 {
382  if ( !definition )
383  return QTime();
384 
385  return parameterAsTime( definition, parameters.value( definition->name() ), context );
386 }
387 
388 QTime QgsProcessingParameters::parameterAsTime( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
389 {
390  if ( !definition )
391  return QTime();
392 
393  QVariant val = value;
394  if ( val.canConvert<QgsProperty>() )
395  val = val.value< QgsProperty >().value( context.expressionContext(), definition->defaultValue() );
396 
397  QTime d;
398 
399  if ( val.type() == QVariant::DateTime )
400  d = val.toDateTime().time();
401  else
402  d = val.toTime();
403 
404  if ( !d.isValid() && val.type() == QVariant::String )
405  {
406  d = QTime::fromString( val.toString() );
407  }
408 
409  if ( !d.isValid() )
410  {
411  // fall back to default
412  val = definition->defaultValue();
413  d = val.toTime();
414  }
415  if ( !d.isValid() && val.type() == QVariant::String )
416  {
417  d = QTime::fromString( val.toString() );
418  }
419 
420  return d;
421 }
422 
423 int QgsProcessingParameters::parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
424 {
425  if ( !definition )
426  return 0;
427 
428  return parameterAsEnum( definition, parameters.value( definition->name() ), context );
429 }
430 
431 int QgsProcessingParameters::parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
432 {
433  if ( !definition )
434  return 0;
435 
436  int val = parameterAsInt( definition, value, context );
437  const QgsProcessingParameterEnum *enumDef = dynamic_cast< const QgsProcessingParameterEnum *>( definition );
438  if ( enumDef && val >= enumDef->options().size() )
439  {
440  return enumDef->defaultValue().toInt();
441  }
442  return val;
443 }
444 
445 QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
446 {
447  if ( !definition )
448  return QList<int>();
449 
450  return parameterAsEnums( definition, parameters.value( definition->name() ), context );
451 }
452 
453 QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
454 {
455  if ( !definition )
456  return QList<int>();
457 
458  QVariantList resultList;
459  QVariant val = value;
460  if ( val.canConvert<QgsProperty>() )
461  resultList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
462  else if ( val.type() == QVariant::List )
463  {
464  const auto constToList = val.toList();
465  for ( const QVariant &var : constToList )
466  resultList << var;
467  }
468  else if ( val.type() == QVariant::String )
469  {
470  const auto constSplit = val.toString().split( ',' );
471  for ( const QString &var : constSplit )
472  resultList << var;
473  }
474  else
475  resultList << val;
476 
477  if ( resultList.isEmpty() )
478  return QList< int >();
479 
480  if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
481  {
482  resultList.clear();
483  // check default
484  if ( definition->defaultValue().type() == QVariant::List )
485  {
486  const auto constToList = definition->defaultValue().toList();
487  for ( const QVariant &var : constToList )
488  resultList << var;
489  }
490  else if ( definition->defaultValue().type() == QVariant::String )
491  {
492  const auto constSplit = definition->defaultValue().toString().split( ',' );
493  for ( const QString &var : constSplit )
494  resultList << var;
495  }
496  else
497  resultList << definition->defaultValue();
498  }
499 
500  QList< int > result;
501  const QgsProcessingParameterEnum *enumDef = dynamic_cast< const QgsProcessingParameterEnum *>( definition );
502  const auto constResultList = resultList;
503  for ( const QVariant &var : constResultList )
504  {
505  int resInt = var.toInt();
506  if ( !enumDef || resInt < enumDef->options().size() )
507  {
508  result << resInt;
509  }
510  }
511  return result;
512 }
513 
514 bool QgsProcessingParameters::parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
515 {
516  if ( !definition )
517  return false;
518 
519  return parameterAsBool( definition, parameters.value( definition->name() ), context );
520 }
521 
522 bool QgsProcessingParameters::parameterAsBoolean( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
523 {
524  if ( !definition )
525  return false;
526 
527  return parameterAsBoolean( definition, parameters.value( definition->name() ), context );
528 }
529 
530 bool QgsProcessingParameters::parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
531 {
532  if ( !definition )
533  return false;
534 
535  QVariant def = definition->defaultValue();
536 
537  QVariant val = value;
538  if ( val.canConvert<QgsProperty>() )
539  return val.value< QgsProperty >().valueAsBool( context.expressionContext(), def.toBool() );
540  else if ( val.isValid() )
541  return val.toBool();
542  else
543  return def.toBool();
544 }
545 
546 bool QgsProcessingParameters::parameterAsBoolean( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
547 {
548  if ( !definition )
549  return false;
550 
551  QVariant def = definition->defaultValue();
552 
553  QVariant val = value;
554  if ( val.canConvert<QgsProperty>() )
555  return val.value< QgsProperty >().valueAsBool( context.expressionContext(), def.toBool() );
556  else if ( val.isValid() )
557  return val.toBool();
558  else
559  return def.toBool();
560 }
561 
562 QgsFeatureSink *QgsProcessingParameters::parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsFields &fields,
564  QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
565  const QVariantMap &createOptions, const QStringList &datasourceOptions, const QStringList &layerOptions )
566 {
567  QVariant val;
568  if ( definition )
569  {
570  val = parameters.value( definition->name() );
571  }
572 
573  return parameterAsSink( definition, val, fields, geometryType, crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
574 }
575 
576 QgsFeatureSink *QgsProcessingParameters::parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags, const QVariantMap &createOptions, const QStringList &datasourceOptions, const QStringList &layerOptions )
577 {
578  QVariantMap options = createOptions;
579  QVariant val = value;
580 
581  QgsProject *destinationProject = nullptr;
582  QString destName;
583  QgsRemappingSinkDefinition remapDefinition;
584  bool useRemapDefinition = false;
585  if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
586  {
587  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
588  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
589  destinationProject = fromVar.destinationProject;
590  options = fromVar.createOptions;
591 
592  val = fromVar.sink;
593  destName = fromVar.destinationName;
594  if ( fromVar.useRemapping() )
595  {
596  useRemapDefinition = true;
597  remapDefinition = fromVar.remappingDefinition();
598  }
599  }
600 
601  QString dest;
602  if ( definition && val.canConvert<QgsProperty>() )
603  {
604  dest = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
605  }
606  else if ( !val.isValid() || val.toString().isEmpty() )
607  {
608  if ( definition && definition->flags() & QgsProcessingParameterDefinition::FlagOptional && !definition->defaultValue().isValid() )
609  {
610  // unset, optional sink, no default => no sink
611  return nullptr;
612  }
613  // fall back to default
614  if ( !definition )
615  {
616  throw QgsProcessingException( QObject::tr( "No parameter definition for the sink" ) );
617  }
618  dest = definition->defaultValue().toString();
619  }
620  else
621  {
622  dest = val.toString();
623  }
624  if ( dest == QgsProcessing::TEMPORARY_OUTPUT )
625  {
626  if ( const QgsProcessingDestinationParameter *destParam = dynamic_cast< const QgsProcessingDestinationParameter * >( definition ) )
627  dest = destParam->generateTemporaryDestination();
628  }
629 
630  if ( dest.isEmpty() )
631  return nullptr;
632 
633  std::unique_ptr< QgsFeatureSink > sink( QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType, crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition : nullptr ) );
634  destinationIdentifier = dest;
635 
636  if ( destinationProject )
637  {
638  if ( destName.isEmpty() && definition )
639  {
640  destName = definition->description();
641  }
642  QString outputName;
643  if ( definition )
644  outputName = definition->name();
645  context.addLayerToLoadOnCompletion( destinationIdentifier, QgsProcessingContext::LayerDetails( destName, destinationProject, outputName, QgsProcessingUtils::LayerHint::Vector ) );
646  }
647 
648  return sink.release();
649 }
650 
652 {
653  if ( !definition )
654  return nullptr;
655 
656  return parameterAsSource( definition, parameters.value( definition->name() ), context );
657 }
658 
660 {
661  if ( !definition )
662  return nullptr;
663 
664  return QgsProcessingUtils::variantToSource( value, context, definition->defaultValue() );
665 }
666 
667 QString parameterAsCompatibleSourceLayerPathInternal( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName )
668 {
669  if ( !definition )
670  return QString();
671 
672  QVariant val = parameters.value( definition->name() );
673 
674  bool selectedFeaturesOnly = false;
675  long long featureLimit = -1;
676  if ( val.canConvert<QgsProcessingFeatureSourceDefinition>() )
677  {
678  // input is a QgsProcessingFeatureSourceDefinition - get extra properties from it
679  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( val );
680  selectedFeaturesOnly = fromVar.selectedFeaturesOnly;
681  featureLimit = fromVar.featureLimit;
682  val = fromVar.source;
683  }
684  else if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
685  {
686  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
687  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
688  val = fromVar.sink;
689  }
690 
691  if ( val.canConvert<QgsProperty>() )
692  {
693  val = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
694  }
695 
696  QgsVectorLayer *vl = nullptr;
697  vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
698 
699  if ( !vl )
700  {
701  QString layerRef;
702  if ( val.canConvert<QgsProperty>() )
703  {
704  layerRef = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
705  }
706  else if ( !val.isValid() || val.toString().isEmpty() )
707  {
708  // fall back to default
709  val = definition->defaultValue();
710 
711  // default value may be a vector layer
712  vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
713  if ( !vl )
714  layerRef = definition->defaultValue().toString();
715  }
716  else
717  {
718  layerRef = val.toString();
719  }
720 
721  if ( !vl )
722  {
723  if ( layerRef.isEmpty() )
724  return QString();
725 
726  vl = qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::mapLayerFromString( layerRef, context, true, QgsProcessingUtils::LayerHint::Vector ) );
727  }
728  }
729 
730  if ( !vl )
731  return QString();
732 
733  if ( layerName )
734  return QgsProcessingUtils::convertToCompatibleFormatAndLayerName( vl, selectedFeaturesOnly, definition->name(),
735  compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit );
736  else
737  return QgsProcessingUtils::convertToCompatibleFormat( vl, selectedFeaturesOnly, definition->name(),
738  compatibleFormats, preferredFormat, context, feedback, featureLimit );
739 }
740 
741 QString QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback )
742 {
743  return parameterAsCompatibleSourceLayerPathInternal( definition, parameters, context, compatibleFormats, preferredFormat, feedback, nullptr );
744 }
745 
746 QString QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName )
747 {
748  QString *destLayer = layerName;
749  QString tmp;
750  if ( destLayer )
751  destLayer->clear();
752  else
753  destLayer = &tmp;
754 
755  return parameterAsCompatibleSourceLayerPathInternal( definition, parameters, context, compatibleFormats, preferredFormat, feedback, destLayer );
756 }
757 
758 
760 {
761  if ( !definition )
762  return nullptr;
763 
764  return parameterAsLayer( definition, parameters.value( definition->name() ), context, layerHint );
765 }
766 
768 {
769  if ( !definition )
770  return nullptr;
771 
772  QVariant val = value;
773  if ( val.canConvert<QgsProperty>() )
774  {
775  val = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
776  }
777 
778  if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
779  {
780  return layer;
781  }
782 
783  if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
784  {
785  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
786  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
787  val = fromVar.sink;
788  }
789 
790  if ( val.canConvert<QgsProperty>() && val.value< QgsProperty >().propertyType() == QgsProperty::StaticProperty )
791  {
792  val = val.value< QgsProperty >().staticValue();
793  }
794 
795  if ( !val.isValid() || val.toString().isEmpty() )
796  {
797  // fall back to default
798  val = definition->defaultValue();
799  }
800 
801  if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
802  {
803  return layer;
804  }
805 
806  QString layerRef = val.toString();
807  if ( layerRef.isEmpty() )
808  layerRef = definition->defaultValue().toString();
809 
810  if ( layerRef.isEmpty() )
811  return nullptr;
812 
813  return QgsProcessingUtils::mapLayerFromString( layerRef, context, true, layerHint );
814 }
815 
817 {
818  return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, parameters, context, QgsProcessingUtils::LayerHint::Raster ) );
819 }
820 
822 {
823  return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, value, context, QgsProcessingUtils::LayerHint::Raster ) );
824 }
825 
827 {
828  return qobject_cast< QgsMeshLayer *>( parameterAsLayer( definition, parameters, context, QgsProcessingUtils::LayerHint::Mesh ) );
829 }
830 
832 {
833  return qobject_cast< QgsMeshLayer *>( parameterAsLayer( definition, value, context, QgsProcessingUtils::LayerHint::Mesh ) );
834 }
835 
836 QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
837 {
838  QVariant val;
839  if ( definition )
840  {
841  val = parameters.value( definition->name() );
842  }
843  return parameterAsOutputLayer( definition, val, context );
844 }
845 
847 {
848  QVariant val = value;
849 
850  QgsProject *destinationProject = nullptr;
851  QString destName;
852  if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
853  {
854  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
855  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
856  destinationProject = fromVar.destinationProject;
857  val = fromVar.sink;
858  destName = fromVar.destinationName;
859  }
860 
861  QString dest;
862  if ( definition && val.canConvert<QgsProperty>() )
863  {
864  dest = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
865  }
866  else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
867  {
868  // fall back to default
869  dest = definition->defaultValue().toString();
870  }
871  else
872  {
873  dest = val.toString();
874  }
875  if ( dest == QgsProcessing::TEMPORARY_OUTPUT )
876  {
877  if ( const QgsProcessingDestinationParameter *destParam = dynamic_cast< const QgsProcessingDestinationParameter * >( definition ) )
878  dest = destParam->generateTemporaryDestination();
879  }
880 
881  if ( destinationProject )
882  {
883  QString outputName;
884  if ( destName.isEmpty() && definition )
885  {
886  destName = definition->description();
887  }
888  if ( definition )
889  outputName = definition->name();
890 
892  if ( definition && definition->type() == QgsProcessingParameterVectorDestination::typeName() )
894  else if ( definition && definition->type() == QgsProcessingParameterRasterDestination::typeName() )
896 
897  context.addLayerToLoadOnCompletion( dest, QgsProcessingContext::LayerDetails( destName, destinationProject, outputName, layerTypeHint ) );
898  }
899 
900  return dest;
901 }
902 
903 QString QgsProcessingParameters::parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
904 {
905  QVariant val;
906  if ( definition )
907  {
908  val = parameters.value( definition->name() );
909  }
910  return parameterAsFileOutput( definition, val, context );
911 }
912 
914 {
915  QVariant val = value;
916 
917  if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
918  {
919  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
920  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
921  val = fromVar.sink;
922  }
923 
924  QString dest;
925  if ( definition && val.canConvert<QgsProperty>() )
926  {
927  dest = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
928  }
929  else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
930  {
931  // fall back to default
932  dest = definition->defaultValue().toString();
933  }
934  else
935  {
936  dest = val.toString();
937  }
938  if ( dest == QgsProcessing::TEMPORARY_OUTPUT )
939  {
940  if ( const QgsProcessingDestinationParameter *destParam = dynamic_cast< const QgsProcessingDestinationParameter * >( definition ) )
941  dest = destParam->generateTemporaryDestination();
942  }
943  return dest;
944 }
945 
947 {
948  return qobject_cast< QgsVectorLayer *>( parameterAsLayer( definition, parameters, context, QgsProcessingUtils::LayerHint::Vector ) );
949 }
950 
952 {
953  return qobject_cast< QgsVectorLayer *>( parameterAsLayer( definition, value, context, QgsProcessingUtils::LayerHint::Vector ) );
954 }
955 
957 {
958  if ( !definition )
960 
961  return parameterAsCrs( definition, parameters.value( definition->name() ), context );
962 }
963 
965 {
966  if ( !definition )
968 
969  return QgsProcessingUtils::variantToCrs( value, context, definition->defaultValue() );
970 }
971 
974 {
975  if ( !definition )
976  return QgsRectangle();
977 
978  return parameterAsExtent( definition, parameters.value( definition->name() ), context, crs );
979 }
980 
982 {
983  if ( !definition )
984  return QgsRectangle();
985 
986  QVariant val = value;
987 
988  if ( val.canConvert< QgsRectangle >() )
989  {
990  return val.value<QgsRectangle>();
991  }
992  if ( val.canConvert< QgsGeometry >() )
993  {
994  const QgsGeometry geom = val.value<QgsGeometry>();
995  if ( !geom.isNull() )
996  return geom.boundingBox();
997  }
998  if ( val.canConvert< QgsReferencedRectangle >() )
999  {
1001  if ( crs.isValid() && rr.crs().isValid() && crs != rr.crs() )
1002  {
1003  QgsCoordinateTransform ct( rr.crs(), crs, context.project() );
1004  try
1005  {
1006  return ct.transformBoundingBox( rr );
1007  }
1008  catch ( QgsCsException & )
1009  {
1010  QgsMessageLog::logMessage( QObject::tr( "Error transforming extent geometry" ) );
1011  }
1012  }
1013  return rr;
1014  }
1015 
1016  if ( val.canConvert<QgsProcessingFeatureSourceDefinition>() )
1017  {
1018  // input is a QgsProcessingFeatureSourceDefinition - get extra properties from it
1019  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( val );
1020  val = fromVar.source;
1021  }
1022  else if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
1023  {
1024  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
1025  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
1026  val = fromVar.sink;
1027  }
1028 
1029  if ( val.canConvert<QgsProperty>() && val.value< QgsProperty >().propertyType() == QgsProperty::StaticProperty )
1030  {
1031  val = val.value< QgsProperty >().staticValue();
1032  }
1033 
1034  // maybe parameter is a direct layer value?
1035  QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1036 
1037  QString rectText;
1038  if ( val.canConvert<QgsProperty>() )
1039  rectText = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
1040  else
1041  rectText = val.toString();
1042 
1043  if ( rectText.isEmpty() && !layer )
1044  return QgsRectangle();
1045 
1046  QRegularExpression rx( QStringLiteral( "^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1047  QRegularExpressionMatch match = rx.match( rectText );
1048  if ( match.hasMatch() )
1049  {
1050  bool xMinOk = false;
1051  double xMin = match.captured( 1 ).toDouble( &xMinOk );
1052  bool xMaxOk = false;
1053  double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1054  bool yMinOk = false;
1055  double yMin = match.captured( 3 ).toDouble( &yMinOk );
1056  bool yMaxOk = false;
1057  double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1058  if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1059  {
1060  QgsRectangle rect( xMin, yMin, xMax, yMax );
1061  QgsCoordinateReferenceSystem rectCrs( match.captured( 5 ) );
1062  if ( crs.isValid() && rectCrs.isValid() && crs != rectCrs )
1063  {
1064  QgsCoordinateTransform ct( rectCrs, crs, context.project() );
1065  try
1066  {
1067  return ct.transformBoundingBox( rect );
1068  }
1069  catch ( QgsCsException & )
1070  {
1071  QgsMessageLog::logMessage( QObject::tr( "Error transforming extent geometry" ) );
1072  }
1073  }
1074  return rect;
1075  }
1076  }
1077 
1078  // try as layer extent
1079  if ( !layer )
1080  layer = QgsProcessingUtils::mapLayerFromString( rectText, context );
1081 
1082  if ( layer )
1083  {
1084  QgsRectangle rect = layer->extent();
1085  if ( crs.isValid() && layer->crs().isValid() && crs != layer->crs() )
1086  {
1087  QgsCoordinateTransform ct( layer->crs(), crs, context.project() );
1088  try
1089  {
1090  return ct.transformBoundingBox( rect );
1091  }
1092  catch ( QgsCsException & )
1093  {
1094  QgsMessageLog::logMessage( QObject::tr( "Error transforming extent geometry" ) );
1095  }
1096  }
1097  return rect;
1098  }
1099  return QgsRectangle();
1100 }
1101 
1103 {
1104  if ( !definition )
1105  return QgsGeometry();
1106 
1107  QVariant val = parameters.value( definition->name() );
1108 
1109  if ( val.canConvert< QgsReferencedRectangle >() )
1110  {
1113  if ( crs.isValid() && rr.crs().isValid() && crs != rr.crs() )
1114  {
1115  g = g.densifyByCount( 20 );
1116  QgsCoordinateTransform ct( rr.crs(), crs, context.project() );
1117  try
1118  {
1119  g.transform( ct );
1120  }
1121  catch ( QgsCsException & )
1122  {
1123  QgsMessageLog::logMessage( QObject::tr( "Error transforming extent geometry" ) );
1124  }
1125  return g;
1126  }
1127  }
1128 
1129  if ( val.canConvert<QgsProcessingFeatureSourceDefinition>() )
1130  {
1131  // input is a QgsProcessingFeatureSourceDefinition - get extra properties from it
1132  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( val );
1133  val = fromVar.source;
1134  }
1135  else if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
1136  {
1137  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
1138  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
1139  val = fromVar.sink;
1140  }
1141 
1142  if ( val.canConvert<QgsProperty>() && val.value< QgsProperty >().propertyType() == QgsProperty::StaticProperty )
1143  {
1144  val = val.value< QgsProperty >().staticValue();
1145  }
1146 
1147  QString rectText;
1148  if ( val.canConvert<QgsProperty>() )
1149  rectText = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
1150  else
1151  rectText = val.toString();
1152 
1153  if ( !rectText.isEmpty() )
1154  {
1155  QRegularExpression rx( QStringLiteral( "^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1156  QRegularExpressionMatch match = rx.match( rectText );
1157  if ( match.hasMatch() )
1158  {
1159  bool xMinOk = false;
1160  double xMin = match.captured( 1 ).toDouble( &xMinOk );
1161  bool xMaxOk = false;
1162  double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1163  bool yMinOk = false;
1164  double yMin = match.captured( 3 ).toDouble( &yMinOk );
1165  bool yMaxOk = false;
1166  double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1167  if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1168  {
1169  QgsRectangle rect( xMin, yMin, xMax, yMax );
1170  QgsCoordinateReferenceSystem rectCrs( match.captured( 5 ) );
1171  QgsGeometry g = QgsGeometry::fromRect( rect );
1172  if ( crs.isValid() && rectCrs.isValid() && crs != rectCrs )
1173  {
1174  g = g.densifyByCount( 20 );
1175  QgsCoordinateTransform ct( rectCrs, crs, context.project() );
1176  try
1177  {
1178  g.transform( ct );
1179  }
1180  catch ( QgsCsException & )
1181  {
1182  QgsMessageLog::logMessage( QObject::tr( "Error transforming extent geometry" ) );
1183  }
1184  return g;
1185  }
1186  }
1187  }
1188  }
1189 
1190  // try as layer extent
1191 
1192  // maybe parameter is a direct layer value?
1193  QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1194  if ( !layer )
1195  layer = QgsProcessingUtils::mapLayerFromString( rectText, context );
1196 
1197  if ( layer )
1198  {
1199  QgsRectangle rect = layer->extent();
1200  QgsGeometry g = QgsGeometry::fromRect( rect );
1201  if ( crs.isValid() && layer->crs().isValid() && crs != layer->crs() )
1202  {
1203  g = g.densifyByCount( 20 );
1204  QgsCoordinateTransform ct( layer->crs(), crs, context.project() );
1205  try
1206  {
1207  g.transform( ct );
1208  }
1209  catch ( QgsCsException & )
1210  {
1211  QgsMessageLog::logMessage( QObject::tr( "Error transforming extent geometry" ) );
1212  }
1213  }
1214  return g;
1215  }
1216 
1217  return QgsGeometry::fromRect( parameterAsExtent( definition, parameters, context, crs ) );
1218 }
1219 
1221 {
1222  QVariant val = parameters.value( definition->name() );
1223  return parameterAsExtentCrs( definition, val, context );
1224 }
1225 
1227 {
1228  QVariant val = value;
1229  if ( val.canConvert< QgsReferencedRectangle >() )
1230  {
1232  if ( rr.crs().isValid() )
1233  {
1234  return rr.crs();
1235  }
1236  }
1237 
1238  if ( val.canConvert<QgsProcessingFeatureSourceDefinition>() )
1239  {
1240  // input is a QgsProcessingFeatureSourceDefinition - get extra properties from it
1241  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( val );
1242  val = fromVar.source;
1243  }
1244  else if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
1245  {
1246  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
1247  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
1248  val = fromVar.sink;
1249  }
1250 
1251  if ( val.canConvert<QgsProperty>() && val.value< QgsProperty >().propertyType() == QgsProperty::StaticProperty )
1252  {
1253  val = val.value< QgsProperty >().staticValue();
1254  }
1255 
1256  QString valueAsString;
1257  if ( val.canConvert<QgsProperty>() )
1258  valueAsString = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
1259  else
1260  valueAsString = val.toString();
1261 
1262  QRegularExpression rx( QStringLiteral( "^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1263 
1264  QRegularExpressionMatch match = rx.match( valueAsString );
1265  if ( match.hasMatch() )
1266  {
1267  QgsCoordinateReferenceSystem crs( match.captured( 5 ) );
1268  if ( crs.isValid() )
1269  return crs;
1270  }
1271 
1272  if ( val.canConvert<QgsProcessingFeatureSourceDefinition>() )
1273  {
1274  // input is a QgsProcessingFeatureSourceDefinition - get extra properties from it
1275  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( val );
1276  val = fromVar.source;
1277  }
1278  else if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
1279  {
1280  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
1281  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( val );
1282  val = fromVar.sink;
1283  }
1284 
1285  if ( val.canConvert<QgsProperty>() && val.value< QgsProperty >().propertyType() == QgsProperty::StaticProperty )
1286  {
1287  val = val.value< QgsProperty >().staticValue();
1288  }
1289 
1290  // try as layer crs
1291  if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1292  return layer->crs();
1293  else if ( QgsMapLayer *layer = QgsProcessingUtils::mapLayerFromString( valueAsString, context ) )
1294  return layer->crs();
1295 
1296  if ( auto *lProject = context.project() )
1297  return lProject->crs();
1298  else
1300 }
1301 
1303 {
1304  if ( !definition )
1305  return QgsPointXY();
1306 
1307  return parameterAsPoint( definition, parameters.value( definition->name() ), context, crs );
1308 }
1309 
1311 {
1312  if ( !definition )
1313  return QgsPointXY();
1314 
1315  QVariant val = value;
1316  if ( val.canConvert< QgsPointXY >() )
1317  {
1318  return val.value<QgsPointXY>();
1319  }
1320  if ( val.canConvert< QgsGeometry >() )
1321  {
1322  const QgsGeometry geom = val.value<QgsGeometry>();
1323  if ( !geom.isNull() )
1324  return geom.centroid().asPoint();
1325  }
1326  if ( val.canConvert< QgsReferencedPointXY >() )
1327  {
1328  QgsReferencedPointXY rp = val.value<QgsReferencedPointXY>();
1329  if ( crs.isValid() && rp.crs().isValid() && crs != rp.crs() )
1330  {
1331  QgsCoordinateTransform ct( rp.crs(), crs, context.project() );
1332  try
1333  {
1334  return ct.transform( rp );
1335  }
1336  catch ( QgsCsException & )
1337  {
1338  QgsMessageLog::logMessage( QObject::tr( "Error transforming point geometry" ) );
1339  }
1340  }
1341  return rp;
1342  }
1343 
1344  QString pointText = parameterAsString( definition, value, context );
1345  if ( pointText.isEmpty() )
1346  pointText = definition->defaultValue().toString();
1347 
1348  if ( pointText.isEmpty() )
1349  return QgsPointXY();
1350 
1351  QRegularExpression rx( QStringLiteral( "^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1352 
1353  QString valueAsString = parameterAsString( definition, value, context );
1354  QRegularExpressionMatch match = rx.match( valueAsString );
1355  if ( match.hasMatch() )
1356  {
1357  bool xOk = false;
1358  double x = match.captured( 1 ).toDouble( &xOk );
1359  bool yOk = false;
1360  double y = match.captured( 2 ).toDouble( &yOk );
1361 
1362  if ( xOk && yOk )
1363  {
1364  QgsPointXY pt( x, y );
1365 
1366  QgsCoordinateReferenceSystem pointCrs( match.captured( 3 ) );
1367  if ( crs.isValid() && pointCrs.isValid() && crs != pointCrs )
1368  {
1369  QgsCoordinateTransform ct( pointCrs, crs, context.project() );
1370  try
1371  {
1372  return ct.transform( pt );
1373  }
1374  catch ( QgsCsException & )
1375  {
1376  QgsMessageLog::logMessage( QObject::tr( "Error transforming point geometry" ) );
1377  }
1378  }
1379  return pt;
1380  }
1381  }
1382 
1383  return QgsPointXY();
1384 }
1385 
1387 {
1388  QVariant val = parameters.value( definition->name() );
1389  return parameterAsPointCrs( definition, val, context );
1390 }
1391 
1393 {
1394  if ( value.canConvert< QgsReferencedPointXY >() )
1395  {
1396  QgsReferencedPointXY rr = value.value<QgsReferencedPointXY>();
1397  if ( rr.crs().isValid() )
1398  {
1399  return rr.crs();
1400  }
1401  }
1402 
1403  QRegularExpression rx( QStringLiteral( "^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1404 
1405  QString valueAsString = parameterAsString( definition, value, context );
1406  QRegularExpressionMatch match = rx.match( valueAsString );
1407  if ( match.hasMatch() )
1408  {
1409  QgsCoordinateReferenceSystem crs( match.captured( 3 ) );
1410  if ( crs.isValid() )
1411  return crs;
1412  }
1413 
1414  if ( auto *lProject = context.project() )
1415  return lProject->crs();
1416  else
1418 }
1419 
1421 {
1422  if ( !definition )
1423  return QgsGeometry();
1424 
1425  return parameterAsGeometry( definition, parameters.value( definition->name() ), context, crs );
1426 }
1427 
1429 {
1430  if ( !definition )
1431  return QgsGeometry();
1432 
1433  QVariant val = value;
1434  if ( val.canConvert< QgsGeometry >() )
1435  {
1436  return val.value<QgsGeometry>();
1437  }
1438 
1439  if ( val.canConvert< QgsPointXY >() )
1440  {
1441  return QgsGeometry::fromPointXY( val.value<QgsPointXY>() );
1442  }
1443 
1444  if ( val.canConvert< QgsRectangle >() )
1445  {
1446  return QgsGeometry::fromRect( val.value<QgsRectangle>() );
1447  }
1448 
1449  if ( val.canConvert< QgsReferencedPointXY >() )
1450  {
1451  QgsReferencedPointXY rp = val.value<QgsReferencedPointXY>();
1452  if ( crs.isValid() && rp.crs().isValid() && crs != rp.crs() )
1453  {
1454  QgsCoordinateTransform ct( rp.crs(), crs, context.project() );
1455  try
1456  {
1457  return QgsGeometry::fromPointXY( ct.transform( rp ) );
1458  }
1459  catch ( QgsCsException & )
1460  {
1461  QgsMessageLog::logMessage( QObject::tr( "Error transforming point geometry" ) );
1462  }
1463  }
1464  return QgsGeometry::fromPointXY( rp );
1465  }
1466 
1467  if ( val.canConvert< QgsReferencedRectangle >() )
1468  {
1471  if ( crs.isValid() && rr.crs().isValid() && crs != rr.crs() )
1472  {
1473  g = g.densifyByCount( 20 );
1474  QgsCoordinateTransform ct( rr.crs(), crs, context.project() );
1475  try
1476  {
1477  g.transform( ct );
1478  }
1479  catch ( QgsCsException & )
1480  {
1481  QgsMessageLog::logMessage( QObject::tr( "Error transforming rectangle geometry" ) );
1482  }
1483  }
1484  return g;
1485  }
1486 
1487  if ( val.canConvert< QgsReferencedGeometry >() )
1488  {
1489  QgsReferencedGeometry rg = val.value<QgsReferencedGeometry>();
1490  if ( crs.isValid() && rg.crs().isValid() && crs != rg.crs() )
1491  {
1492  QgsCoordinateTransform ct( rg.crs(), crs, context.project() );
1493  try
1494  {
1495  rg.transform( ct );
1496  }
1497  catch ( QgsCsException & )
1498  {
1499  QgsMessageLog::logMessage( QObject::tr( "Error transforming geometry" ) );
1500  }
1501  }
1502  return rg;
1503  }
1504 
1505  QString valueAsString = parameterAsString( definition, value, context );
1506  if ( valueAsString.isEmpty() )
1507  valueAsString = definition->defaultValue().toString();
1508 
1509  if ( valueAsString.isEmpty() )
1510  return QgsGeometry();
1511 
1512  QRegularExpression rx( QStringLiteral( "^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1513 
1514  QRegularExpressionMatch match = rx.match( valueAsString );
1515  if ( match.hasMatch() )
1516  {
1517  QgsGeometry g = QgsGeometry::fromWkt( match.captured( 2 ) );
1518  if ( !g.isNull() )
1519  {
1520  QgsCoordinateReferenceSystem geomCrs( match.captured( 1 ) );
1521  if ( crs.isValid() && geomCrs.isValid() && crs != geomCrs )
1522  {
1523  QgsCoordinateTransform ct( geomCrs, crs, context.project() );
1524  try
1525  {
1526  g.transform( ct );
1527  }
1528  catch ( QgsCsException & )
1529  {
1530  QgsMessageLog::logMessage( QObject::tr( "Error transforming geometry" ) );
1531  }
1532  }
1533  return g;
1534  }
1535  }
1536 
1537  return QgsGeometry();
1538 }
1539 
1540 
1542 {
1543  QVariant val = parameters.value( definition->name() );
1544  return parameterAsGeometryCrs( definition, val, context );
1545 }
1546 
1548 {
1549  if ( value.canConvert< QgsReferencedGeometry >() )
1550  {
1551  QgsReferencedGeometry rg = value.value<QgsReferencedGeometry>();
1552  if ( rg.crs().isValid() )
1553  {
1554  return rg.crs();
1555  }
1556  }
1557 
1558  if ( value.canConvert< QgsReferencedPointXY >() )
1559  {
1560  QgsReferencedPointXY rp = value.value<QgsReferencedPointXY>();
1561  if ( rp.crs().isValid() )
1562  {
1563  return rp.crs();
1564  }
1565  }
1566 
1567  if ( value.canConvert< QgsReferencedRectangle >() )
1568  {
1569  QgsReferencedRectangle rr = value.value<QgsReferencedRectangle>();
1570  if ( rr.crs().isValid() )
1571  {
1572  return rr.crs();
1573  }
1574  }
1575 
1576  // Match against EWKT
1577  QRegularExpression rx( QStringLiteral( "^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1578 
1579  QString valueAsString = parameterAsString( definition, value, context );
1580  QRegularExpressionMatch match = rx.match( valueAsString );
1581  if ( match.hasMatch() )
1582  {
1583  QgsCoordinateReferenceSystem crs( match.captured( 1 ) );
1584  if ( crs.isValid() )
1585  return crs;
1586  }
1587 
1588  if ( auto *lProject = context.project() )
1589  return lProject->crs();
1590  else
1592 }
1593 
1594 
1595 
1596 
1597 QString QgsProcessingParameters::parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
1598 {
1599  if ( !definition )
1600  return QString();
1601 
1602  QString fileText = parameterAsString( definition, parameters, context );
1603  if ( fileText.isEmpty() )
1604  fileText = definition->defaultValue().toString();
1605  return fileText;
1606 }
1607 
1608 QString QgsProcessingParameters::parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
1609 {
1610  if ( !definition )
1611  return QString();
1612 
1613  QString fileText = parameterAsString( definition, value, context );
1614  if ( fileText.isEmpty() )
1615  fileText = definition->defaultValue().toString();
1616  return fileText;
1617 }
1618 
1619 QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
1620 {
1621  if ( !definition )
1622  return QVariantList();
1623 
1624  return parameterAsMatrix( definition, parameters.value( definition->name() ), context );
1625 }
1626 
1627 QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
1628 {
1629  if ( !definition )
1630  return QVariantList();
1631 
1632  QString resultString;
1633  QVariant val = value;
1634  if ( val.canConvert<QgsProperty>() )
1635  resultString = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
1636  else if ( val.type() == QVariant::List )
1637  return val.toList();
1638  else
1639  resultString = val.toString();
1640 
1641  if ( resultString.isEmpty() )
1642  {
1643  // check default
1644  if ( definition->defaultValue().type() == QVariant::List )
1645  return definition->defaultValue().toList();
1646  else
1647  resultString = definition->defaultValue().toString();
1648  }
1649 
1650  QVariantList result;
1651  const auto constSplit = resultString.split( ',' );
1652  for ( const QString &s : constSplit )
1653  result << s;
1654 
1655  return result;
1656 }
1657 
1658 QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
1659 {
1660  if ( !definition )
1661  return QList<QgsMapLayer *>();
1662 
1663  return parameterAsLayerList( definition, parameters.value( definition->name() ), context );
1664 }
1665 
1666 QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
1667 {
1668  if ( !definition )
1669  return QList<QgsMapLayer *>();
1670 
1671  QVariant val = value;
1672  if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1673  {
1674  return QList<QgsMapLayer *>() << layer;
1675  }
1676 
1677  QList<QgsMapLayer *> layers;
1678 
1679  std::function< void( const QVariant &var ) > processVariant;
1680  processVariant = [ &layers, &context, &definition, &processVariant ]( const QVariant & var )
1681  {
1682  if ( var.type() == QVariant::List )
1683  {
1684  const auto constToList = var.toList();
1685  for ( const QVariant &listVar : constToList )
1686  {
1687  processVariant( listVar );
1688  }
1689  }
1690  else if ( var.type() == QVariant::StringList )
1691  {
1692  const auto constToStringList = var.toStringList();
1693  for ( const QString &s : constToStringList )
1694  {
1695  processVariant( s );
1696  }
1697  }
1698  else if ( var.canConvert<QgsProperty>() )
1699  processVariant( var.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1700  else if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
1701  {
1702  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
1703  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
1704  QVariant sink = fromVar.sink;
1705  if ( sink.canConvert<QgsProperty>() )
1706  {
1707  processVariant( sink.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1708  }
1709  }
1710  else if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1711  {
1712  layers << layer;
1713  }
1714  else
1715  {
1716  QgsMapLayer *alayer = QgsProcessingUtils::mapLayerFromString( var.toString(), context );
1717  if ( alayer )
1718  layers << alayer;
1719  }
1720  };
1721 
1722  processVariant( val );
1723 
1724  if ( layers.isEmpty() )
1725  {
1726  // check default
1727  if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1728  {
1729  layers << layer;
1730  }
1731  else if ( definition->defaultValue().type() == QVariant::List )
1732  {
1733  const auto constToList = definition->defaultValue().toList();
1734  for ( const QVariant &var : constToList )
1735  {
1736  if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1737  {
1738  layers << layer;
1739  }
1740  else
1741  {
1742  processVariant( var );
1743  }
1744  }
1745  }
1746  else
1747  processVariant( definition->defaultValue() );
1748  }
1749 
1750  return layers;
1751 }
1752 
1753 QStringList QgsProcessingParameters::parameterAsFileList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
1754 {
1755  if ( !definition )
1756  return QStringList();
1757 
1758  QVariant val = value;
1759 
1760  QStringList files;
1761 
1762  std::function< void( const QVariant &var ) > processVariant;
1763  processVariant = [ &files, &context, &definition, &processVariant ]( const QVariant & var )
1764  {
1765  if ( var.type() == QVariant::List )
1766  {
1767  const auto constToList = var.toList();
1768  for ( const QVariant &listVar : constToList )
1769  {
1770  processVariant( listVar );
1771  }
1772  }
1773  else if ( var.type() == QVariant::StringList )
1774  {
1775  const auto constToStringList = var.toStringList();
1776  for ( const QString &s : constToStringList )
1777  {
1778  processVariant( s );
1779  }
1780  }
1781  else if ( var.canConvert<QgsProperty>() )
1782  processVariant( var.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1783  else
1784  {
1785  files << var.toString();
1786  }
1787  };
1788 
1789  processVariant( val );
1790 
1791  if ( files.isEmpty() )
1792  {
1793  processVariant( definition->defaultValue() );
1794  }
1795 
1796  return files;
1797 }
1798 
1799 QStringList QgsProcessingParameters::parameterAsFileList( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
1800 {
1801  if ( !definition )
1802  return QStringList();
1803 
1804  return parameterAsFileList( definition, parameters.value( definition->name() ), context );
1805 }
1806 
1807 QList<double> QgsProcessingParameters::parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
1808 {
1809  if ( !definition )
1810  return QList<double>();
1811 
1812  return parameterAsRange( definition, parameters.value( definition->name() ), context );
1813 }
1814 
1815 QList<double> QgsProcessingParameters::parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
1816 {
1817  if ( !definition )
1818  return QList<double>();
1819 
1820  QStringList resultStringList;
1821  QVariant val = value;
1822 
1823  if ( val.canConvert<QgsProperty>() )
1824  resultStringList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
1825  else if ( val.type() == QVariant::List )
1826  {
1827  const auto constToList = val.toList();
1828  for ( const QVariant &var : constToList )
1829  resultStringList << var.toString();
1830  }
1831  else
1832  resultStringList << val.toString();
1833 
1834  if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1835  {
1836  resultStringList.clear();
1837  // check default
1838  if ( definition->defaultValue().type() == QVariant::List )
1839  {
1840  const auto constToList = definition->defaultValue().toList();
1841  for ( const QVariant &var : constToList )
1842  resultStringList << var.toString();
1843  }
1844  else
1845  resultStringList << definition->defaultValue().toString();
1846  }
1847 
1848  if ( resultStringList.size() == 1 )
1849  {
1850  resultStringList = resultStringList.at( 0 ).split( ',' );
1851  }
1852 
1853  if ( resultStringList.size() < 2 )
1854  return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1855 
1856  QList< double > result;
1857  bool ok = false;
1858  double n = resultStringList.at( 0 ).toDouble( &ok );
1859  if ( ok )
1860  result << n;
1861  else
1862  result << std::numeric_limits<double>::quiet_NaN() ;
1863  ok = false;
1864  n = resultStringList.at( 1 ).toDouble( &ok );
1865  if ( ok )
1866  result << n;
1867  else
1868  result << std::numeric_limits<double>::quiet_NaN() ;
1869 
1870  return result;
1871 }
1872 
1873 QStringList QgsProcessingParameters::parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
1874 {
1875  if ( !definition )
1876  return QStringList();
1877 
1878  QStringList resultStringList;
1879  return parameterAsFields( definition, parameters.value( definition->name() ), context );
1880 }
1881 
1882 QStringList QgsProcessingParameters::parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
1883 {
1884  if ( !definition )
1885  return QStringList();
1886 
1887  QStringList resultStringList;
1888  QVariant val = value;
1889  if ( val.isValid() )
1890  {
1891  if ( val.canConvert<QgsProperty>() )
1892  resultStringList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
1893  else if ( val.type() == QVariant::List )
1894  {
1895  const auto constToList = val.toList();
1896  for ( const QVariant &var : constToList )
1897  resultStringList << var.toString();
1898  }
1899  else if ( val.type() == QVariant::StringList )
1900  {
1901  resultStringList = val.toStringList();
1902  }
1903  else
1904  resultStringList.append( val.toString().split( ';' ) );
1905  }
1906 
1907  if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1908  {
1909  resultStringList.clear();
1910  // check default
1911  if ( definition->defaultValue().isValid() )
1912  {
1913  if ( definition->defaultValue().type() == QVariant::List )
1914  {
1915  const auto constToList = definition->defaultValue().toList();
1916  for ( const QVariant &var : constToList )
1917  resultStringList << var.toString();
1918  }
1919  else if ( definition->defaultValue().type() == QVariant::StringList )
1920  {
1921  resultStringList = definition->defaultValue().toStringList();
1922  }
1923  else
1924  resultStringList.append( definition->defaultValue().toString().split( ';' ) );
1925  }
1926  }
1927 
1928  return resultStringList;
1929 }
1930 
1932 {
1933  if ( !definition )
1934  return nullptr;
1935 
1936  return parameterAsLayout( definition, parameters.value( definition->name() ), context );
1937 }
1938 
1940 {
1941  const QString layoutName = parameterAsString( definition, value, context );
1942  if ( layoutName.isEmpty() )
1943  return nullptr;
1944 
1945  if ( !context.project() )
1946  return nullptr;
1947 
1948  QgsMasterLayoutInterface *l = context.project()->layoutManager()->layoutByName( layoutName );
1950  return static_cast< QgsPrintLayout * >( l );
1951  else
1952  return nullptr;
1953 }
1954 
1956 {
1957  if ( !definition )
1958  return nullptr;
1959 
1960  return parameterAsLayoutItem( definition, parameters.value( definition->name() ), context, layout );
1961 }
1962 
1964 {
1965  if ( !layout )
1966  return nullptr;
1967 
1968  const QString id = parameterAsString( definition, value, context );
1969  if ( id.isEmpty() )
1970  return nullptr;
1971 
1972  // prefer matching by uuid, since it's guaranteed to be unique.
1973  if ( QgsLayoutItem *item = layout->itemByUuid( id ) )
1974  return item;
1975  else if ( QgsLayoutItem *item = layout->itemById( id ) )
1976  return item;
1977  else
1978  return nullptr;
1979 }
1980 
1981 QColor QgsProcessingParameters::parameterAsColor( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
1982 {
1983  if ( !definition )
1984  return QColor();
1985 
1986  return parameterAsColor( definition, parameters.value( definition->name() ), context );
1987 }
1988 
1990 {
1991  if ( !definition )
1992  return QColor();
1993 
1994  QVariant val = value;
1995  if ( val.canConvert<QgsProperty>() )
1996  {
1997  val = val.value< QgsProperty >().value( context.expressionContext(), definition->defaultValue() );
1998  }
1999  if ( val.type() == QVariant::Color )
2000  {
2001  QColor c = val.value< QColor >();
2002  if ( const QgsProcessingParameterColor *colorParam = dynamic_cast< const QgsProcessingParameterColor * >( definition ) )
2003  if ( !colorParam->opacityEnabled() )
2004  c.setAlpha( 255 );
2005  return c;
2006  }
2007 
2008  QString colorText = parameterAsString( definition, value, context );
2009  if ( colorText.isEmpty() && !( definition->flags() & QgsProcessingParameterDefinition::FlagOptional ) )
2010  {
2011  if ( definition->defaultValue().type() == QVariant::Color )
2012  return definition->defaultValue().value< QColor >();
2013  else
2014  colorText = definition->defaultValue().toString();
2015  }
2016 
2017  if ( colorText.isEmpty() )
2018  return QColor();
2019 
2020  bool containsAlpha = false;
2021  QColor c = QgsSymbolLayerUtils::parseColorWithAlpha( colorText, containsAlpha );
2022  if ( const QgsProcessingParameterColor *colorParam = dynamic_cast< const QgsProcessingParameterColor * >( definition ) )
2023  if ( c.isValid() && !colorParam->opacityEnabled() )
2024  c.setAlpha( 255 );
2025  return c;
2026 }
2027 
2028 QString QgsProcessingParameters::parameterAsConnectionName( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
2029 {
2030  if ( !definition )
2031  return QString();
2032 
2033  return parameterAsConnectionName( definition, parameters.value( definition->name() ), context );
2034 }
2035 
2036 QString QgsProcessingParameters::parameterAsConnectionName( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
2037 {
2038  // for now it's just treated identical to strings, but in future we may want flexibility to amend this
2039  // (hence the new method)
2040  return parameterAsString( definition, value, context );
2041 }
2042 
2043 QString QgsProcessingParameters::parameterAsSchema( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
2044 {
2045  if ( !definition )
2046  return QString();
2047 
2048  return parameterAsSchema( definition, parameters.value( definition->name() ), context );
2049 }
2050 
2051 QString QgsProcessingParameters::parameterAsSchema( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
2052 {
2053  // for now it's just treated identical to strings, but in future we may want flexibility to amend this (e.g. if we want to embed connection details into the schema
2054  // parameter values, such as via a delimiter separated string)
2055  return parameterAsString( definition, value, context );
2056 }
2057 
2058 QString QgsProcessingParameters::parameterAsDatabaseTableName( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context )
2059 {
2060  if ( !definition )
2061  return QString();
2062 
2063  return parameterAsDatabaseTableName( definition, parameters.value( definition->name() ), context );
2064 }
2065 
2067 {
2068  // for now it's just treated identical to strings, but in future we may want flexibility to amend this (e.g. if we want to embed connection details into the table name
2069  // parameter values, such as via a delimiter separated string)
2070  return parameterAsString( definition, value, context );
2071 }
2072 
2074 {
2075  QString type = map.value( QStringLiteral( "parameter_type" ) ).toString();
2076  QString name = map.value( QStringLiteral( "name" ) ).toString();
2077  std::unique_ptr< QgsProcessingParameterDefinition > def;
2078 
2079  // probably all these hardcoded values aren't required anymore, and we could
2080  // always resort to the registry lookup...
2081  // TODO: confirm
2083  def.reset( new QgsProcessingParameterBoolean( name ) );
2084  else if ( type == QgsProcessingParameterCrs::typeName() )
2085  def.reset( new QgsProcessingParameterCrs( name ) );
2086  else if ( type == QgsProcessingParameterMapLayer::typeName() )
2087  def.reset( new QgsProcessingParameterMapLayer( name ) );
2088  else if ( type == QgsProcessingParameterExtent::typeName() )
2089  def.reset( new QgsProcessingParameterExtent( name ) );
2090  else if ( type == QgsProcessingParameterPoint::typeName() )
2091  def.reset( new QgsProcessingParameterPoint( name ) );
2092  else if ( type == QgsProcessingParameterFile::typeName() )
2093  def.reset( new QgsProcessingParameterFile( name ) );
2094  else if ( type == QgsProcessingParameterMatrix::typeName() )
2095  def.reset( new QgsProcessingParameterMatrix( name ) );
2097  def.reset( new QgsProcessingParameterMultipleLayers( name ) );
2098  else if ( type == QgsProcessingParameterNumber::typeName() )
2099  def.reset( new QgsProcessingParameterNumber( name ) );
2100  else if ( type == QgsProcessingParameterRange::typeName() )
2101  def.reset( new QgsProcessingParameterRange( name ) );
2102  else if ( type == QgsProcessingParameterRasterLayer::typeName() )
2103  def.reset( new QgsProcessingParameterRasterLayer( name ) );
2104  else if ( type == QgsProcessingParameterEnum::typeName() )
2105  def.reset( new QgsProcessingParameterEnum( name ) );
2106  else if ( type == QgsProcessingParameterString::typeName() )
2107  def.reset( new QgsProcessingParameterString( name ) );
2108  else if ( type == QgsProcessingParameterAuthConfig::typeName() )
2109  def.reset( new QgsProcessingParameterAuthConfig( name ) );
2110  else if ( type == QgsProcessingParameterExpression::typeName() )
2111  def.reset( new QgsProcessingParameterExpression( name ) );
2112  else if ( type == QgsProcessingParameterVectorLayer::typeName() )
2113  def.reset( new QgsProcessingParameterVectorLayer( name ) );
2114  else if ( type == QgsProcessingParameterField::typeName() )
2115  def.reset( new QgsProcessingParameterField( name ) );
2116  else if ( type == QgsProcessingParameterFeatureSource::typeName() )
2117  def.reset( new QgsProcessingParameterFeatureSource( name ) );
2118  else if ( type == QgsProcessingParameterFeatureSink::typeName() )
2119  def.reset( new QgsProcessingParameterFeatureSink( name ) );
2121  def.reset( new QgsProcessingParameterVectorDestination( name ) );
2123  def.reset( new QgsProcessingParameterRasterDestination( name ) );
2125  def.reset( new QgsProcessingParameterFileDestination( name ) );
2127  def.reset( new QgsProcessingParameterFolderDestination( name ) );
2128  else if ( type == QgsProcessingParameterBand::typeName() )
2129  def.reset( new QgsProcessingParameterBand( name ) );
2130  else if ( type == QgsProcessingParameterMeshLayer::typeName() )
2131  def.reset( new QgsProcessingParameterMeshLayer( name ) );
2132  else if ( type == QgsProcessingParameterLayout::typeName() )
2133  def.reset( new QgsProcessingParameterLayout( name ) );
2134  else if ( type == QgsProcessingParameterLayoutItem::typeName() )
2135  def.reset( new QgsProcessingParameterLayoutItem( name ) );
2136  else if ( type == QgsProcessingParameterColor::typeName() )
2137  def.reset( new QgsProcessingParameterColor( name ) );
2139  def.reset( new QgsProcessingParameterCoordinateOperation( name ) );
2140  else
2141  {
2143  if ( paramType )
2144  def.reset( paramType->create( name ) );
2145  }
2146 
2147  if ( !def )
2148  return nullptr;
2149 
2150  def->fromVariantMap( map );
2151  return def.release();
2152 }
2153 
2154 QString QgsProcessingParameters::descriptionFromName( const QString &name )
2155 {
2156  QString desc = name;
2157  desc.replace( '_', ' ' );
2158  return desc;
2159 }
2160 
2162 {
2163  bool isOptional = false;
2164  QString name;
2165  QString definition;
2166  QString type;
2167  if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2168  return nullptr;
2169 
2170  QString description = descriptionFromName( name );
2171 
2172  if ( type == QLatin1String( "boolean" ) )
2173  return QgsProcessingParameterBoolean::fromScriptCode( name, description, isOptional, definition );
2174  else if ( type == QLatin1String( "crs" ) )
2175  return QgsProcessingParameterCrs::fromScriptCode( name, description, isOptional, definition );
2176  else if ( type == QLatin1String( "layer" ) )
2177  return QgsProcessingParameterMapLayer::fromScriptCode( name, description, isOptional, definition );
2178  else if ( type == QLatin1String( "extent" ) )
2179  return QgsProcessingParameterExtent::fromScriptCode( name, description, isOptional, definition );
2180  else if ( type == QLatin1String( "point" ) )
2181  return QgsProcessingParameterPoint::fromScriptCode( name, description, isOptional, definition );
2182  else if ( type == QLatin1String( "geometry" ) )
2183  return QgsProcessingParameterGeometry::fromScriptCode( name, description, isOptional, definition );
2184  else if ( type == QLatin1String( "file" ) )
2185  return QgsProcessingParameterFile::fromScriptCode( name, description, isOptional, definition, QgsProcessingParameterFile::File );
2186  else if ( type == QLatin1String( "folder" ) )
2187  return QgsProcessingParameterFile::fromScriptCode( name, description, isOptional, definition, QgsProcessingParameterFile::Folder );
2188  else if ( type == QLatin1String( "matrix" ) )
2189  return QgsProcessingParameterMatrix::fromScriptCode( name, description, isOptional, definition );
2190  else if ( type == QLatin1String( "multiple" ) )
2191  return QgsProcessingParameterMultipleLayers::fromScriptCode( name, description, isOptional, definition );
2192  else if ( type == QLatin1String( "number" ) )
2193  return QgsProcessingParameterNumber::fromScriptCode( name, description, isOptional, definition );
2194  else if ( type == QLatin1String( "distance" ) )
2195  return QgsProcessingParameterDistance::fromScriptCode( name, description, isOptional, definition );
2196  else if ( type == QLatin1String( "scale" ) )
2197  return QgsProcessingParameterScale::fromScriptCode( name, description, isOptional, definition );
2198  else if ( type == QLatin1String( "range" ) )
2199  return QgsProcessingParameterRange::fromScriptCode( name, description, isOptional, definition );
2200  else if ( type == QLatin1String( "raster" ) )
2201  return QgsProcessingParameterRasterLayer::fromScriptCode( name, description, isOptional, definition );
2202  else if ( type == QLatin1String( "enum" ) )
2203  return QgsProcessingParameterEnum::fromScriptCode( name, description, isOptional, definition );
2204  else if ( type == QLatin1String( "string" ) )
2205  return QgsProcessingParameterString::fromScriptCode( name, description, isOptional, definition );
2206  else if ( type == QLatin1String( "authcfg" ) )
2207  return QgsProcessingParameterAuthConfig::fromScriptCode( name, description, isOptional, definition );
2208  else if ( type == QLatin1String( "expression" ) )
2209  return QgsProcessingParameterExpression::fromScriptCode( name, description, isOptional, definition );
2210  else if ( type == QLatin1String( "field" ) )
2211  return QgsProcessingParameterField::fromScriptCode( name, description, isOptional, definition );
2212  else if ( type == QLatin1String( "vector" ) )
2213  return QgsProcessingParameterVectorLayer::fromScriptCode( name, description, isOptional, definition );
2214  else if ( type == QLatin1String( "source" ) )
2215  return QgsProcessingParameterFeatureSource::fromScriptCode( name, description, isOptional, definition );
2216  else if ( type == QLatin1String( "sink" ) )
2217  return QgsProcessingParameterFeatureSink::fromScriptCode( name, description, isOptional, definition );
2218  else if ( type == QLatin1String( "vectordestination" ) )
2219  return QgsProcessingParameterVectorDestination::fromScriptCode( name, description, isOptional, definition );
2220  else if ( type == QLatin1String( "rasterdestination" ) )
2221  return QgsProcessingParameterRasterDestination::fromScriptCode( name, description, isOptional, definition );
2222  else if ( type == QLatin1String( "filedestination" ) )
2223  return QgsProcessingParameterFileDestination::fromScriptCode( name, description, isOptional, definition );
2224  else if ( type == QLatin1String( "folderdestination" ) )
2225  return QgsProcessingParameterFolderDestination::fromScriptCode( name, description, isOptional, definition );
2226  else if ( type == QLatin1String( "band" ) )
2227  return QgsProcessingParameterBand::fromScriptCode( name, description, isOptional, definition );
2228  else if ( type == QLatin1String( "mesh" ) )
2229  return QgsProcessingParameterMeshLayer::fromScriptCode( name, description, isOptional, definition );
2230  else if ( type == QLatin1String( "layout" ) )
2231  return QgsProcessingParameterLayout::fromScriptCode( name, description, isOptional, definition );
2232  else if ( type == QLatin1String( "layoutitem" ) )
2233  return QgsProcessingParameterLayoutItem::fromScriptCode( name, description, isOptional, definition );
2234  else if ( type == QLatin1String( "color" ) )
2235  return QgsProcessingParameterColor::fromScriptCode( name, description, isOptional, definition );
2236  else if ( type == QLatin1String( "coordinateoperation" ) )
2237  return QgsProcessingParameterCoordinateOperation::fromScriptCode( name, description, isOptional, definition );
2238  else if ( type == QLatin1String( "maptheme" ) )
2239  return QgsProcessingParameterMapTheme::fromScriptCode( name, description, isOptional, definition );
2240  else if ( type == QLatin1String( "datetime" ) )
2241  return QgsProcessingParameterDateTime::fromScriptCode( name, description, isOptional, definition );
2242  else if ( type == QLatin1String( "providerconnection" ) )
2243  return QgsProcessingParameterProviderConnection::fromScriptCode( name, description, isOptional, definition );
2244  else if ( type == QLatin1String( "databaseschema" ) )
2245  return QgsProcessingParameterDatabaseSchema::fromScriptCode( name, description, isOptional, definition );
2246  else if ( type == QLatin1String( "databasetable" ) )
2247  return QgsProcessingParameterDatabaseTable::fromScriptCode( name, description, isOptional, definition );
2248 
2249  return nullptr;
2250 }
2251 
2252 bool QgsProcessingParameters::parseScriptCodeParameterOptions( const QString &code, bool &isOptional, QString &name, QString &type, QString &definition )
2253 {
2254  QRegularExpression re( QStringLiteral( "(?:#*)(.*?)=\\s*(.*)" ) );
2255  QRegularExpressionMatch m = re.match( code );
2256  if ( !m.hasMatch() )
2257  return false;
2258 
2259  name = m.captured( 1 );
2260  QString tokens = m.captured( 2 );
2261  if ( tokens.startsWith( QLatin1String( "optional" ), Qt::CaseInsensitive ) )
2262  {
2263  isOptional = true;
2264  tokens.remove( 0, 8 ); // length "optional" = 8
2265  }
2266  else
2267  {
2268  isOptional = false;
2269  }
2270 
2271  tokens = tokens.trimmed();
2272 
2273  QRegularExpression re2( QStringLiteral( "(.*?)\\s+(.*)" ) );
2274  m = re2.match( tokens );
2275  if ( !m.hasMatch() )
2276  {
2277  type = tokens.toLower().trimmed();
2278  definition.clear();
2279  }
2280  else
2281  {
2282  type = m.captured( 1 ).toLower().trimmed();
2283  definition = m.captured( 2 );
2284  }
2285  return true;
2286 }
2287 
2288 //
2289 // QgsProcessingParameterDefinition
2290 //
2291 
2292 QgsProcessingParameterDefinition::QgsProcessingParameterDefinition( const QString &name, const QString &description, const QVariant &defaultValue, bool optional, const QString &help )
2293  : mName( name )
2294  , mDescription( description )
2295  , mHelp( help )
2296  , mDefault( defaultValue )
2297  , mFlags( optional ? FlagOptional : 0 )
2298 {}
2299 
2301 {
2302  if ( !input.isValid() && !mDefault.isValid() )
2303  return mFlags & FlagOptional;
2304 
2305  if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2306  || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) )
2307  return mFlags & FlagOptional;
2308 
2309  return true;
2310 }
2311 
2313 {
2314  if ( !value.isValid() )
2315  return QStringLiteral( "None" );
2316 
2317  if ( value.canConvert<QgsProperty>() )
2318  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
2319 
2320  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
2321 }
2322 
2324 {
2325  QString code = QStringLiteral( "##%1=" ).arg( mName );
2326  if ( mFlags & FlagOptional )
2327  code += QLatin1String( "optional " );
2328  code += type() + ' ';
2329  code += mDefault.toString();
2330  return code.trimmed();
2331 }
2332 
2334 {
2335  // base class method is probably not much use
2336  if ( QgsProcessingParameterType *t = QgsApplication::processingRegistry()->parameterType( type() ) )
2337  {
2338  switch ( outputType )
2339  {
2341  {
2342  QString code = t->className() + QStringLiteral( "('%1', '%2'" ).arg( name(), description() );
2343  if ( mFlags & FlagOptional )
2344  code += QLatin1String( ", optional=True" );
2345 
2347  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
2348  return code;
2349  }
2350  }
2351  }
2352 
2353  // oh well, we tried
2354  return QString();
2355 }
2356 
2358 {
2359  QVariantMap map;
2360  map.insert( QStringLiteral( "parameter_type" ), type() );
2361  map.insert( QStringLiteral( "name" ), mName );
2362  map.insert( QStringLiteral( "description" ), mDescription );
2363  map.insert( QStringLiteral( "help" ), mHelp );
2364  map.insert( QStringLiteral( "default" ), mDefault );
2365  map.insert( QStringLiteral( "flags" ), static_cast< int >( mFlags ) );
2366  map.insert( QStringLiteral( "metadata" ), mMetadata );
2367  return map;
2368 }
2369 
2371 {
2372  mName = map.value( QStringLiteral( "name" ) ).toString();
2373  mDescription = map.value( QStringLiteral( "description" ) ).toString();
2374  mHelp = map.value( QStringLiteral( "help" ) ).toString();
2375  mDefault = map.value( QStringLiteral( "default" ) );
2376  mFlags = static_cast< Flags >( map.value( QStringLiteral( "flags" ) ).toInt() );
2377  mMetadata = map.value( QStringLiteral( "metadata" ) ).toMap();
2378  return true;
2379 }
2380 
2382 {
2383  return mAlgorithm;
2384 }
2385 
2387 {
2388  return mAlgorithm ? mAlgorithm->provider() : nullptr;
2389 }
2390 
2392 {
2393  QString text = QStringLiteral( "<p><b>%1</b></p>" ).arg( description() );
2394  if ( !help().isEmpty() )
2395  {
2396  text += QStringLiteral( "<p>%1</p>" ).arg( help() );
2397  }
2398  text += QStringLiteral( "<p>%1</p>" ).arg( QObject::tr( "Python identifier: ‘%1’" ).arg( QStringLiteral( "<i>%1</i>" ).arg( name() ) ) );
2399  return text;
2400 }
2401 
2402 QgsProcessingParameterBoolean::QgsProcessingParameterBoolean( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
2403  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
2404 {}
2405 
2407 {
2408  return new QgsProcessingParameterBoolean( *this );
2409 }
2410 
2412 {
2413  if ( !val.isValid() )
2414  return QStringLiteral( "None" );
2415 
2416  if ( val.canConvert<QgsProperty>() )
2417  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( val.value< QgsProperty >().asExpression() );
2418  return val.toBool() ? QStringLiteral( "True" ) : QStringLiteral( "False" );
2419 }
2420 
2422 {
2423  QString code = QStringLiteral( "##%1=" ).arg( mName );
2424  if ( mFlags & FlagOptional )
2425  code += QLatin1String( "optional " );
2426  code += type() + ' ';
2427  code += mDefault.toBool() ? QStringLiteral( "true" ) : QStringLiteral( "false" );
2428  return code.trimmed();
2429 }
2430 
2431 QgsProcessingParameterBoolean *QgsProcessingParameterBoolean::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
2432 {
2433  return new QgsProcessingParameterBoolean( name, description, definition.toLower().trimmed() != QStringLiteral( "false" ), isOptional );
2434 }
2435 
2436 QgsProcessingParameterCrs::QgsProcessingParameterCrs( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
2437  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
2438 {
2439 
2440 }
2441 
2443 {
2444  return new QgsProcessingParameterCrs( *this );
2445 }
2446 
2448 {
2449  if ( !input.isValid() )
2450  return mFlags & FlagOptional;
2451 
2452  if ( input.canConvert<QgsCoordinateReferenceSystem>() )
2453  {
2454  return true;
2455  }
2456  else if ( input.canConvert<QgsProcessingFeatureSourceDefinition>() )
2457  {
2458  return true;
2459  }
2460  else if ( input.canConvert<QgsProcessingOutputLayerDefinition>() )
2461  {
2462  return true;
2463  }
2464 
2465  if ( input.canConvert<QgsProperty>() )
2466  {
2467  return true;
2468  }
2469 
2470  // direct map layer value
2471  if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2472  return true;
2473 
2474  if ( input.type() != QVariant::String || input.toString().isEmpty() )
2475  return mFlags & FlagOptional;
2476 
2477  return true;
2478 }
2479 
2480 QString QgsProcessingParameterCrs::valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const
2481 {
2482  if ( !value.isValid() )
2483  return QStringLiteral( "None" );
2484 
2485  if ( value.canConvert<QgsCoordinateReferenceSystem>() )
2486  {
2487  if ( !value.value< QgsCoordinateReferenceSystem >().isValid() )
2488  return QStringLiteral( "QgsCoordinateReferenceSystem()" );
2489  else
2490  return QStringLiteral( "QgsCoordinateReferenceSystem('%1')" ).arg( value.value< QgsCoordinateReferenceSystem >().authid() );
2491  }
2492 
2493  if ( value.canConvert<QgsProperty>() )
2494  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
2495 
2496  QVariantMap p;
2497  p.insert( name(), value );
2498  QgsMapLayer *layer = QgsProcessingParameters::parameterAsLayer( this, p, context );
2499  if ( layer )
2501 
2503 }
2504 
2505 QgsProcessingParameterCrs *QgsProcessingParameterCrs::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
2506 {
2507  return new QgsProcessingParameterCrs( name, description, definition.compare( QLatin1String( "none" ), Qt::CaseInsensitive ) == 0 ? QVariant() : definition, isOptional );
2508 }
2509 
2510 QgsProcessingParameterMapLayer::QgsProcessingParameterMapLayer( const QString &name, const QString &description, const QVariant &defaultValue, bool optional, const QList<int> &types )
2511  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
2513 {
2514 
2515 }
2516 
2518 {
2519  return new QgsProcessingParameterMapLayer( *this );
2520 }
2521 
2523 {
2524  if ( !input.isValid() )
2525  return mFlags & FlagOptional;
2526 
2527  if ( input.canConvert<QgsProperty>() )
2528  {
2529  return true;
2530  }
2531 
2532  if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2533  {
2534  return true;
2535  }
2536 
2537  if ( input.type() != QVariant::String || input.toString().isEmpty() )
2538  return mFlags & FlagOptional;
2539 
2540  if ( !context )
2541  {
2542  // that's as far as we can get without a context
2543  return true;
2544  }
2545 
2546  // try to load as layer
2547  if ( QgsProcessingUtils::mapLayerFromString( input.toString(), *context ) )
2548  return true;
2549 
2550  return false;
2551 }
2552 
2554 {
2555  if ( !val.isValid() )
2556  return QStringLiteral( "None" );
2557 
2558  if ( val.canConvert<QgsProperty>() )
2559  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( val.value< QgsProperty >().asExpression() );
2560 
2561  QVariantMap p;
2562  p.insert( name(), val );
2563  QgsMapLayer *layer = QgsProcessingParameters::parameterAsLayer( this, p, context );
2565  : QgsProcessingUtils::stringToPythonLiteral( val.toString() );
2566 }
2567 
2569 {
2570  QStringList vectors = QgsProviderRegistry::instance()->fileVectorFilters().split( QStringLiteral( ";;" ) );
2571  QStringList rasters = QgsProviderRegistry::instance()->fileRasterFilters().split( QStringLiteral( ";;" ) );
2572  for ( const QString &raster : rasters )
2573  {
2574  if ( !vectors.contains( raster ) )
2575  vectors << raster;
2576  }
2577  QStringList meshFilters = QgsProviderRegistry::instance()->fileMeshFilters().split( QStringLiteral( ";;" ) );
2578  for ( const QString &mesh : meshFilters )
2579  {
2580  if ( !vectors.contains( mesh ) )
2581  vectors << mesh;
2582  }
2583  vectors.removeAll( QObject::tr( "All files (*.*)" ) );
2584  std::sort( vectors.begin(), vectors.end() );
2585 
2586  return QObject::tr( "All files (*.*)" ) + QStringLiteral( ";;" ) + vectors.join( QLatin1String( ";;" ) );
2587 }
2588 
2590 {
2591  return createAllMapLayerFileFilter();
2592 }
2593 
2595 {
2596  QString code = QStringLiteral( "##%1=" ).arg( mName );
2597  if ( mFlags & FlagOptional )
2598  code += QLatin1String( "optional " );
2599  code += QLatin1String( "layer " );
2600 
2601  for ( int type : mDataTypes )
2602  {
2603  switch ( type )
2604  {
2606  code += QLatin1String( "hasgeometry " );
2607  break;
2608 
2610  code += QLatin1String( "point " );
2611  break;
2612 
2614  code += QLatin1String( "line " );
2615  break;
2616 
2618  code += QLatin1String( "polygon " );
2619  break;
2620 
2622  code += QLatin1String( "raster " );
2623  break;
2624 
2626  code += QLatin1String( "mesh " );
2627  break;
2628  }
2629  }
2630 
2631  code += mDefault.toString();
2632  return code.trimmed();
2633 }
2634 
2635 QgsProcessingParameterMapLayer *QgsProcessingParameterMapLayer::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
2636 {
2637  QList< int > types;
2638  QString def = definition;
2639  while ( true )
2640  {
2641  if ( def.startsWith( QLatin1String( "hasgeometry" ), Qt::CaseInsensitive ) )
2642  {
2644  def = def.mid( 12 );
2645  continue;
2646  }
2647  else if ( def.startsWith( QLatin1String( "point" ), Qt::CaseInsensitive ) )
2648  {
2650  def = def.mid( 6 );
2651  continue;
2652  }
2653  else if ( def.startsWith( QLatin1String( "line" ), Qt::CaseInsensitive ) )
2654  {
2656  def = def.mid( 5 );
2657  continue;
2658  }
2659  else if ( def.startsWith( QLatin1String( "polygon" ), Qt::CaseInsensitive ) )
2660  {
2662  def = def.mid( 8 );
2663  continue;
2664  }
2665  else if ( def.startsWith( QLatin1String( "raster" ), Qt::CaseInsensitive ) )
2666  {
2667  types << QgsProcessing::TypeRaster;
2668  def = def.mid( 7 );
2669  continue;
2670  }
2671  else if ( def.startsWith( QLatin1String( "mesh" ), Qt::CaseInsensitive ) )
2672  {
2673  types << QgsProcessing::TypeMesh;
2674  def = def.mid( 5 );
2675  continue;
2676  }
2677  break;
2678  }
2679 
2680  return new QgsProcessingParameterMapLayer( name, description, def, isOptional, types );
2681 }
2682 
2684 {
2685  switch ( outputType )
2686  {
2688  {
2689  QString code = QStringLiteral( "QgsProcessingParameterMapLayer('%1', '%2'" ).arg( name(), description() );
2690  if ( mFlags & FlagOptional )
2691  code += QLatin1String( ", optional=True" );
2692 
2694  code += QStringLiteral( ", defaultValue=%1" ).arg( valueAsPythonString( mDefault, c ) );
2695 
2696  if ( !mDataTypes.empty() )
2697  {
2698  QStringList options;
2699  options.reserve( mDataTypes.size() );
2700  for ( int t : mDataTypes )
2701  options << QStringLiteral( "QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( static_cast< QgsProcessing::SourceType >( t ) ) );
2702  code += QStringLiteral( ", types=[%1])" ).arg( options.join( ',' ) );
2703  }
2704  else
2705  {
2706  code += QLatin1Char( ')' );
2707  }
2708 
2709  return code;
2710  }
2711  }
2712  return QString();
2713 }
2714 
2716 {
2718  QVariantList types;
2719  for ( int type : mDataTypes )
2720  {
2721  types << type;
2722  }
2723  map.insert( QStringLiteral( "data_types" ), types );
2724  return map;
2725 }
2726 
2728 {
2730  mDataTypes.clear();
2731  const QVariantList values = map.value( QStringLiteral( "data_types" ) ).toList();
2732  for ( const QVariant &val : values )
2733  {
2734  mDataTypes << val.toInt();
2735  }
2736  return true;
2737 }
2738 
2739 QgsProcessingParameterExtent::QgsProcessingParameterExtent( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
2740  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
2741 {
2742 
2743 }
2744 
2746 {
2747  return new QgsProcessingParameterExtent( *this );
2748 }
2749 
2751 {
2752  if ( !input.isValid() )
2753  return mFlags & FlagOptional;
2754 
2755  if ( input.canConvert<QgsProcessingFeatureSourceDefinition>() )
2756  {
2757  return true;
2758  }
2759  else if ( input.canConvert<QgsProcessingOutputLayerDefinition>() )
2760  {
2761  return true;
2762  }
2763 
2764  if ( input.canConvert<QgsProperty>() )
2765  {
2766  return true;
2767  }
2768 
2769  if ( input.canConvert< QgsRectangle >() )
2770  {
2771  QgsRectangle r = input.value<QgsRectangle>();
2772  return !r.isNull();
2773  }
2774  if ( input.canConvert< QgsGeometry >() )
2775  {
2776  return true;
2777  }
2778  if ( input.canConvert< QgsReferencedRectangle >() )
2779  {
2781  return !r.isNull();
2782  }
2783 
2784  // direct map layer value
2785  if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2786  return true;
2787 
2788  if ( input.type() != QVariant::String || input.toString().isEmpty() )
2789  return mFlags & FlagOptional;
2790 
2791  if ( !context )
2792  {
2793  // that's as far as we can get without a context
2794  return true;
2795  }
2796 
2797  QRegularExpression rx( QStringLiteral( "^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
2798  QRegularExpressionMatch match = rx.match( input.toString() );
2799  if ( match.hasMatch() )
2800  {
2801  bool xMinOk = false;
2802  ( void )match.captured( 1 ).toDouble( &xMinOk );
2803  bool xMaxOk = false;
2804  ( void )match.captured( 2 ).toDouble( &xMaxOk );
2805  bool yMinOk = false;
2806  ( void )match.captured( 3 ).toDouble( &yMinOk );
2807  bool yMaxOk = false;
2808  ( void )match.captured( 4 ).toDouble( &yMaxOk );
2809  if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
2810  return true;
2811  }
2812 
2813  // try as layer extent
2814  return QgsProcessingUtils::mapLayerFromString( input.toString(), *context );
2815 }
2816 
2817 QString QgsProcessingParameterExtent::valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const
2818 {
2819  if ( !value.isValid() )
2820  return QStringLiteral( "None" );
2821 
2822  if ( value.canConvert<QgsProperty>() )
2823  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
2824 
2825  if ( value.canConvert< QgsRectangle >() )
2826  {
2827  QgsRectangle r = value.value<QgsRectangle>();
2828  return QStringLiteral( "'%1, %3, %2, %4'" ).arg( qgsDoubleToString( r.xMinimum() ),
2829  qgsDoubleToString( r.yMinimum() ),
2830  qgsDoubleToString( r.xMaximum() ),
2831  qgsDoubleToString( r.yMaximum() ) );
2832  }
2833  else if ( value.canConvert< QgsReferencedRectangle >() )
2834  {
2836  return QStringLiteral( "'%1, %3, %2, %4 [%5]'" ).arg( qgsDoubleToString( r.xMinimum() ),
2837  qgsDoubleToString( r.yMinimum() ),
2838  qgsDoubleToString( r.xMaximum() ),
2839  qgsDoubleToString( r.yMaximum() ), r.crs().authid() );
2840  }
2841  else if ( value.canConvert< QgsGeometry >() )
2842  {
2843  const QgsGeometry g = value.value<QgsGeometry>();
2844  if ( !g.isNull() )
2845  {
2846  const QString wkt = g.asWkt();
2847  return QStringLiteral( "QgsGeometry.fromWkt('%1')" ).arg( wkt );
2848  }
2849  }
2850 
2851  QVariantMap p;
2852  p.insert( name(), value );
2853  QgsMapLayer *layer = QgsProcessingParameters::parameterAsLayer( this, p, context );
2854  if ( layer )
2856 
2858 }
2859 
2860 QgsProcessingParameterExtent *QgsProcessingParameterExtent::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
2861 {
2862  return new QgsProcessingParameterExtent( name, description, definition, isOptional );
2863 }
2864 
2865 QgsProcessingParameterPoint::QgsProcessingParameterPoint( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
2866  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
2867 {
2868 
2869 }
2870 
2872 {
2873  return new QgsProcessingParameterPoint( *this );
2874 }
2875 
2877 {
2878  if ( !input.isValid() )
2879  return mFlags & FlagOptional;
2880 
2881  if ( input.canConvert<QgsProperty>() )
2882  {
2883  return true;
2884  }
2885 
2886  if ( input.canConvert< QgsPointXY >() )
2887  {
2888  return true;
2889  }
2890  if ( input.canConvert< QgsReferencedPointXY >() )
2891  {
2892  return true;
2893  }
2894  if ( input.canConvert< QgsGeometry >() )
2895  {
2896  return true;
2897  }
2898 
2899  if ( input.type() == QVariant::String )
2900  {
2901  if ( input.toString().isEmpty() )
2902  return mFlags & FlagOptional;
2903  }
2904 
2905  QRegularExpression rx( QStringLiteral( "^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2906 
2907  QRegularExpressionMatch match = rx.match( input.toString() );
2908  if ( match.hasMatch() )
2909  {
2910  bool xOk = false;
2911  ( void )match.captured( 1 ).toDouble( &xOk );
2912  bool yOk = false;
2913  ( void )match.captured( 2 ).toDouble( &yOk );
2914  return xOk && yOk;
2915  }
2916  else
2917  return false;
2918 }
2919 
2920 QString QgsProcessingParameterPoint::valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const
2921 {
2922  if ( !value.isValid() )
2923  return QStringLiteral( "None" );
2924 
2925  if ( value.canConvert<QgsProperty>() )
2926  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
2927 
2928  if ( value.canConvert< QgsPointXY >() )
2929  {
2930  QgsPointXY r = value.value<QgsPointXY>();
2931  return QStringLiteral( "'%1,%2'" ).arg( qgsDoubleToString( r.x() ),
2932  qgsDoubleToString( r.y() ) );
2933  }
2934  else if ( value.canConvert< QgsReferencedPointXY >() )
2935  {
2936  QgsReferencedPointXY r = value.value<QgsReferencedPointXY>();
2937  return QStringLiteral( "'%1,%2 [%3]'" ).arg( qgsDoubleToString( r.x() ),
2938  qgsDoubleToString( r.y() ),
2939  r.crs().authid() );
2940  }
2941  else if ( value.canConvert< QgsGeometry >() )
2942  {
2943  const QgsGeometry g = value.value<QgsGeometry>();
2944  if ( !g.isNull() )
2945  {
2946  const QString wkt = g.asWkt();
2947  return QStringLiteral( "QgsGeometry.fromWkt('%1')" ).arg( wkt );
2948  }
2949  }
2950 
2952 }
2953 
2954 QgsProcessingParameterPoint *QgsProcessingParameterPoint::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
2955 {
2956  return new QgsProcessingParameterPoint( name, description, definition, isOptional );
2957 }
2958 
2959 QgsProcessingParameterGeometry::QgsProcessingParameterGeometry( const QString &name, const QString &description,
2960  const QVariant &defaultValue, bool optional, const QList<int> &geometryTypes )
2961  : QgsProcessingParameterDefinition( name, description, defaultValue, optional ),
2962  mGeomTypes( geometryTypes )
2963 {
2964 
2965 }
2966 
2968 {
2969  return new QgsProcessingParameterGeometry( *this );
2970 }
2971 
2973 {
2974  if ( !input.isValid() )
2975  return mFlags & FlagOptional;
2976 
2977  if ( input.canConvert<QgsProperty>() )
2978  {
2979  return true;
2980  }
2981 
2982  bool anyTypeAllowed = mGeomTypes.isEmpty() || mGeomTypes.contains( QgsWkbTypes::UnknownGeometry );
2983 
2984  if ( input.canConvert< QgsGeometry >() )
2985  {
2986  return anyTypeAllowed || mGeomTypes.contains( input.value<QgsGeometry>().type() );
2987  }
2988 
2989  if ( input.canConvert< QgsReferencedGeometry >() )
2990  {
2991  return anyTypeAllowed || mGeomTypes.contains( input.value<QgsReferencedGeometry>().type() );
2992  }
2993 
2994  if ( input.canConvert< QgsPointXY >() )
2995  {
2996  return anyTypeAllowed || mGeomTypes.contains( QgsWkbTypes::PointGeometry );
2997  }
2998 
2999  if ( input.canConvert< QgsRectangle >() )
3000  {
3001  return anyTypeAllowed || mGeomTypes.contains( QgsWkbTypes::PolygonGeometry );
3002  }
3003 
3004  if ( input.canConvert< QgsReferencedPointXY >() )
3005  {
3006  return anyTypeAllowed || mGeomTypes.contains( QgsWkbTypes::PointGeometry );
3007  }
3008 
3009  if ( input.canConvert< QgsReferencedRectangle >() )
3010  {
3011  return anyTypeAllowed || mGeomTypes.contains( QgsWkbTypes::PolygonGeometry );
3012  }
3013 
3014  if ( input.type() == QVariant::String )
3015  {
3016  if ( input.toString().isEmpty() )
3017  return mFlags & FlagOptional;
3018  }
3019 
3020  // Match against EWKT
3021  QRegularExpression rx( QStringLiteral( "^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3022 
3023  QRegularExpressionMatch match = rx.match( input.toString() );
3024  if ( match.hasMatch() )
3025  {
3026  QgsGeometry g = QgsGeometry::fromWkt( match.captured( 2 ) );
3027  if ( ! g.isNull() )
3028  {
3029  return anyTypeAllowed || mGeomTypes.contains( g.type() );
3030  }
3031  else
3032  {
3033  QgsMessageLog::logMessage( QObject::tr( "Error creating geometry: \"%1\"" ).arg( g.lastError() ), QObject::tr( "Processing" ) );
3034  }
3035  }
3036  return false;
3037 }
3038 
3039 QString QgsProcessingParameterGeometry::valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const
3040 {
3042  {
3043  if ( !crs.isValid() )
3045  else
3046  return QgsProcessingUtils::stringToPythonLiteral( QStringLiteral( "CRS=%1;%2" ).arg( crs.authid().isEmpty() ? crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) : crs.authid(), g.asWkt() ) );
3047  };
3048 
3049  if ( !value.isValid() )
3050  return QStringLiteral( "None" );
3051 
3052  if ( value.canConvert<QgsProperty>() )
3053  return QStringLiteral( "QgsProperty.fromExpression(%1)" ).arg( QgsProcessingUtils::stringToPythonLiteral( value.value< QgsProperty >().asExpression() ) );
3054 
3055  if ( value.canConvert< QgsGeometry >() )
3056  {
3057  const QgsGeometry g = value.value<QgsGeometry>();
3058  if ( !g.isNull() )
3059  return asPythonString( g );
3060  }
3061 
3062  if ( value.canConvert< QgsReferencedGeometry >() )
3063  {
3064  const QgsReferencedGeometry g = value.value<QgsReferencedGeometry>();
3065  if ( !g.isNull() )
3066  return asPythonString( g, g.crs() );
3067  }
3068 
3069  if ( value.canConvert< QgsPointXY >() )
3070  {
3071  const QgsGeometry g = QgsGeometry::fromPointXY( value.value<QgsPointXY>() );
3072  if ( !g.isNull() )
3073  return asPythonString( g );
3074  }
3075 
3076  if ( value.canConvert< QgsReferencedPointXY >() )
3077  {
3079  if ( !g.isNull() )
3080  return asPythonString( g, g.crs() );
3081  }
3082 
3083  if ( value.canConvert< QgsRectangle >() )
3084  {
3085  const QgsGeometry g = QgsGeometry::fromRect( value.value<QgsRectangle>() );
3086  if ( !g.isNull() )
3087  return asPythonString( g );
3088  }
3089 
3090  if ( value.canConvert< QgsReferencedRectangle >() )
3091  {
3093  if ( !g.isNull() )
3094  return asPythonString( g, g.crs() );
3095  }
3096 
3098 }
3099 
3101 {
3102  QString code = QStringLiteral( "##%1=" ).arg( mName );
3103  if ( mFlags & FlagOptional )
3104  code += QLatin1String( "optional " );
3105  code += type() + ' ';
3106 
3107  for ( int type : mGeomTypes )
3108  {
3109  switch ( static_cast<QgsWkbTypes::GeometryType>( type ) )
3110  {
3112  code += QLatin1String( "point " );
3113  break;
3114 
3116  code += QLatin1String( "line " );
3117  break;
3118 
3120  code += QLatin1String( "polygon " );
3121  break;
3122 
3123  default:
3124  code += QLatin1String( "unknown" );
3125  break;
3126  }
3127  }
3128 
3129  code += mDefault.toString();
3130  return code.trimmed();
3131 }
3132 
3134 {
3135  switch ( outputType )
3136  {
3138  {
3139  QString code = QStringLiteral( "QgsProcessingParameterGeometry('%1', '%2'" ).arg( name(), description() );
3140  if ( mFlags & FlagOptional )
3141  code += QLatin1String( ", optional=True" );
3142 
3143  if ( !mGeomTypes.empty() )
3144  {
3145  auto geomTypeToString = []( QgsWkbTypes::GeometryType t ) -> QString
3146  {
3147  switch ( t )
3148  {
3150  return QStringLiteral( "PointGeometry" );
3151 
3153  return QStringLiteral( "LineGeometry" );
3154 
3156  return QStringLiteral( "PolygonGeometry" );
3157 
3159  return QStringLiteral( "UnknownGeometry" );
3160 
3162  return QStringLiteral( "NullGeometry" );
3163  }
3164  return QString();
3165  };
3166 
3167  QStringList options;
3168  options.reserve( mGeomTypes.size() );
3169  for ( int type : mGeomTypes )
3170  {
3171  options << QStringLiteral( " QgsWkbTypes.%1" ).arg( geomTypeToString( static_cast<QgsWkbTypes::GeometryType>( type ) ) );
3172  }
3173  code += QStringLiteral( ", geometryTypes=[%1 ]" ).arg( options.join( ',' ) );
3174  }
3175 
3177  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
3178  return code;
3179  }
3180  }
3181  return QString();
3182 }
3183 
3185 {
3187  QVariantList types;
3188  for ( int type : mGeomTypes )
3189  {
3190  types << type;
3191  }
3192  map.insert( QStringLiteral( "geometrytypes" ), types );
3193  return map;
3194 }
3195 
3197 {
3199  mGeomTypes.clear();
3200  const QVariantList values = map.value( QStringLiteral( "geometrytypes" ) ).toList();
3201  for ( const QVariant &val : values )
3202  {
3203  mGeomTypes << val.toInt();
3204  }
3205  return true;
3206 }
3207 
3208 QgsProcessingParameterGeometry *QgsProcessingParameterGeometry::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
3209 {
3210  return new QgsProcessingParameterGeometry( name, description, definition, isOptional );
3211 }
3212 
3213 QgsProcessingParameterFile::QgsProcessingParameterFile( const QString &name, const QString &description, Behavior behavior, const QString &extension, const QVariant &defaultValue, bool optional, const QString &fileFilter )
3214  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
3215  , mBehavior( behavior )
3216  , mExtension( fileFilter.isEmpty() ? extension : QString() )
3217  , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr( "All files (*.*)" ) : fileFilter )
3218 {
3219 
3220 }
3221 
3223 {
3224  return new QgsProcessingParameterFile( *this );
3225 }
3226 
3228 {
3229  if ( !input.isValid() )
3230  return mFlags & FlagOptional;
3231 
3232  if ( input.canConvert<QgsProperty>() )
3233  {
3234  return true;
3235  }
3236 
3237  QString string = input.toString().trimmed();
3238 
3239  if ( input.type() != QVariant::String || string.isEmpty() )
3240  return mFlags & FlagOptional;
3241 
3242  switch ( mBehavior )
3243  {
3244  case File:
3245  {
3246  if ( !mExtension.isEmpty() )
3247  {
3248  return string.endsWith( mExtension, Qt::CaseInsensitive );
3249  }
3250  else if ( !mFileFilter.isEmpty() )
3251  {
3252  const QString test = QgsFileUtils::addExtensionFromFilter( string, mFileFilter );
3253  return test == string;
3254  }
3255  else
3256  {
3257  return true;
3258  }
3259  }
3260 
3261  case Folder:
3262  return true;
3263  }
3264  return true;
3265 }
3266 
3268 {
3269  QString code = QStringLiteral( "##%1=" ).arg( mName );
3270  if ( mFlags & FlagOptional )
3271  code += QLatin1String( "optional " );
3272  code += ( mBehavior == File ? QStringLiteral( "file" ) : QStringLiteral( "folder" ) ) + ' ';
3273  code += mDefault.toString();
3274  return code.trimmed();
3275 }
3276 
3278 {
3279  switch ( outputType )
3280  {
3282  {
3283 
3284  QString code = QStringLiteral( "QgsProcessingParameterFile('%1', '%2'" ).arg( name(), description() );
3285  if ( mFlags & FlagOptional )
3286  code += QLatin1String( ", optional=True" );
3287  code += QStringLiteral( ", behavior=%1" ).arg( mBehavior == File ? QStringLiteral( "QgsProcessingParameterFile.File" ) : QStringLiteral( "QgsProcessingParameterFile.Folder" ) );
3288  if ( !mExtension.isEmpty() )
3289  code += QStringLiteral( ", extension='%1'" ).arg( mExtension );
3290  if ( !mFileFilter.isEmpty() )
3291  code += QStringLiteral( ", fileFilter='%1'" ).arg( mFileFilter );
3293  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
3294  return code;
3295  }
3296  }
3297  return QString();
3298 }
3299 
3300 void QgsProcessingParameterFile::setExtension( const QString &extension )
3301 {
3302  mExtension = extension;
3303  mFileFilter.clear();
3304 }
3305 
3307 {
3308  return mFileFilter;
3309 }
3310 
3311 void QgsProcessingParameterFile::setFileFilter( const QString &filter )
3312 {
3313  mFileFilter = filter;
3314  mExtension.clear();
3315 }
3316 
3318 {
3320  map.insert( QStringLiteral( "behavior" ), mBehavior );
3321  map.insert( QStringLiteral( "extension" ), mExtension );
3322  map.insert( QStringLiteral( "filefilter" ), mFileFilter );
3323  return map;
3324 }
3325 
3326 bool QgsProcessingParameterFile::fromVariantMap( const QVariantMap &map )
3327 {
3329  mBehavior = static_cast< Behavior >( map.value( QStringLiteral( "behavior" ) ).toInt() );
3330  mExtension = map.value( QStringLiteral( "extension" ) ).toString();
3331  mFileFilter = map.value( QStringLiteral( "filefilter" ) ).toString();
3332  return true;
3333 }
3334 
3335 QgsProcessingParameterFile *QgsProcessingParameterFile::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition, QgsProcessingParameterFile::Behavior behavior )
3336 {
3337  return new QgsProcessingParameterFile( name, description, behavior, QString(), definition, isOptional );
3338 }
3339 
3340 QgsProcessingParameterMatrix::QgsProcessingParameterMatrix( const QString &name, const QString &description, int numberRows, bool fixedNumberRows, const QStringList &headers, const QVariant &defaultValue, bool optional )
3341  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
3342  , mHeaders( headers )
3343  , mNumberRows( numberRows )
3344  , mFixedNumberRows( fixedNumberRows )
3345 {
3346 
3347 }
3348 
3350 {
3351  return new QgsProcessingParameterMatrix( *this );
3352 }
3353 
3355 {
3356  if ( !input.isValid() )
3357  return mFlags & FlagOptional;
3358 
3359  if ( input.type() == QVariant::String )
3360  {
3361  if ( input.toString().isEmpty() )
3362  return mFlags & FlagOptional;
3363  return true;
3364  }
3365  else if ( input.type() == QVariant::List )
3366  {
3367  if ( input.toList().isEmpty() )
3368  return mFlags & FlagOptional;
3369  return true;
3370  }
3371  else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
3372  {
3373  return true;
3374  }
3375 
3376  return false;
3377 }
3378 
3379 QString QgsProcessingParameterMatrix::valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const
3380 {
3381  if ( !value.isValid() )
3382  return QStringLiteral( "None" );
3383 
3384  if ( value.canConvert<QgsProperty>() )
3385  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
3386 
3387  QVariantMap p;
3388  p.insert( name(), value );
3389  QVariantList list = QgsProcessingParameters::parameterAsMatrix( this, p, context );
3390 
3391  QStringList parts;
3392  const auto constList = list;
3393  for ( const QVariant &v : constList )
3394  {
3395  if ( v.type() == QVariant::List )
3396  {
3397  QStringList parts2;
3398  const auto constToList = v.toList();
3399  for ( const QVariant &v2 : constToList )
3400  {
3401  if ( v2.isNull() || !v2.isValid() )
3402  parts2 << QStringLiteral( "None" );
3403  else if ( v2.toString().isEmpty() )
3404  parts2 << QStringLiteral( "''" );
3405  else
3406  parts2 << v2.toString();
3407  }
3408  parts << parts2.join( ',' ).prepend( '[' ).append( ']' );
3409  }
3410  else
3411  {
3412  if ( v.isNull() || !v.isValid() )
3413  parts << QStringLiteral( "None" );
3414  else if ( v.toString().isEmpty() )
3415  parts << QStringLiteral( "''" );
3416  else
3417  parts << v.toString();
3418  }
3419  }
3420 
3421  return parts.join( ',' ).prepend( '[' ).append( ']' );
3422 }
3423 
3425 {
3426  switch ( outputType )
3427  {
3429  {
3430  QString code = QStringLiteral( "QgsProcessingParameterMatrix('%1', '%2'" ).arg( name(), description() );
3431  if ( mFlags & FlagOptional )
3432  code += QLatin1String( ", optional=True" );
3433  code += QStringLiteral( ", numberRows=" ).arg( mNumberRows );
3434  code += QStringLiteral( ", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
3435 
3436  QStringList headers;
3437  headers.reserve( mHeaders.size() );
3438  for ( const QString &h : mHeaders )
3440  code += QStringLiteral( ", headers=[%1]" ).arg( headers.join( ',' ) );
3441 
3443  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
3444  return code;
3445  }
3446  }
3447  return QString();
3448 }
3449 
3451 {
3452  return mHeaders;
3453 }
3454 
3455 void QgsProcessingParameterMatrix::setHeaders( const QStringList &headers )
3456 {
3457  mHeaders = headers;
3458 }
3459 
3461 {
3462  return mNumberRows;
3463 }
3464 
3466 {
3467  mNumberRows = numberRows;
3468 }
3469 
3471 {
3472  return mFixedNumberRows;
3473 }
3474 
3476 {
3477  mFixedNumberRows = fixedNumberRows;
3478 }
3479 
3481 {
3483  map.insert( QStringLiteral( "headers" ), mHeaders );
3484  map.insert( QStringLiteral( "rows" ), mNumberRows );
3485  map.insert( QStringLiteral( "fixed_number_rows" ), mFixedNumberRows );
3486  return map;
3487 }
3488 
3489 bool QgsProcessingParameterMatrix::fromVariantMap( const QVariantMap &map )
3490 {
3492  mHeaders = map.value( QStringLiteral( "headers" ) ).toStringList();
3493  mNumberRows = map.value( QStringLiteral( "rows" ) ).toInt();
3494  mFixedNumberRows = map.value( QStringLiteral( "fixed_number_rows" ) ).toBool();
3495  return true;
3496 }
3497 
3498 QgsProcessingParameterMatrix *QgsProcessingParameterMatrix::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
3499 {
3500  return new QgsProcessingParameterMatrix( name, description, 0, false, QStringList(), definition.isEmpty() ? QVariant() : definition, isOptional );
3501 }
3502 
3503 QgsProcessingParameterMultipleLayers::QgsProcessingParameterMultipleLayers( const QString &name, const QString &description, QgsProcessing::SourceType layerType, const QVariant &defaultValue, bool optional )
3504  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
3505  , mLayerType( layerType )
3506 {
3507 
3508 }
3509 
3511 {
3512  return new QgsProcessingParameterMultipleLayers( *this );
3513 }
3514 
3516 {
3517  if ( !input.isValid() )
3518  return mFlags & FlagOptional;
3519 
3520  if ( mLayerType != QgsProcessing::TypeFile )
3521  {
3522  if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3523  {
3524  return true;
3525  }
3526  }
3527 
3528  if ( input.type() == QVariant::String )
3529  {
3530  if ( input.toString().isEmpty() )
3531  return mFlags & FlagOptional;
3532 
3533  if ( mMinimumNumberInputs > 1 )
3534  return false;
3535 
3536  if ( !context )
3537  return true;
3538 
3539  if ( mLayerType != QgsProcessing::TypeFile )
3540  return QgsProcessingUtils::mapLayerFromString( input.toString(), *context );
3541  else
3542  return true;
3543  }
3544  else if ( input.type() == QVariant::List )
3545  {
3546  if ( input.toList().count() < mMinimumNumberInputs )
3547  return mFlags & FlagOptional;
3548 
3549  if ( mMinimumNumberInputs > input.toList().count() )
3550  return false;
3551 
3552  if ( !context )
3553  return true;
3554 
3555  if ( mLayerType != QgsProcessing::TypeFile )
3556  {
3557  const auto constToList = input.toList();
3558  for ( const QVariant &v : constToList )
3559  {
3560  if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
3561  continue;
3562 
3563  if ( !QgsProcessingUtils::mapLayerFromString( v.toString(), *context ) )
3564  return false;
3565  }
3566  }
3567  return true;
3568  }
3569  else if ( input.type() == QVariant::StringList )
3570  {
3571  if ( input.toStringList().count() < mMinimumNumberInputs )
3572  return mFlags & FlagOptional;
3573 
3574  if ( mMinimumNumberInputs > input.toStringList().count() )
3575  return false;
3576 
3577  if ( !context )
3578  return true;
3579 
3580  if ( mLayerType != QgsProcessing::TypeFile )
3581  {
3582  const auto constToStringList = input.toStringList();
3583  for ( const QString &v : constToStringList )
3584  {
3585  if ( !QgsProcessingUtils::mapLayerFromString( v, *context ) )
3586  return false;
3587  }
3588  }
3589  return true;
3590  }
3591  return false;
3592 }
3593 
3595 {
3596  if ( !value.isValid() )
3597  return QStringLiteral( "None" );
3598 
3599  if ( value.canConvert<QgsProperty>() )
3600  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
3601 
3602  if ( mLayerType == QgsProcessing::TypeFile )
3603  {
3604  QStringList parts;
3605  if ( value.type() == QVariant::StringList )
3606  {
3607  const QStringList list = value.toStringList();
3608  parts.reserve( list.count() );
3609  for ( const QString &v : list )
3611  }
3612  else if ( value.type() == QVariant::List )
3613  {
3614  const QVariantList list = value.toList();
3615  parts.reserve( list.count() );
3616  for ( const QVariant &v : list )
3617  parts << QgsProcessingUtils::stringToPythonLiteral( v.toString() );
3618  }
3619  if ( !parts.isEmpty() )
3620  return parts.join( ',' ).prepend( '[' ).append( ']' );
3621  }
3622  else
3623  {
3624  QVariantMap p;
3625  p.insert( name(), value );
3626  const QList<QgsMapLayer *> list = QgsProcessingParameters::parameterAsLayerList( this, p, context );
3627  if ( !list.isEmpty() )
3628  {
3629  QStringList parts;
3630  parts.reserve( list.count() );
3631  for ( const QgsMapLayer *layer : list )
3632  {
3634  }
3635  return parts.join( ',' ).prepend( '[' ).append( ']' );
3636  }
3637  }
3638 
3640 }
3641 
3643 {
3644  QString code = QStringLiteral( "##%1=" ).arg( mName );
3645  if ( mFlags & FlagOptional )
3646  code += QLatin1String( "optional " );
3647  switch ( mLayerType )
3648  {
3650  code += QLatin1String( "multiple raster" );
3651  break;
3652 
3654  code += QLatin1String( "multiple file" );
3655  break;
3656 
3657  default:
3658  code += QLatin1String( "multiple vector" );
3659  break;
3660  }
3661  code += ' ';
3662  if ( mDefault.type() == QVariant::List )
3663  {
3664  QStringList parts;
3665  const auto constToList = mDefault.toList();
3666  for ( const QVariant &var : constToList )
3667  {
3668  parts << var.toString();
3669  }
3670  code += parts.join( ',' );
3671  }
3672  else if ( mDefault.type() == QVariant::StringList )
3673  {
3674  code += mDefault.toStringList().join( ',' );
3675  }
3676  else
3677  {
3678  code += mDefault.toString();
3679  }
3680  return code.trimmed();
3681 }
3682 
3684 {
3685  switch ( outputType )
3686  {
3688  {
3689  QString code = QStringLiteral( "QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg( name(), description() );
3690  if ( mFlags & FlagOptional )
3691  code += QLatin1String( ", optional=True" );
3692 
3693  QString layerType = QStringLiteral( "QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( mLayerType ) );
3694 
3695  code += QStringLiteral( ", layerType=%1" ).arg( layerType );
3697  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
3698  return code;
3699  }
3700  }
3701  return QString();
3702 }
3703 
3705 {
3706  QStringList exts;
3707  switch ( mLayerType )
3708  {
3710  return QObject::tr( "All files (*.*)" );
3711 
3713  return QgsProviderRegistry::instance()->fileRasterFilters() + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
3714 
3720  return QgsProviderRegistry::instance()->fileVectorFilters() + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
3721 
3723  return QgsProviderRegistry::instance()->fileMeshFilters() + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
3724 
3726  return createAllMapLayerFileFilter();
3727  }
3728  return QString();
3729 }
3730 
3732 {
3733  return mLayerType;
3734 }
3735 
3737 {
3738  mLayerType = type;
3739 }
3740 
3742 {
3743  return mMinimumNumberInputs;
3744 }
3745 
3747 {
3748  if ( mMinimumNumberInputs >= 1 || !( flags() & QgsProcessingParameterDefinition::FlagOptional ) )
3749  mMinimumNumberInputs = minimumNumberInputs;
3750 }
3751 
3753 {
3755  map.insert( QStringLiteral( "layer_type" ), mLayerType );
3756  map.insert( QStringLiteral( "min_inputs" ), mMinimumNumberInputs );
3757  return map;
3758 }
3759 
3761 {
3763  mLayerType = static_cast< QgsProcessing::SourceType >( map.value( QStringLiteral( "layer_type" ) ).toInt() );
3764  mMinimumNumberInputs = map.value( QStringLiteral( "min_inputs" ) ).toInt();
3765  return true;
3766 }
3767 
3768 QgsProcessingParameterMultipleLayers *QgsProcessingParameterMultipleLayers::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
3769 {
3770  QString type = definition;
3771  QString defaultVal;
3772  QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*)" ) );
3773  QRegularExpressionMatch m = re.match( definition );
3774  if ( m.hasMatch() )
3775  {
3776  type = m.captured( 1 ).toLower().trimmed();
3777  defaultVal = m.captured( 2 );
3778  }
3780  if ( type == QLatin1String( "vector" ) )
3782  else if ( type == QLatin1String( "raster" ) )
3784  else if ( type == QLatin1String( "file" ) )
3786  return new QgsProcessingParameterMultipleLayers( name, description, layerType, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
3787 }
3788 
3789 QgsProcessingParameterNumber::QgsProcessingParameterNumber( const QString &name, const QString &description, Type type, const QVariant &defaultValue, bool optional, double minValue, double maxValue )
3790  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
3791  , mMin( minValue )
3792  , mMax( maxValue )
3793  , mDataType( type )
3794 {
3795  if ( mMin >= mMax )
3796  {
3797  QgsMessageLog::logMessage( QObject::tr( "Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg( name ).arg( mMin ).arg( mMax ), QObject::tr( "Processing" ) );
3798  }
3799 }
3800 
3802 {
3803  return new QgsProcessingParameterNumber( *this );
3804 }
3805 
3807 {
3808  QVariant input = value;
3809  if ( !input.isValid() )
3810  {
3811  if ( !defaultValue().isValid() )
3812  return mFlags & FlagOptional;
3813 
3814  input = defaultValue();
3815  }
3816 
3817  if ( input.canConvert<QgsProperty>() )
3818  {
3819  return true;
3820  }
3821 
3822  bool ok = false;
3823  double res = input.toDouble( &ok );
3824  if ( !ok )
3825  return mFlags & FlagOptional;
3826 
3827  return !( res < mMin || res > mMax );
3828 }
3829 
3831 {
3832  if ( !value.isValid() )
3833  return QStringLiteral( "None" );
3834 
3835  if ( value.canConvert<QgsProperty>() )
3836  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
3837 
3838  return value.toString();
3839 }
3840 
3842 {
3844  QStringList parts;
3845  if ( mMin > std::numeric_limits<double>::lowest() + 1 )
3846  parts << QObject::tr( "Minimum value: %1" ).arg( mMin );
3847  if ( mMax < std::numeric_limits<double>::max() )
3848  parts << QObject::tr( "Maximum value: %1" ).arg( mMax );
3849  if ( mDefault.isValid() )
3850  parts << QObject::tr( "Default value: %1" ).arg( mDataType == Integer ? mDefault.toInt() : mDefault.toDouble() );
3851  QString extra = parts.join( QLatin1String( "<br />" ) );
3852  if ( !extra.isEmpty() )
3853  text += QStringLiteral( "<p>%1</p>" ).arg( extra );
3854  return text;
3855 }
3856 
3858 {
3859  switch ( outputType )
3860  {
3862  {
3863  QString code = QStringLiteral( "QgsProcessingParameterNumber('%1', '%2'" ).arg( name(), description() );
3864  if ( mFlags & FlagOptional )
3865  code += QLatin1String( ", optional=True" );
3866 
3867  code += QStringLiteral( ", type=%1" ).arg( mDataType == Integer ? QStringLiteral( "QgsProcessingParameterNumber.Integer" ) : QStringLiteral( "QgsProcessingParameterNumber.Double" ) );
3868 
3869  if ( mMin != std::numeric_limits<double>::lowest() + 1 )
3870  code += QStringLiteral( ", minValue=%1" ).arg( mMin );
3871  if ( mMax != std::numeric_limits<double>::max() )
3872  code += QStringLiteral( ", maxValue=%1" ).arg( mMax );
3874  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
3875  return code;
3876  }
3877  }
3878  return QString();
3879 }
3880 
3882 {
3883  return mMin;
3884 }
3885 
3887 {
3888  mMin = min;
3889 }
3890 
3892 {
3893  return mMax;
3894 }
3895 
3897 {
3898  mMax = max;
3899 }
3900 
3902 {
3903  return mDataType;
3904 }
3905 
3907 {
3908  mDataType = dataType;
3909 }
3910 
3912 {
3914  map.insert( QStringLiteral( "min" ), mMin );
3915  map.insert( QStringLiteral( "max" ), mMax );
3916  map.insert( QStringLiteral( "data_type" ), mDataType );
3917  return map;
3918 }
3919 
3920 bool QgsProcessingParameterNumber::fromVariantMap( const QVariantMap &map )
3921 {
3923  mMin = map.value( QStringLiteral( "min" ) ).toDouble();
3924  mMax = map.value( QStringLiteral( "max" ) ).toDouble();
3925  mDataType = static_cast< Type >( map.value( QStringLiteral( "data_type" ) ).toInt() );
3926  return true;
3927 }
3928 
3929 QgsProcessingParameterNumber *QgsProcessingParameterNumber::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
3930 {
3931  return new QgsProcessingParameterNumber( name, description, Double, definition.isEmpty() ? QVariant()
3932  : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
3933 }
3934 
3935 QgsProcessingParameterRange::QgsProcessingParameterRange( const QString &name, const QString &description, QgsProcessingParameterNumber::Type type, const QVariant &defaultValue, bool optional )
3936  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
3937  , mDataType( type )
3938 {
3939 
3940 }
3941 
3943 {
3944  return new QgsProcessingParameterRange( *this );
3945 }
3946 
3948 {
3949  if ( !input.isValid() )
3950  return mFlags & FlagOptional;
3951 
3952  if ( input.canConvert<QgsProperty>() )
3953  {
3954  return true;
3955  }
3956 
3957  if ( input.type() == QVariant::String )
3958  {
3959  QStringList list = input.toString().split( ',' );
3960  if ( list.count() != 2 )
3961  return mFlags & FlagOptional;
3962  bool ok = false;
3963  list.at( 0 ).toDouble( &ok );
3964  bool ok2 = false;
3965  list.at( 1 ).toDouble( &ok2 );
3966  if ( !ok || !ok2 )
3967  return mFlags & FlagOptional;
3968  return true;
3969  }
3970  else if ( input.type() == QVariant::List )
3971  {
3972  if ( input.toList().count() != 2 )
3973  return mFlags & FlagOptional;
3974 
3975  bool ok = false;
3976  input.toList().at( 0 ).toDouble( &ok );
3977  bool ok2 = false;
3978  input.toList().at( 1 ).toDouble( &ok2 );
3979  if ( !ok || !ok2 )
3980  return mFlags & FlagOptional;
3981  return true;
3982  }
3983 
3984  return false;
3985 }
3986 
3987 QString QgsProcessingParameterRange::valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const
3988 {
3989  if ( !value.isValid() )
3990  return QStringLiteral( "None" );
3991 
3992  if ( value.canConvert<QgsProperty>() )
3993  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
3994 
3995  QVariantMap p;
3996  p.insert( name(), value );
3997  QList< double > parts = QgsProcessingParameters::parameterAsRange( this, p, context );
3998 
3999  QStringList stringParts;
4000  const auto constParts = parts;
4001  for ( double v : constParts )
4002  {
4003  stringParts << QString::number( v );
4004  }
4005  return stringParts.join( ',' ).prepend( '[' ).append( ']' );
4006 }
4007 
4009 {
4010  switch ( outputType )
4011  {
4013  {
4014  QString code = QStringLiteral( "QgsProcessingParameterRange('%1', '%2'" ).arg( name(), description() );
4015  if ( mFlags & FlagOptional )
4016  code += QLatin1String( ", optional=True" );
4017 
4018  code += QStringLiteral( ", type=%1" ).arg( mDataType == QgsProcessingParameterNumber::Integer ? QStringLiteral( "QgsProcessingParameterNumber.Integer" ) : QStringLiteral( "QgsProcessingParameterNumber.Double" ) );
4019 
4021  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
4022  return code;
4023  }
4024  }
4025  return QString();
4026 }
4027 
4029 {
4030  return mDataType;
4031 }
4032 
4034 {
4035  mDataType = dataType;
4036 }
4037 
4039 {
4041  map.insert( QStringLiteral( "data_type" ), mDataType );
4042  return map;
4043 }
4044 
4045 bool QgsProcessingParameterRange::fromVariantMap( const QVariantMap &map )
4046 {
4048  mDataType = static_cast< QgsProcessingParameterNumber::Type >( map.value( QStringLiteral( "data_type" ) ).toInt() );
4049  return true;
4050 }
4051 
4052 QgsProcessingParameterRange *QgsProcessingParameterRange::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4053 {
4054  return new QgsProcessingParameterRange( name, description, QgsProcessingParameterNumber::Double, definition.isEmpty() ? QVariant()
4055  : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
4056 }
4057 
4058 QgsProcessingParameterRasterLayer::QgsProcessingParameterRasterLayer( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
4059  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4060 {
4061 
4062 }
4063 
4065 {
4066  return new QgsProcessingParameterRasterLayer( *this );
4067 }
4068 
4070 {
4071  if ( !input.isValid() )
4072  return mFlags & FlagOptional;
4073 
4074  if ( input.canConvert<QgsProperty>() )
4075  {
4076  return true;
4077  }
4078 
4079  if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4080  return true;
4081 
4082  if ( input.type() != QVariant::String || input.toString().isEmpty() )
4083  return mFlags & FlagOptional;
4084 
4085  if ( !context )
4086  {
4087  // that's as far as we can get without a context
4088  return true;
4089  }
4090 
4091  // try to load as layer
4092  if ( QgsProcessingUtils::mapLayerFromString( input.toString(), *context, true, QgsProcessingUtils::LayerHint::Raster ) )
4093  return true;
4094 
4095  return false;
4096 }
4097 
4099 {
4100  if ( !val.isValid() )
4101  return QStringLiteral( "None" );
4102 
4103  if ( val.canConvert<QgsProperty>() )
4104  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( val.value< QgsProperty >().asExpression() );
4105 
4106  QVariantMap p;
4107  p.insert( name(), val );
4110  : QgsProcessingUtils::stringToPythonLiteral( val.toString() );
4111 }
4112 
4114 {
4115  return QgsProviderRegistry::instance()->fileRasterFilters() + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
4116 }
4117 
4118 QgsProcessingParameterRasterLayer *QgsProcessingParameterRasterLayer::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4119 {
4120  return new QgsProcessingParameterRasterLayer( name, description, definition.isEmpty() ? QVariant() : definition, isOptional );
4121 }
4122 
4123 QgsProcessingParameterEnum::QgsProcessingParameterEnum( const QString &name, const QString &description, const QStringList &options, bool allowMultiple, const QVariant &defaultValue, bool optional )
4124  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4125  , mOptions( options )
4126  , mAllowMultiple( allowMultiple )
4127 {
4128 
4129 }
4130 
4132 {
4133  return new QgsProcessingParameterEnum( *this );
4134 }
4135 
4137 {
4138  QVariant input = value;
4139  if ( !input.isValid() )
4140  {
4141  if ( !defaultValue().isValid() )
4142  return mFlags & FlagOptional;
4143 
4144  input = defaultValue();
4145  }
4146 
4147  if ( input.canConvert<QgsProperty>() )
4148  {
4149  return true;
4150  }
4151 
4152  if ( input.type() == QVariant::List )
4153  {
4154  if ( !mAllowMultiple )
4155  return false;
4156 
4157  const QVariantList values = input.toList();
4158  if ( values.empty() && !( mFlags & FlagOptional ) )
4159  return false;
4160 
4161  for ( const QVariant &val : values )
4162  {
4163  bool ok = false;
4164  int res = val.toInt( &ok );
4165  if ( !ok )
4166  return false;
4167  else if ( res < 0 || res >= mOptions.count() )
4168  return false;
4169  }
4170 
4171  return true;
4172  }
4173  else if ( input.type() == QVariant::String )
4174  {
4175  QStringList parts = input.toString().split( ',' );
4176  if ( parts.count() > 1 && !mAllowMultiple )
4177  return false;
4178 
4179  const auto constParts = parts;
4180  for ( const QString &part : constParts )
4181  {
4182  bool ok = false;
4183  int res = part.toInt( &ok );
4184  if ( !ok )
4185  return false;
4186  else if ( res < 0 || res >= mOptions.count() )
4187  return false;
4188  }
4189  return true;
4190  }
4191  else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
4192  {
4193  bool ok = false;
4194  int res = input.toInt( &ok );
4195  if ( !ok )
4196  return false;
4197  else if ( res >= 0 && res < mOptions.count() )
4198  return true;
4199  }
4200  return false;
4201 }
4202 
4204 {
4205  if ( !value.isValid() )
4206  return QStringLiteral( "None" );
4207 
4208  if ( value.canConvert<QgsProperty>() )
4209  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
4210 
4211  if ( value.type() == QVariant::List )
4212  {
4213  QStringList parts;
4214  const auto constToList = value.toList();
4215  for ( const QVariant &val : constToList )
4216  {
4217  parts << QString::number( static_cast< int >( val.toDouble() ) );
4218  }
4219  return parts.join( ',' ).prepend( '[' ).append( ']' );
4220  }
4221  else if ( value.type() == QVariant::String )
4222  {
4223  QStringList parts = value.toString().split( ',' );
4224  if ( parts.count() > 1 )
4225  {
4226  return parts.join( ',' ).prepend( '[' ).append( ']' );
4227  }
4228  }
4229 
4230  return QString::number( static_cast< int >( value.toDouble() ) );
4231 }
4232 
4234 {
4235  QString code = QStringLiteral( "##%1=" ).arg( mName );
4236  if ( mFlags & FlagOptional )
4237  code += QLatin1String( "optional " );
4238  code += QLatin1String( "enum " );
4239 
4240  if ( mAllowMultiple )
4241  code += QLatin1String( "multiple " );
4242 
4243  code += mOptions.join( ';' ) + ' ';
4244 
4245  code += mDefault.toString();
4246  return code.trimmed();
4247 }
4248 
4250 {
4251  switch ( outputType )
4252  {
4254  {
4255  QString code = QStringLiteral( "QgsProcessingParameterEnum('%1', '%2'" ).arg( name(), description() );
4256  if ( mFlags & FlagOptional )
4257  code += QLatin1String( ", optional=True" );
4258 
4259  QStringList options;
4260  options.reserve( mOptions.size() );
4261  for ( const QString &o : mOptions )
4263  code += QStringLiteral( ", options=[%1]" ).arg( options.join( ',' ) );
4264 
4265  code += QStringLiteral( ", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
4266 
4268  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
4269  return code;
4270  }
4271  }
4272  return QString();
4273 }
4274 
4276 {
4277  return mOptions;
4278 }
4279 
4280 void QgsProcessingParameterEnum::setOptions( const QStringList &options )
4281 {
4282  mOptions = options;
4283 }
4284 
4286 {
4287  return mAllowMultiple;
4288 }
4289 
4291 {
4292  mAllowMultiple = allowMultiple;
4293 }
4294 
4296 {
4298  map.insert( QStringLiteral( "options" ), mOptions );
4299  map.insert( QStringLiteral( "allow_multiple" ), mAllowMultiple );
4300  return map;
4301 }
4302 
4303 bool QgsProcessingParameterEnum::fromVariantMap( const QVariantMap &map )
4304 {
4306  mOptions = map.value( QStringLiteral( "options" ) ).toStringList();
4307  mAllowMultiple = map.value( QStringLiteral( "allow_multiple" ) ).toBool();
4308  return true;
4309 }
4310 
4311 QgsProcessingParameterEnum *QgsProcessingParameterEnum::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4312 {
4313  QString defaultVal;
4314  bool multiple = false;
4315  QString def = definition;
4316  if ( def.startsWith( QLatin1String( "multiple" ), Qt::CaseInsensitive ) )
4317  {
4318  multiple = true;
4319  def = def.mid( 9 );
4320  }
4321 
4322  QRegularExpression re( QStringLiteral( "(.*)\\s+(.*?)$" ) );
4323  QRegularExpressionMatch m = re.match( def );
4324  QString values = def;
4325  if ( m.hasMatch() )
4326  {
4327  values = m.captured( 1 ).trimmed();
4328  defaultVal = m.captured( 2 );
4329  }
4330 
4331  return new QgsProcessingParameterEnum( name, description, values.split( ';' ), multiple, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
4332 }
4333 
4334 QgsProcessingParameterString::QgsProcessingParameterString( const QString &name, const QString &description, const QVariant &defaultValue, bool multiLine, bool optional )
4335  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4336  , mMultiLine( multiLine )
4337 {
4338 
4339 }
4340 
4342 {
4343  return new QgsProcessingParameterString( *this );
4344 }
4345 
4347 {
4348  if ( !value.isValid() || value.isNull() )
4349  return QStringLiteral( "None" );
4350 
4351  if ( value.canConvert<QgsProperty>() )
4352  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
4353 
4354  QString s = value.toString();
4356 }
4357 
4359 {
4360  QString code = QStringLiteral( "##%1=" ).arg( mName );
4361  if ( mFlags & FlagOptional )
4362  code += QLatin1String( "optional " );
4363  code += QLatin1String( "string " );
4364 
4365  if ( mMultiLine )
4366  code += QLatin1String( "long " );
4367 
4368  code += mDefault.toString();
4369  return code.trimmed();
4370 }
4371 
4373 {
4374  switch ( outputType )
4375  {
4377  {
4378  QString code = QStringLiteral( "QgsProcessingParameterString('%1', '%2'" ).arg( name(), description() );
4379  if ( mFlags & FlagOptional )
4380  code += QLatin1String( ", optional=True" );
4381  code += QStringLiteral( ", multiLine=%1" ).arg( mMultiLine ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
4382 
4384  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
4385  return code;
4386  }
4387  }
4388  return QString();
4389 }
4390 
4392 {
4393  return mMultiLine;
4394 }
4395 
4397 {
4398  mMultiLine = multiLine;
4399 }
4400 
4402 {
4404  map.insert( QStringLiteral( "multiline" ), mMultiLine );
4405  return map;
4406 }
4407 
4408 bool QgsProcessingParameterString::fromVariantMap( const QVariantMap &map )
4409 {
4411  mMultiLine = map.value( QStringLiteral( "multiline" ) ).toBool();
4412  return true;
4413 }
4414 
4415 QgsProcessingParameterString *QgsProcessingParameterString::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4416 {
4417  QString def = definition;
4418  bool multiLine = false;
4419  if ( def.startsWith( QLatin1String( "long" ), Qt::CaseInsensitive ) )
4420  {
4421  multiLine = true;
4422  def = def.mid( 5 );
4423  }
4424 
4425  if ( def.startsWith( '"' ) || def.startsWith( '\'' ) )
4426  def = def.mid( 1 );
4427  if ( def.endsWith( '"' ) || def.endsWith( '\'' ) )
4428  def.chop( 1 );
4429 
4430  QVariant defaultValue = def;
4431  if ( def == QLatin1String( "None" ) )
4432  defaultValue = QVariant();
4433 
4435 }
4436 
4437 //
4438 // QgsProcessingParameterAuthConfig
4439 //
4440 
4441 QgsProcessingParameterAuthConfig::QgsProcessingParameterAuthConfig( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
4442  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4443 {
4444 
4445 }
4446 
4448 {
4449  return new QgsProcessingParameterAuthConfig( *this );
4450 }
4451 
4453 {
4454  if ( !value.isValid() )
4455  return QStringLiteral( "None" );
4456 
4457  QString s = value.toString();
4459 }
4460 
4462 {
4463  QString code = QStringLiteral( "##%1=" ).arg( mName );
4464  if ( mFlags & FlagOptional )
4465  code += QLatin1String( "optional " );
4466  code += QLatin1String( "authcfg " );
4467 
4468  code += mDefault.toString();
4469  return code.trimmed();
4470 }
4471 
4472 QgsProcessingParameterAuthConfig *QgsProcessingParameterAuthConfig::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4473 {
4474  QString def = definition;
4475 
4476  if ( def.startsWith( '"' ) || def.startsWith( '\'' ) )
4477  def = def.mid( 1 );
4478  if ( def.endsWith( '"' ) || def.endsWith( '\'' ) )
4479  def.chop( 1 );
4480 
4481  QVariant defaultValue = def;
4482  if ( def == QLatin1String( "None" ) )
4483  defaultValue = QVariant();
4484 
4485  return new QgsProcessingParameterAuthConfig( name, description, defaultValue, isOptional );
4486 }
4487 
4488 
4489 //
4490 // QgsProcessingParameterExpression
4491 //
4492 
4493 QgsProcessingParameterExpression::QgsProcessingParameterExpression( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentLayerParameterName, bool optional )
4494  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4495  , mParentLayerParameterName( parentLayerParameterName )
4496 {
4497 
4498 }
4499 
4501 {
4502  return new QgsProcessingParameterExpression( *this );
4503 }
4504 
4506 {
4507  if ( !value.isValid() )
4508  return QStringLiteral( "None" );
4509 
4510  if ( value.canConvert<QgsProperty>() )
4511  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
4512 
4513  QString s = value.toString();
4515 }
4516 
4518 {
4519  QStringList depends;
4520  if ( !mParentLayerParameterName.isEmpty() )
4521  depends << mParentLayerParameterName;
4522  return depends;
4523 }
4524 
4526 {
4527  switch ( outputType )
4528  {
4530  {
4531  QString code = QStringLiteral( "QgsProcessingParameterExpression('%1', '%2'" ).arg( name(), description() );
4532  if ( mFlags & FlagOptional )
4533  code += QLatin1String( ", optional=True" );
4534 
4535  code += QStringLiteral( ", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4536 
4538  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
4539  return code;
4540  }
4541  }
4542  return QString();
4543 }
4544 
4546 {
4547  return mParentLayerParameterName;
4548 }
4549 
4550 void QgsProcessingParameterExpression::setParentLayerParameterName( const QString &parentLayerParameterName )
4551 {
4552  mParentLayerParameterName = parentLayerParameterName;
4553 }
4554 
4556 {
4558  map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameterName );
4559  return map;
4560 }
4561 
4563 {
4565  mParentLayerParameterName = map.value( QStringLiteral( "parent_layer" ) ).toString();
4566  return true;
4567 }
4568 
4569 QgsProcessingParameterExpression *QgsProcessingParameterExpression::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4570 {
4571  return new QgsProcessingParameterExpression( name, description, definition, QString(), isOptional );
4572 }
4573 
4574 QgsProcessingParameterVectorLayer::QgsProcessingParameterVectorLayer( const QString &name, const QString &description, const QList<int> &types, const QVariant &defaultValue, bool optional )
4575  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4577 {
4578 
4579 }
4580 
4582 {
4583  return new QgsProcessingParameterVectorLayer( *this );
4584 }
4585 
4587 {
4588  if ( !v.isValid() )
4589  return mFlags & FlagOptional;
4590 
4591  QVariant var = v;
4592 
4593  if ( var.canConvert<QgsProperty>() )
4594  {
4595  QgsProperty p = var.value< QgsProperty >();
4597  {
4598  var = p.staticValue();
4599  }
4600  else
4601  {
4602  return true;
4603  }
4604  }
4605 
4606  if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
4607  return true;
4608 
4609  if ( var.type() != QVariant::String || var.toString().isEmpty() )
4610  return mFlags & FlagOptional;
4611 
4612  if ( !context )
4613  {
4614  // that's as far as we can get without a context
4615  return true;
4616  }
4617 
4618  // try to load as layer
4619  if ( QgsProcessingUtils::mapLayerFromString( var.toString(), *context, true, QgsProcessingUtils::LayerHint::Vector ) )
4620  return true;
4621 
4622  return false;
4623 }
4624 
4626 {
4627  if ( !val.isValid() )
4628  return QStringLiteral( "None" );
4629 
4630  if ( val.canConvert<QgsProperty>() )
4631  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( val.value< QgsProperty >().asExpression() );
4632 
4633  QVariantMap p;
4634  p.insert( name(), val );
4637  : QgsProcessingUtils::stringToPythonLiteral( val.toString() );
4638 }
4639 
4641 {
4642  switch ( outputType )
4643  {
4645  {
4646  QString code = QStringLiteral( "QgsProcessingParameterVectorLayer('%1', '%2'" ).arg( name(), description() );
4647  if ( mFlags & FlagOptional )
4648  code += QLatin1String( ", optional=True" );
4649 
4650  if ( !mDataTypes.empty() )
4651  {
4652  QStringList options;
4653  for ( int t : mDataTypes )
4654  options << QStringLiteral( "QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( static_cast< QgsProcessing::SourceType >( t ) ) );
4655  code += QStringLiteral( ", types=[%1]" ).arg( options.join( ',' ) );
4656  }
4657 
4659  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
4660  return code;
4661  }
4662  }
4663  return QString();
4664 }
4665 
4667 {
4668  return QgsProviderRegistry::instance()->fileVectorFilters() + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
4669 }
4670 
4672 {
4673  return mDataTypes;
4674 }
4675 
4677 {
4678  mDataTypes = types;
4679 }
4680 
4682 {
4684  QVariantList types;
4685  for ( int type : mDataTypes )
4686  {
4687  types << type;
4688  }
4689  map.insert( QStringLiteral( "data_types" ), types );
4690  return map;
4691 }
4692 
4694 {
4696  mDataTypes.clear();
4697  const QVariantList values = map.value( QStringLiteral( "data_types" ) ).toList();
4698  for ( const QVariant &val : values )
4699  {
4700  mDataTypes << val.toInt();
4701  }
4702  return true;
4703 }
4704 
4705 QgsProcessingParameterVectorLayer *QgsProcessingParameterVectorLayer::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4706 {
4707  return new QgsProcessingParameterVectorLayer( name, description, QList< int>(), definition.isEmpty() ? QVariant() : definition, isOptional );
4708 }
4709 
4711  const QString &description,
4712  const QVariant &defaultValue,
4713  bool optional )
4714  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4715 {
4716 
4717 }
4718 
4720 {
4721  return new QgsProcessingParameterMeshLayer( *this );
4722 }
4723 
4725 {
4726  if ( !v.isValid() )
4727  return mFlags & FlagOptional;
4728 
4729  QVariant var = v;
4730 
4731  if ( var.canConvert<QgsProperty>() )
4732  {
4733  QgsProperty p = var.value< QgsProperty >();
4735  {
4736  var = p.staticValue();
4737  }
4738  else
4739  {
4740  return true;
4741  }
4742  }
4743 
4744  if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
4745  return true;
4746 
4747  if ( var.type() != QVariant::String || var.toString().isEmpty() )
4748  return mFlags & FlagOptional;
4749 
4750  if ( !context )
4751  {
4752  // that's as far as we can get without a context
4753  return true;
4754  }
4755 
4756  // try to load as layer
4757  if ( QgsProcessingUtils::mapLayerFromString( var.toString(), *context, true, QgsProcessingUtils::LayerHint::Mesh ) )
4758  return true;
4759 
4760  return false;
4761 }
4762 
4764 {
4765  if ( !val.isValid() )
4766  return QStringLiteral( "None" );
4767 
4768  if ( val.canConvert<QgsProperty>() )
4769  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( val.value< QgsProperty >().asExpression() );
4770 
4771  QVariantMap p;
4772  p.insert( name(), val );
4773  QgsMeshLayer *layer = QgsProcessingParameters::parameterAsMeshLayer( this, p, context );
4775  : QgsProcessingUtils::stringToPythonLiteral( val.toString() );
4776 }
4777 
4779 {
4780  return QgsProviderRegistry::instance()->fileMeshFilters() + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
4781 }
4782 
4783 QgsProcessingParameterMeshLayer *QgsProcessingParameterMeshLayer::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
4784 {
4785  return new QgsProcessingParameterMeshLayer( name, description, definition.isEmpty() ? QVariant() : definition, isOptional );
4786 }
4787 
4788 QgsProcessingParameterField::QgsProcessingParameterField( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentLayerParameterName, DataType type, bool allowMultiple, bool optional, bool defaultToAllFields )
4789  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
4790  , mParentLayerParameterName( parentLayerParameterName )
4791  , mDataType( type )
4792  , mAllowMultiple( allowMultiple )
4793  , mDefaultToAllFields( defaultToAllFields )
4794 {
4795 
4796 }
4797 
4798 
4800 {
4801  return new QgsProcessingParameterField( *this );
4802 }
4803 
4805 {
4806  if ( !input.isValid() )
4807  return mFlags & FlagOptional;
4808 
4809  if ( input.canConvert<QgsProperty>() )
4810  {
4811  return true;
4812  }
4813 
4814  if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
4815  {
4816  if ( !mAllowMultiple )
4817  return false;
4818 
4819  if ( input.toList().isEmpty() && !( mFlags & FlagOptional ) )
4820  return false;
4821  }
4822  else if ( input.type() == QVariant::String )
4823  {
4824  if ( input.toString().isEmpty() )
4825  return mFlags & FlagOptional;
4826 
4827  QStringList parts = input.toString().split( ';' );
4828  if ( parts.count() > 1 && !mAllowMultiple )
4829  return false;
4830  }
4831  else
4832  {
4833  if ( input.toString().isEmpty() )
4834  return mFlags & FlagOptional;
4835  }
4836  return true;
4837 }
4838 
4840 {
4841  if ( !value.isValid() )
4842  return QStringLiteral( "None" );
4843 
4844  if ( value.canConvert<QgsProperty>() )
4845  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
4846 
4847  if ( value.type() == QVariant::List )
4848  {
4849  QStringList parts;
4850  const auto constToList = value.toList();
4851  for ( const QVariant &val : constToList )
4852  {
4853  parts << QgsProcessingUtils::stringToPythonLiteral( val.toString() );
4854  }
4855  return parts.join( ',' ).prepend( '[' ).append( ']' );
4856  }
4857  else if ( value.type() == QVariant::StringList )
4858  {
4859  QStringList parts;
4860  const auto constToStringList = value.toStringList();
4861  for ( QString s : constToStringList )
4862  {
4864  }
4865  return parts.join( ',' ).prepend( '[' ).append( ']' );
4866  }
4867 
4868  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
4869 }
4870 
4872 {
4873  QString code = QStringLiteral( "##%1=" ).arg( mName );
4874  if ( mFlags & FlagOptional )
4875  code += QLatin1String( "optional " );
4876  code += QLatin1String( "field " );
4877 
4878  switch ( mDataType )
4879  {
4880  case Numeric:
4881  code += QLatin1String( "numeric " );
4882  break;
4883 
4884  case String:
4885  code += QLatin1String( "string " );
4886  break;
4887 
4888  case DateTime:
4889  code += QLatin1String( "datetime " );
4890  break;
4891 
4892  case Any:
4893  break;
4894  }
4895 
4896  if ( mAllowMultiple )
4897  code += QLatin1String( "multiple " );
4898 
4899  if ( mDefaultToAllFields )
4900  code += QLatin1String( "default_to_all_fields " );
4901 
4902  code += mParentLayerParameterName + ' ';
4903 
4904  code += mDefault.toString();
4905  return code.trimmed();
4906 }
4907 
4909 {
4910  switch ( outputType )
4911  {
4913  {
4914  QString code = QStringLiteral( "QgsProcessingParameterField('%1', '%2'" ).arg( name(), description() );
4915  if ( mFlags & FlagOptional )
4916  code += QLatin1String( ", optional=True" );
4917 
4918  QString dataType;
4919  switch ( mDataType )
4920  {
4921  case Any:
4922  dataType = QStringLiteral( "QgsProcessingParameterField.Any" );
4923  break;
4924 
4925  case Numeric:
4926  dataType = QStringLiteral( "QgsProcessingParameterField.Numeric" );
4927  break;
4928 
4929  case String:
4930  dataType = QStringLiteral( "QgsProcessingParameterField.String" );
4931  break;
4932 
4933  case DateTime:
4934  dataType = QStringLiteral( "QgsProcessingParameterField.DateTime" );
4935  break;
4936  }
4937  code += QStringLiteral( ", type=%1" ).arg( dataType );
4938 
4939  code += QStringLiteral( ", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4940  code += QStringLiteral( ", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
4942  code += QStringLiteral( ", defaultValue=%1" ).arg( valueAsPythonString( mDefault, c ) );
4943 
4944  if ( mDefaultToAllFields )
4945  code += QLatin1String( ", defaultToAllFields=True" );
4946 
4947  code += ')';
4948 
4949  return code;
4950  }
4951  }
4952  return QString();
4953 }
4954 
4956 {
4957  QStringList depends;
4958  if ( !mParentLayerParameterName.isEmpty() )
4959  depends << mParentLayerParameterName;
4960  return depends;
4961 }
4962 
4964 {
4965  return mParentLayerParameterName;
4966 }
4967 
4968 void QgsProcessingParameterField::setParentLayerParameterName( const QString &parentLayerParameterName )
4969 {
4970  mParentLayerParameterName = parentLayerParameterName;
4971 }
4972 
4974 {
4975  return mDataType;
4976 }
4977 
4979 {
4980  mDataType = dataType;
4981 }
4982 
4984 {
4985  return mAllowMultiple;
4986 }
4987 
4989 {
4990  mAllowMultiple = allowMultiple;
4991 }
4992 
4994 {
4995  return mDefaultToAllFields;
4996 }
4997 
4999 {
5000  mDefaultToAllFields = enabled;
5001 }
5002 
5004 {
5006  map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameterName );
5007  map.insert( QStringLiteral( "data_type" ), mDataType );
5008  map.insert( QStringLiteral( "allow_multiple" ), mAllowMultiple );
5009  map.insert( QStringLiteral( "default_to_all_fields" ), mDefaultToAllFields );
5010  return map;
5011 }
5012 
5013 bool QgsProcessingParameterField::fromVariantMap( const QVariantMap &map )
5014 {
5016  mParentLayerParameterName = map.value( QStringLiteral( "parent_layer" ) ).toString();
5017  mDataType = static_cast< DataType >( map.value( QStringLiteral( "data_type" ) ).toInt() );
5018  mAllowMultiple = map.value( QStringLiteral( "allow_multiple" ) ).toBool();
5019  mDefaultToAllFields = map.value( QStringLiteral( "default_to_all_fields" ) ).toBool();
5020  return true;
5021 }
5022 
5023 QgsProcessingParameterField *QgsProcessingParameterField::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
5024 {
5025  QString parent;
5026  DataType type = Any;
5027  bool allowMultiple = false;
5028  bool defaultToAllFields = false;
5029  QString def = definition;
5030 
5031  if ( def.startsWith( QLatin1String( "numeric " ), Qt::CaseInsensitive ) )
5032  {
5033  type = Numeric;
5034  def = def.mid( 8 );
5035  }
5036  else if ( def.startsWith( QLatin1String( "string " ), Qt::CaseInsensitive ) )
5037  {
5038  type = String;
5039  def = def.mid( 7 );
5040  }
5041  else if ( def.startsWith( QLatin1String( "datetime " ), Qt::CaseInsensitive ) )
5042  {
5043  type = DateTime;
5044  def = def.mid( 9 );
5045  }
5046 
5047  if ( def.startsWith( QLatin1String( "multiple" ), Qt::CaseInsensitive ) )
5048  {
5049  allowMultiple = true;
5050  def = def.mid( 8 ).trimmed();
5051  }
5052 
5053  if ( def.startsWith( QLatin1String( "default_to_all_fields" ), Qt::CaseInsensitive ) )
5054  {
5055  defaultToAllFields = true;
5056  def = def.mid( 21 ).trimmed();
5057  }
5058 
5059  QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*)$" ) );
5060  QRegularExpressionMatch m = re.match( def );
5061  if ( m.hasMatch() )
5062  {
5063  parent = m.captured( 1 ).trimmed();
5064  def = m.captured( 2 );
5065  }
5066  else
5067  {
5068  parent = def;
5069  def.clear();
5070  }
5071 
5072  return new QgsProcessingParameterField( name, description, def.isEmpty() ? QVariant() : def, parent, type, allowMultiple, isOptional, defaultToAllFields );
5073 }
5074 
5075 QgsProcessingParameterFeatureSource::QgsProcessingParameterFeatureSource( const QString &name, const QString &description, const QList<int> &types, const QVariant &defaultValue, bool optional )
5076  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
5078 {
5079 
5080 }
5081 
5083 {
5084  return new QgsProcessingParameterFeatureSource( *this );
5085 }
5086 
5088 {
5089  QVariant var = input;
5090  if ( !var.isValid() )
5091  return mFlags & FlagOptional;
5092 
5093  if ( var.canConvert<QgsProcessingFeatureSourceDefinition>() )
5094  {
5095  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( var );
5096  var = fromVar.source;
5097  }
5098  else if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
5099  {
5100  // input is a QgsProcessingOutputLayerDefinition - get extra properties from it
5101  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
5102  var = fromVar.sink;
5103  }
5104 
5105  if ( var.canConvert<QgsProperty>() )
5106  {
5107  QgsProperty p = var.value< QgsProperty >();
5109  {
5110  var = p.staticValue();
5111  }
5112  else
5113  {
5114  return true;
5115  }
5116  }
5117  if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
5118  {
5119  return true;
5120  }
5121 
5122  if ( var.type() != QVariant::String || var.toString().isEmpty() )
5123  return mFlags & FlagOptional;
5124 
5125  if ( !context )
5126  {
5127  // that's as far as we can get without a context
5128  return true;
5129  }
5130 
5131  // try to load as layer
5132  if ( QgsProcessingUtils::mapLayerFromString( var.toString(), *context, true, QgsProcessingUtils::LayerHint::Vector ) )
5133  return true;
5134 
5135  return false;
5136 }
5137 
5139 {
5140  if ( !value.isValid() )
5141  return QStringLiteral( "None" );
5142 
5143  if ( value.canConvert<QgsProperty>() )
5144  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
5145 
5146  if ( value.canConvert<QgsProcessingFeatureSourceDefinition>() )
5147  {
5148  QgsProcessingFeatureSourceDefinition fromVar = qvariant_cast<QgsProcessingFeatureSourceDefinition>( value );
5149  QString geometryCheckString;
5150  switch ( fromVar.geometryCheck )
5151  {
5153  geometryCheckString = QStringLiteral( "QgsFeatureRequest.GeometryNoCheck" );
5154  break;
5155 
5157  geometryCheckString = QStringLiteral( "QgsFeatureRequest.GeometrySkipInvalid" );
5158  break;
5159 
5161  geometryCheckString = QStringLiteral( "QgsFeatureRequest.GeometryAbortOnInvalid" );
5162  break;
5163  }
5164 
5165  QStringList flags;
5166  QString flagString;
5167  if ( fromVar.flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck )
5168  flags << QStringLiteral( "QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
5169  if ( fromVar.flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
5170  flags << QStringLiteral( "QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
5171  if ( !flags.empty() )
5172  flagString = flags.join( QLatin1String( " | " ) );
5173 
5174  if ( fromVar.source.propertyType() == QgsProperty::StaticProperty )
5175  {
5176  QString layerString = fromVar.source.staticValue().toString();
5177  // prefer to use layer source instead of id if possible (since it's persistent)
5178  if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( QgsProcessingUtils::mapLayerFromString( layerString, context, true, QgsProcessingUtils::LayerHint::Vector ) ) )
5179  layerString = layer->source();
5180 
5181  if ( fromVar.selectedFeaturesOnly || fromVar.featureLimit != -1 || fromVar.flags )
5182  {
5183  return QStringLiteral( "QgsProcessingFeatureSourceDefinition('%1', selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" ).arg( layerString,
5184  fromVar.selectedFeaturesOnly ? QStringLiteral( "True" ) : QStringLiteral( "False" ),
5185  QString::number( fromVar.featureLimit ),
5186  flagString.isEmpty() ? QString() : ( QStringLiteral( ", flags=%1" ).arg( flagString ) ),
5187  geometryCheckString );
5188  }
5189  else
5190  {
5191  return QgsProcessingUtils::stringToPythonLiteral( layerString );
5192  }
5193  }
5194  else
5195  {
5196  if ( fromVar.selectedFeaturesOnly || fromVar.featureLimit != -1 || fromVar.flags )
5197  {
5198  return QStringLiteral( "QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" )
5199  .arg( fromVar.source.asExpression(),
5200  fromVar.selectedFeaturesOnly ? QStringLiteral( "True" ) : QStringLiteral( "False" ),
5201  QString::number( fromVar.featureLimit ),
5202  flagString.isEmpty() ? QString() : ( QStringLiteral( ", flags=%1" ).arg( flagString ) ),
5203  geometryCheckString );
5204  }
5205  else
5206  {
5207  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.source.asExpression() );
5208  }
5209  }
5210  }
5211  else if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
5212  {
5213  return QgsProcessingUtils::stringToPythonLiteral( layer->source() );
5214  }
5215 
5216  QString layerString = value.toString();
5217 
5218  // prefer to use layer source if possible (since it's persistent)
5219  if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( QgsProcessingUtils::mapLayerFromString( layerString, context, true, QgsProcessingUtils::LayerHint::Vector ) ) )
5220  layerString = layer->providerType() != QLatin1String( "ogr" ) && layer->providerType() != QLatin1String( "gdal" ) && layer->providerType() != QLatin1String( "mdal" ) ? QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
5221 
5222  return QgsProcessingUtils::stringToPythonLiteral( layerString );
5223 }
5224 
5226 {
5227  QString code = QStringLiteral( "##%1=" ).arg( mName );
5228  if ( mFlags & FlagOptional )
5229  code += QLatin1String( "optional " );
5230  code += QLatin1String( "source " );
5231 
5232  for ( int type : mDataTypes )
5233  {
5234  switch ( type )
5235  {
5237  code += QLatin1String( "point " );
5238  break;
5239 
5241  code += QLatin1String( "line " );
5242  break;
5243 
5245  code += QLatin1String( "polygon " );
5246  break;
5247 
5248  }
5249  }
5250 
5251  code += mDefault.toString();
5252  return code.trimmed();
5253 }
5254 
5256 {
5257  switch ( outputType )
5258  {
5260  {
5261  QString code = QStringLiteral( "QgsProcessingParameterFeatureSource('%1', '%2'" ).arg( name(), description() );
5262  if ( mFlags & FlagOptional )
5263  code += QLatin1String( ", optional=True" );
5264 
5265  if ( !mDataTypes.empty() )
5266  {
5267  QStringList options;
5268  options.reserve( mDataTypes.size() );
5269  for ( int t : mDataTypes )
5270  options << QStringLiteral( "QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( static_cast< QgsProcessing::SourceType >( t ) ) );
5271  code += QStringLiteral( ", types=[%1]" ).arg( options.join( ',' ) );
5272  }
5273 
5275  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
5276  return code;
5277  }
5278  }
5279  return QString();
5280 }
5281 
5283 {
5284  return QgsProviderRegistry::instance()->fileVectorFilters() + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
5285 }
5286 
5288  : mDataTypes( types )
5289 {
5290 
5291 }
5292 
5294 {
5296  QVariantList types;
5297  for ( int type : mDataTypes )
5298  {
5299  types << type;
5300  }
5301  map.insert( QStringLiteral( "data_types" ), types );
5302  return map;
5303 }
5304 
5306 {
5308  mDataTypes.clear();
5309  const QVariantList values = map.value( QStringLiteral( "data_types" ) ).toList();
5310  for ( const QVariant &val : values )
5311  {
5312  mDataTypes << val.toInt();
5313  }
5314  return true;
5315 }
5316 
5317 QgsProcessingParameterFeatureSource *QgsProcessingParameterFeatureSource::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
5318 {
5319  QList< int > types;
5320  QString def = definition;
5321  while ( true )
5322  {
5323  if ( def.startsWith( QLatin1String( "point" ), Qt::CaseInsensitive ) )
5324  {
5326  def = def.mid( 6 );
5327  continue;
5328  }
5329  else if ( def.startsWith( QLatin1String( "line" ), Qt::CaseInsensitive ) )
5330  {
5332  def = def.mid( 5 );
5333  continue;
5334  }
5335  else if ( def.startsWith( QLatin1String( "polygon" ), Qt::CaseInsensitive ) )
5336  {
5338  def = def.mid( 8 );
5339  continue;
5340  }
5341  break;
5342  }
5343 
5344  return new QgsProcessingParameterFeatureSource( name, description, types, def, isOptional );
5345 }
5346 
5347 QgsProcessingParameterFeatureSink::QgsProcessingParameterFeatureSink( const QString &name, const QString &description, QgsProcessing::SourceType type, const QVariant &defaultValue, bool optional, bool createByDefault, bool supportsAppend )
5348  : QgsProcessingDestinationParameter( name, description, defaultValue, optional, createByDefault )
5349  , mDataType( type )
5350  , mSupportsAppend( supportsAppend )
5351 {
5352 }
5353 
5355 {
5356  return new QgsProcessingParameterFeatureSink( *this );
5357 }
5358 
5360 {
5361  QVariant var = input;
5362  if ( !var.isValid() )
5363  return mFlags & FlagOptional;
5364 
5365  if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
5366  {
5367  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
5368  var = fromVar.sink;
5369  }
5370 
5371  if ( var.canConvert<QgsProperty>() )
5372  {
5373  QgsProperty p = var.value< QgsProperty >();
5375  {
5376  var = p.staticValue();
5377  }
5378  else
5379  {
5380  return true;
5381  }
5382  }
5383 
5384  if ( var.type() != QVariant::String )
5385  return false;
5386 
5387  if ( var.toString().isEmpty() )
5388  return mFlags & FlagOptional;
5389 
5390  return true;
5391 }
5392 
5394 {
5395  if ( !value.isValid() )
5396  return QStringLiteral( "None" );
5397 
5398  if ( value.canConvert<QgsProperty>() )
5399  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
5400 
5401  if ( value.canConvert<QgsProcessingOutputLayerDefinition>() )
5402  {
5403  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
5404  if ( fromVar.sink.propertyType() == QgsProperty::StaticProperty )
5405  {
5406  return QgsProcessingUtils::stringToPythonLiteral( fromVar.sink.staticValue().toString() );
5407  }
5408  else
5409  {
5410  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.sink.asExpression() );
5411  }
5412  }
5413 
5414  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
5415 }
5416 
5418 {
5419  QString code = QStringLiteral( "##%1=" ).arg( mName );
5420  if ( mFlags & FlagOptional )
5421  code += QLatin1String( "optional " );
5422  code += QLatin1String( "sink " );
5423 
5424  switch ( mDataType )
5425  {
5427  code += QLatin1String( "point " );
5428  break;
5429 
5431  code += QLatin1String( "line " );
5432  break;
5433 
5435  code += QLatin1String( "polygon " );
5436  break;
5437 
5439  code += QLatin1String( "table " );
5440  break;
5441 
5442  default:
5443  break;
5444  }
5445 
5446  code += mDefault.toString();
5447  return code.trimmed();
5448 }
5449 
5451 {
5452  return new QgsProcessingOutputVectorLayer( name(), description(), mDataType );
5453 }
5454 
5456 {
5457  if ( auto *lOriginalProvider = originalProvider() )
5458  {
5459  return lOriginalProvider->defaultVectorFileExtension( hasGeometry() );
5460  }
5461  else if ( QgsProcessingProvider *p = provider() )
5462  {
5463  return p->defaultVectorFileExtension( hasGeometry() );
5464  }
5465  else
5466  {
5467  if ( hasGeometry() )
5468  {
5470  }
5471  else
5472  {
5473  return QStringLiteral( "dbf" );
5474  }
5475  }
5476 }
5477 
5479 {
5480  switch ( outputType )
5481  {
5483  {
5484  QString code = QStringLiteral( "QgsProcessingParameterFeatureSink('%1', '%2'" ).arg( name(), description() );
5485  if ( mFlags & FlagOptional )
5486  code += QLatin1String( ", optional=True" );
5487 
5488  code += QStringLiteral( ", type=QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( mDataType ) );
5489 
5490  code += QStringLiteral( ", createByDefault=%1" ).arg( createByDefault() ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
5491  if ( mSupportsAppend )
5492  code += QLatin1String( ", supportsAppend=True" );
5493 
5495  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
5496  return code;
5497  }
5498  }
5499  return QString();
5500 }
5501 
5503 {
5504  const QStringList exts = supportedOutputVectorLayerExtensions();
5505  QStringList filters;
5506  for ( const QString &ext : exts )
5507  {
5508  filters << QObject::tr( "%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5509  }
5510  return filters.join( QLatin1String( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
5511 
5512 }
5513 
5515 {
5516  if ( auto *lOriginalProvider = originalProvider() )
5517  {
5518  if ( hasGeometry() )
5519  return lOriginalProvider->supportedOutputVectorLayerExtensions();
5520  else
5521  return lOriginalProvider->supportedOutputTableExtensions();
5522  }
5523  else if ( QgsProcessingProvider *p = provider() )
5524  {
5525  if ( hasGeometry() )
5526  return p->supportedOutputVectorLayerExtensions();
5527  else
5528  return p->supportedOutputTableExtensions();
5529  }
5530  else
5531  {
5533  }
5534 }
5535 
5537 {
5538  return mDataType;
5539 }
5540 
5542 {
5543  switch ( mDataType )
5544  {
5550  return true;
5551 
5556  return false;
5557  }
5558  return true;
5559 }
5560 
5562 {
5563  mDataType = type;
5564 }
5565 
5567 {
5569  map.insert( QStringLiteral( "data_type" ), mDataType );
5570  map.insert( QStringLiteral( "supports_append" ), mSupportsAppend );
5571  return map;
5572 }
5573 
5575 {
5577  mDataType = static_cast< QgsProcessing::SourceType >( map.value( QStringLiteral( "data_type" ) ).toInt() );
5578  mSupportsAppend = map.value( QStringLiteral( "supports_append" ), false ).toBool();
5579  return true;
5580 }
5581 
5583 {
5585  return QStringLiteral( "memory:%1" ).arg( description() );
5586  else
5588 }
5589 
5590 QgsProcessingParameterFeatureSink *QgsProcessingParameterFeatureSink::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
5591 {
5593  QString def = definition;
5594  if ( def.startsWith( QLatin1String( "point" ), Qt::CaseInsensitive ) )
5595  {
5597  def = def.mid( 6 );
5598  }
5599  else if ( def.startsWith( QLatin1String( "line" ), Qt::CaseInsensitive ) )
5600  {
5602  def = def.mid( 5 );
5603  }
5604  else if ( def.startsWith( QLatin1String( "polygon" ), Qt::CaseInsensitive ) )
5605  {
5607  def = def.mid( 8 );
5608  }
5609  else if ( def.startsWith( QLatin1String( "table" ), Qt::CaseInsensitive ) )
5610  {
5612  def = def.mid( 6 );
5613  }
5614 
5615  return new QgsProcessingParameterFeatureSink( name, description, type, definition, isOptional );
5616 }
5617 
5619 {
5620  return mSupportsAppend;
5621 }
5622 
5624 {
5625  mSupportsAppend = supportsAppend;
5626 }
5627 
5628 QgsProcessingParameterRasterDestination::QgsProcessingParameterRasterDestination( const QString &name, const QString &description, const QVariant &defaultValue, bool optional, bool createByDefault )
5629  : QgsProcessingDestinationParameter( name, description, defaultValue, optional, createByDefault )
5630 {
5631 }
5632 
5634 {
5635  return new QgsProcessingParameterRasterDestination( *this );
5636 }
5637 
5639 {
5640  QVariant var = input;
5641  if ( !var.isValid() )
5642  return mFlags & FlagOptional;
5643 
5644  if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
5645  {
5646  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
5647  var = fromVar.sink;
5648  }
5649 
5650  if ( var.canConvert<QgsProperty>() )
5651  {
5652  QgsProperty p = var.value< QgsProperty >();
5654  {
5655  var = p.staticValue();
5656  }
5657  else
5658  {
5659  return true;
5660  }
5661  }
5662 
5663  if ( var.type() != QVariant::String )
5664  return false;
5665 
5666  if ( var.toString().isEmpty() )
5667  return mFlags & FlagOptional;
5668 
5669  return true;
5670 }
5671 
5673 {
5674  if ( !value.isValid() )
5675  return QStringLiteral( "None" );
5676 
5677  if ( value.canConvert<QgsProperty>() )
5678  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
5679 
5680  if ( value.canConvert<QgsProcessingOutputLayerDefinition>() )
5681  {
5682  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
5683  if ( fromVar.sink.propertyType() == QgsProperty::StaticProperty )
5684  {
5685  return QgsProcessingUtils::stringToPythonLiteral( fromVar.sink.staticValue().toString() );
5686  }
5687  else
5688  {
5689  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.sink.asExpression() );
5690  }
5691  }
5692 
5693  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
5694 }
5695 
5697 {
5698  return new QgsProcessingOutputRasterLayer( name(), description() );
5699 }
5700 
5702 {
5703  if ( auto *lOriginalProvider = originalProvider() )
5704  {
5705  return lOriginalProvider->defaultRasterFileExtension();
5706  }
5707  else if ( QgsProcessingProvider *p = provider() )
5708  {
5709  return p->defaultRasterFileExtension();
5710  }
5711  else
5712  {
5714  }
5715 }
5716 
5718 {
5719  const QStringList exts = supportedOutputRasterLayerExtensions();
5720  QStringList filters;
5721  for ( const QString &ext : exts )
5722  {
5723  filters << QObject::tr( "%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5724  }
5725  return filters.join( QLatin1String( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
5726 }
5727 
5729 {
5730  if ( auto *lOriginalProvider = originalProvider() )
5731  {
5732  return lOriginalProvider->supportedOutputRasterLayerExtensions();
5733  }
5734  else if ( QgsProcessingProvider *p = provider() )
5735  {
5736  return p->supportedOutputRasterLayerExtensions();
5737  }
5738  else
5739  {
5741  }
5742 }
5743 
5744 QgsProcessingParameterRasterDestination *QgsProcessingParameterRasterDestination::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
5745 {
5746  return new QgsProcessingParameterRasterDestination( name, description, definition.isEmpty() ? QVariant() : definition, isOptional );
5747 }
5748 
5749 
5750 QgsProcessingParameterFileDestination::QgsProcessingParameterFileDestination( const QString &name, const QString &description, const QString &fileFilter, const QVariant &defaultValue, bool optional, bool createByDefault )
5751  : QgsProcessingDestinationParameter( name, description, defaultValue, optional, createByDefault )
5752  , mFileFilter( fileFilter.isEmpty() ? QObject::tr( "All files (*.*)" ) : fileFilter )
5753 {
5754 
5755 }
5756 
5758 {
5759  return new QgsProcessingParameterFileDestination( *this );
5760 }
5761 
5763 {
5764  QVariant var = input;
5765  if ( !var.isValid() )
5766  return mFlags & FlagOptional;
5767 
5768  if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
5769  {
5770  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
5771  var = fromVar.sink;
5772  }
5773 
5774  if ( var.canConvert<QgsProperty>() )
5775  {
5776  QgsProperty p = var.value< QgsProperty >();
5778  {
5779  var = p.staticValue();
5780  }
5781  else
5782  {
5783  return true;
5784  }
5785  }
5786 
5787  if ( var.type() != QVariant::String )
5788  return false;
5789 
5790  if ( var.toString().isEmpty() )
5791  return mFlags & FlagOptional;
5792 
5793  // possible enhancement - check that value is compatible with file filter?
5794 
5795  return true;
5796 }
5797 
5799 {
5800  if ( !value.isValid() )
5801  return QStringLiteral( "None" );
5802 
5803  if ( value.canConvert<QgsProperty>() )
5804  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
5805 
5806  if ( value.canConvert<QgsProcessingOutputLayerDefinition>() )
5807  {
5808  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
5809  if ( fromVar.sink.propertyType() == QgsProperty::StaticProperty )
5810  {
5811  return QgsProcessingUtils::stringToPythonLiteral( fromVar.sink.staticValue().toString() );
5812  }
5813  else
5814  {
5815  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.sink.asExpression() );
5816  }
5817  }
5818 
5819  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
5820 }
5821 
5823 {
5824  if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral( "htm" ), Qt::CaseInsensitive ) )
5825  {
5826  return new QgsProcessingOutputHtml( name(), description() );
5827  }
5828  else
5829  {
5830  return new QgsProcessingOutputFile( name(), description() );
5831  }
5832 }
5833 
5835 {
5836  if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr( "All files (*.*)" ) )
5837  return QStringLiteral( "file" );
5838 
5839  // get first extension from filter
5840  QRegularExpression rx( QStringLiteral( ".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
5841  QRegularExpressionMatch match = rx.match( mFileFilter );
5842  if ( !match.hasMatch() )
5843  return QStringLiteral( "file" );
5844 
5845  return match.captured( 1 );
5846 }
5847 
5849 {
5850  switch ( outputType )
5851  {
5853  {
5854  QString code = QStringLiteral( "QgsProcessingParameterFileDestination('%1', '%2'" ).arg( name(), description() );
5855  if ( mFlags & FlagOptional )
5856  code += QLatin1String( ", optional=True" );
5857 
5858  code += QStringLiteral( ", fileFilter=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mFileFilter ) );
5859 
5860  code += QStringLiteral( ", createByDefault=%1" ).arg( createByDefault() ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
5861 
5863  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
5864  return code;
5865  }
5866  }
5867  return QString();
5868 }
5869 
5871 {
5872  return ( fileFilter().isEmpty() ? QString() : fileFilter() + QStringLiteral( ";;" ) ) + QObject::tr( "All files (*.*)" );
5873 }
5874 
5876 {
5877  return mFileFilter;
5878 }
5879 
5881 {
5882  mFileFilter = fileFilter;
5883 }
5884 
5886 {
5888  map.insert( QStringLiteral( "file_filter" ), mFileFilter );
5889  return map;
5890 }
5891 
5893 {
5895  mFileFilter = map.value( QStringLiteral( "file_filter" ) ).toString();
5896  return true;
5897 
5898 }
5899 
5900 QgsProcessingParameterFileDestination *QgsProcessingParameterFileDestination::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
5901 {
5902  return new QgsProcessingParameterFileDestination( name, description, QString(), definition.isEmpty() ? QVariant() : definition, isOptional );
5903 }
5904 
5905 QgsProcessingParameterFolderDestination::QgsProcessingParameterFolderDestination( const QString &name, const QString &description, const QVariant &defaultValue, bool optional, bool createByDefault )
5906  : QgsProcessingDestinationParameter( name, description, defaultValue, optional, createByDefault )
5907 {}
5908 
5910 {
5911  return new QgsProcessingParameterFolderDestination( *this );
5912 }
5913 
5915 {
5916  QVariant var = input;
5917  if ( !var.isValid() )
5918  return mFlags & FlagOptional;
5919 
5920  if ( var.canConvert<QgsProperty>() )
5921  {
5922  QgsProperty p = var.value< QgsProperty >();
5924  {
5925  var = p.staticValue();
5926  }
5927  else
5928  {
5929  return true;
5930  }
5931  }
5932 
5933  if ( var.type() != QVariant::String )
5934  return false;
5935 
5936  if ( var.toString().isEmpty() )
5937  return mFlags & FlagOptional;
5938 
5939  return true;
5940 }
5941 
5943 {
5944  return new QgsProcessingOutputFolder( name(), description() );
5945 }
5946 
5948 {
5949  return QString();
5950 }
5951 
5952 QgsProcessingParameterFolderDestination *QgsProcessingParameterFolderDestination::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
5953 {
5954  return new QgsProcessingParameterFolderDestination( name, description, definition.isEmpty() ? QVariant() : definition, isOptional );
5955 }
5956 
5957 QgsProcessingDestinationParameter::QgsProcessingDestinationParameter( const QString &name, const QString &description, const QVariant &defaultValue, bool optional, bool createByDefault )
5958  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
5959  , mCreateByDefault( createByDefault )
5960 {
5961 
5962 }
5963 
5965 {
5967  map.insert( QStringLiteral( "supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
5968  map.insert( QStringLiteral( "create_by_default" ), mCreateByDefault );
5969  return map;
5970 }
5971 
5973 {
5975  mSupportsNonFileBasedOutputs = map.value( QStringLiteral( "supports_non_file_outputs" ) ).toBool();
5976  mCreateByDefault = map.value( QStringLiteral( "create_by_default" ), QStringLiteral( "1" ) ).toBool();
5977  return true;
5978 }
5979 
5981 {
5982  switch ( outputType )
5983  {
5985  {
5986  // base class method is probably not much use
5987  if ( QgsProcessingParameterType *t = QgsApplication::processingRegistry()->parameterType( type() ) )
5988  {
5989  QString code = t->className() + QStringLiteral( "('%1', '%2'" ).arg( name(), description() );
5990  if ( mFlags & FlagOptional )
5991  code += QLatin1String( ", optional=True" );
5992 
5993  code += QStringLiteral( ", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
5994 
5996  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
5997  return code;
5998  }
5999  break;
6000  }
6001  }
6002  // oh well, we tried
6003  return QString();
6004 }
6005 
6007 {
6008  return QObject::tr( "Default extension" ) + QStringLiteral( " (*." ) + defaultFileExtension() + ')';
6009 }
6010 
6012 {
6013  // sanitize name to avoid multiple . in the filename. E.g. when name() contain
6014  // backend command name having a "." inside as in case of grass commands
6015  QRegularExpression rx( QStringLiteral( "[.]" ) );
6016  QString sanitizedName = name();
6017  sanitizedName.replace( rx, QStringLiteral( "_" ) );
6018 
6019  if ( defaultFileExtension().isEmpty() )
6020  {
6021  return QgsProcessingUtils::generateTempFilename( sanitizedName );
6022  }
6023  else
6024  {
6025  return QgsProcessingUtils::generateTempFilename( sanitizedName + '.' + defaultFileExtension() );
6026  }
6027 }
6028 
6029 bool QgsProcessingDestinationParameter::isSupportedOutputValue( const QVariant &value, QgsProcessingContext &context, QString &error ) const
6030 {
6031  if ( auto *lOriginalProvider = originalProvider() )
6032  return lOriginalProvider->isSupportedOutputValue( value, this, context, error );
6033  else if ( provider() )
6034  return provider()->isSupportedOutputValue( value, this, context, error );
6035 
6036  return true;
6037 }
6038 
6040 {
6041  return mCreateByDefault;
6042 }
6043 
6045 {
6046  mCreateByDefault = createByDefault;
6047 }
6048 
6049 QgsProcessingParameterVectorDestination::QgsProcessingParameterVectorDestination( const QString &name, const QString &description, QgsProcessing::SourceType type, const QVariant &defaultValue, bool optional, bool createByDefault )
6050  : QgsProcessingDestinationParameter( name, description, defaultValue, optional, createByDefault )
6051  , mDataType( type )
6052 {
6053 
6054 }
6055 
6057 {
6058  return new QgsProcessingParameterVectorDestination( *this );
6059 }
6060 
6062 {
6063  QVariant var = input;
6064  if ( !var.isValid() )
6065  return mFlags & FlagOptional;
6066 
6067  if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
6068  {
6069  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
6070  var = fromVar.sink;
6071  }
6072 
6073  if ( var.canConvert<QgsProperty>() )
6074  {
6075  QgsProperty p = var.value< QgsProperty >();
6077  {
6078  var = p.staticValue();
6079  }
6080  else
6081  {
6082  return true;
6083  }
6084  }
6085 
6086  if ( var.type() != QVariant::String )
6087  return false;
6088 
6089  if ( var.toString().isEmpty() )
6090  return mFlags & FlagOptional;
6091 
6092  return true;
6093 }
6094 
6096 {
6097  if ( !value.isValid() )
6098  return QStringLiteral( "None" );
6099 
6100  if ( value.canConvert<QgsProperty>() )
6101  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
6102 
6103  if ( value.canConvert<QgsProcessingOutputLayerDefinition>() )
6104  {
6105  QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( value );
6106  if ( fromVar.sink.propertyType() == QgsProperty::StaticProperty )
6107  {
6108  return QgsProcessingUtils::stringToPythonLiteral( fromVar.sink.staticValue().toString() );
6109  }
6110  else
6111  {
6112  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( fromVar.sink.asExpression() );
6113  }
6114  }
6115 
6116  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
6117 }
6118 
6120 {
6121  QString code = QStringLiteral( "##%1=" ).arg( mName );
6122  if ( mFlags & FlagOptional )
6123  code += QLatin1String( "optional " );
6124  code += QLatin1String( "vectorDestination " );
6125 
6126  switch ( mDataType )
6127  {
6129  code += QLatin1String( "point " );
6130  break;
6131 
6133  code += QLatin1String( "line " );
6134  break;
6135 
6137  code += QLatin1String( "polygon " );
6138  break;
6139 
6140  default:
6141  break;
6142  }
6143 
6144  code += mDefault.toString();
6145  return code.trimmed();
6146 }
6147 
6149 {
6150  return new QgsProcessingOutputVectorLayer( name(), description(), mDataType );
6151 }
6152 
6154 {
6155  if ( auto *lOriginalProvider = originalProvider() )
6156  {
6157  return lOriginalProvider->defaultVectorFileExtension( hasGeometry() );
6158  }
6159  else if ( QgsProcessingProvider *p = provider() )
6160  {
6161  return p->defaultVectorFileExtension( hasGeometry() );
6162  }
6163  else
6164  {
6165  if ( hasGeometry() )
6166  {
6168  }
6169  else
6170  {
6171  return QStringLiteral( "dbf" );
6172  }
6173  }
6174 }
6175 
6177 {
6178  switch ( outputType )
6179  {
6181  {
6182  QString code = QStringLiteral( "QgsProcessingParameterVectorDestination('%1', '%2'" ).arg( name(), description() );
6183  if ( mFlags & FlagOptional )
6184  code += QLatin1String( ", optional=True" );
6185 
6186  code += QStringLiteral( ", type=QgsProcessing.%1" ).arg( QgsProcessing::sourceTypeToString( mDataType ) );
6187 
6188  code += QStringLiteral( ", createByDefault=%1" ).arg( createByDefault() ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
6189 
6191  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
6192  return code;
6193  }
6194  }
6195  return QString();
6196 }
6197 
6199 {
6200  const QStringList exts = supportedOutputVectorLayerExtensions();
6201  QStringList filters;
6202  for ( const QString &ext : exts )
6203  {
6204  filters << QObject::tr( "%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6205  }
6206  return filters.join( QLatin1String( ";;" ) ) + QStringLiteral( ";;" ) + QObject::tr( "All files (*.*)" );
6207 }
6208 
6210 {
6211  if ( auto *lOriginalProvider = originalProvider() )
6212  {
6213  if ( hasGeometry() )
6214  return lOriginalProvider->supportedOutputVectorLayerExtensions();
6215  else
6216  return lOriginalProvider->supportedOutputTableExtensions();
6217  }
6218  else if ( QgsProcessingProvider *p = provider() )
6219  {
6220  if ( hasGeometry() )
6221  return p->supportedOutputVectorLayerExtensions();
6222  else
6223  return p->supportedOutputTableExtensions();
6224  }
6225  else
6226  {
6228  }
6229 }
6230 
6232 {
6233  return mDataType;
6234 }
6235 
6237 {
6238  switch ( mDataType )
6239  {
6245  return true;
6246 
6251  return false;
6252  }
6253  return true;
6254 }
6255 
6257 {
6258  mDataType = type;
6259 }
6260 
6262 {
6264  map.insert( QStringLiteral( "data_type" ), mDataType );
6265  return map;
6266 }
6267 
6269 {
6271  mDataType = static_cast< QgsProcessing::SourceType >( map.value( QStringLiteral( "data_type" ) ).toInt() );
6272  return true;
6273 }
6274 
6275 QgsProcessingParameterVectorDestination *QgsProcessingParameterVectorDestination::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
6276 {
6278  QString def = definition;
6279  if ( def.startsWith( QLatin1String( "point" ), Qt::CaseInsensitive ) )
6280  {
6282  def = def.mid( 6 );
6283  }
6284  else if ( def.startsWith( QLatin1String( "line" ), Qt::CaseInsensitive ) )
6285  {
6287  def = def.mid( 5 );
6288  }
6289  else if ( def.startsWith( QLatin1String( "polygon" ), Qt::CaseInsensitive ) )
6290  {
6292  def = def.mid( 8 );
6293  }
6294 
6295  return new QgsProcessingParameterVectorDestination( name, description, type, definition, isOptional );
6296 }
6297 
6298 QgsProcessingParameterBand::QgsProcessingParameterBand( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentLayerParameterName, bool optional, bool allowMultiple )
6299  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
6300  , mParentLayerParameterName( parentLayerParameterName )
6301  , mAllowMultiple( allowMultiple )
6302 {
6303 
6304 }
6305 
6307 {
6308  return new QgsProcessingParameterBand( *this );
6309 }
6310 
6312 {
6313  if ( !input.isValid() )
6314  return mFlags & FlagOptional;
6315 
6316  if ( input.canConvert<QgsProperty>() )
6317  {
6318  return true;
6319  }
6320 
6321  if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
6322  {
6323  if ( !mAllowMultiple )
6324  return false;
6325 
6326  if ( input.toList().isEmpty() && !( mFlags & FlagOptional ) )
6327  return false;
6328  }
6329  else
6330  {
6331  bool ok = false;
6332  double res = input.toInt( &ok );
6333  Q_UNUSED( res )
6334  if ( !ok )
6335  return mFlags & FlagOptional;
6336  }
6337  return true;
6338 }
6339 
6341 {
6342  return mAllowMultiple;
6343 }
6344 
6346 {
6347  mAllowMultiple = allowMultiple;
6348 }
6349 
6351 {
6352  if ( !value.isValid() )
6353  return QStringLiteral( "None" );
6354 
6355  if ( value.canConvert<QgsProperty>() )
6356  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
6357 
6358  if ( value.type() == QVariant::List )
6359  {
6360  QStringList parts;
6361  QVariantList values = value.toList();
6362  for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
6363  {
6364  parts << QString::number( static_cast< int >( it->toDouble() ) );
6365  }
6366  return parts.join( ',' ).prepend( '[' ).append( ']' );
6367  }
6368  else if ( value.type() == QVariant::StringList )
6369  {
6370  QStringList parts;
6371  QStringList values = value.toStringList();
6372  for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
6373  {
6374  parts << QString::number( static_cast< int >( it->toDouble() ) );
6375  }
6376  return parts.join( ',' ).prepend( '[' ).append( ']' );
6377  }
6378 
6379  return value.toString();
6380 }
6381 
6383 {
6384  QString code = QStringLiteral( "##%1=" ).arg( mName );
6385  if ( mFlags & FlagOptional )
6386  code += QLatin1String( "optional " );
6387  code += QLatin1String( "band " );
6388 
6389  if ( mAllowMultiple )
6390  code += QLatin1String( "multiple " );
6391 
6392  code += mParentLayerParameterName + ' ';
6393 
6394  code += mDefault.toString();
6395  return code.trimmed();
6396 }
6397 
6399 {
6400  QStringList depends;
6401  if ( !mParentLayerParameterName.isEmpty() )
6402  depends << mParentLayerParameterName;
6403  return depends;
6404 }
6405 
6407 {
6408  switch ( outputType )
6409  {
6411  {
6412  QString code = QStringLiteral( "QgsProcessingParameterBand('%1', '%2'" ).arg( name(), description() );
6413  if ( mFlags & FlagOptional )
6414  code += QLatin1String( ", optional=True" );
6415 
6416  code += QStringLiteral( ", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6417  code += QStringLiteral( ", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
6418 
6420  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
6421  return code;
6422  }
6423  }
6424  return QString();
6425 }
6426 
6428 {
6429  return mParentLayerParameterName;
6430 }
6431 
6432 void QgsProcessingParameterBand::setParentLayerParameterName( const QString &parentLayerParameterName )
6433 {
6434  mParentLayerParameterName = parentLayerParameterName;
6435 }
6436 
6438 {
6440  map.insert( QStringLiteral( "parent_layer" ), mParentLayerParameterName );
6441  map.insert( QStringLiteral( "allow_multiple" ), mAllowMultiple );
6442  return map;
6443 }
6444 
6445 bool QgsProcessingParameterBand::fromVariantMap( const QVariantMap &map )
6446 {
6448  mParentLayerParameterName = map.value( QStringLiteral( "parent_layer" ) ).toString();
6449  mAllowMultiple = map.value( QStringLiteral( "allow_multiple" ) ).toBool();
6450  return true;
6451 }
6452 
6453 QgsProcessingParameterBand *QgsProcessingParameterBand::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
6454 {
6455  QString parent;
6456  QString def = definition;
6457  bool allowMultiple = false;
6458 
6459  if ( def.startsWith( QLatin1String( "multiple" ), Qt::CaseInsensitive ) )
6460  {
6461  allowMultiple = true;
6462  def = def.mid( 8 ).trimmed();
6463  }
6464 
6465  QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*)$" ) );
6466  QRegularExpressionMatch m = re.match( def );
6467  if ( m.hasMatch() )
6468  {
6469  parent = m.captured( 1 ).trimmed();
6470  def = m.captured( 2 );
6471  }
6472  else
6473  {
6474  parent = def;
6475  def.clear();
6476  }
6477 
6478  return new QgsProcessingParameterBand( name, description, def.isEmpty() ? QVariant() : def, parent, isOptional, allowMultiple );
6479 }
6480 
6481 //
6482 // QgsProcessingParameterDistance
6483 //
6484 
6485 QgsProcessingParameterDistance::QgsProcessingParameterDistance( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentParameterName, bool optional, double minValue, double maxValue )
6486  : QgsProcessingParameterNumber( name, description, Double, defaultValue, optional, minValue, maxValue )
6487  , mParentParameterName( parentParameterName )
6488 {
6489 
6490 }
6491 
6493 {
6494  return new QgsProcessingParameterDistance( *this );
6495 }
6496 
6498 {
6499  return typeName();
6500 }
6501 
6503 {
6504  QStringList depends;
6505  if ( !mParentParameterName.isEmpty() )
6506  depends << mParentParameterName;
6507  return depends;
6508 }
6509 
6511 {
6512  switch ( outputType )
6513  {
6515  {
6516  QString code = QStringLiteral( "QgsProcessingParameterDistance('%1', '%2'" ).arg( name(), description() );
6517  if ( mFlags & FlagOptional )
6518  code += QLatin1String( ", optional=True" );
6519 
6520  code += QStringLiteral( ", parentParameterName='%1'" ).arg( mParentParameterName );
6521 
6522  if ( minimum() != std::numeric_limits<double>::lowest() + 1 )
6523  code += QStringLiteral( ", minValue=%1" ).arg( minimum() );
6524  if ( maximum() != std::numeric_limits<double>::max() )
6525  code += QStringLiteral( ", maxValue=%1" ).arg( maximum() );
6527  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
6528  return code;
6529  }
6530  }
6531  return QString();
6532 }
6533 
6535 {
6536  return mParentParameterName;
6537 }
6538 
6539 void QgsProcessingParameterDistance::setParentParameterName( const QString &parentParameterName )
6540 {
6541  mParentParameterName = parentParameterName;
6542 }
6543 
6545 {
6546  QVariantMap map = QgsProcessingParameterNumber::toVariantMap();
6547  map.insert( QStringLiteral( "parent" ), mParentParameterName );
6548  map.insert( QStringLiteral( "default_unit" ), static_cast< int >( mDefaultUnit ) );
6549  return map;
6550 }
6551 
6553 {
6555  mParentParameterName = map.value( QStringLiteral( "parent" ) ).toString();
6556  mDefaultUnit = static_cast< QgsUnitTypes::DistanceUnit>( map.value( QStringLiteral( "default_unit" ), QgsUnitTypes::DistanceUnknownUnit ).toInt() );
6557  return true;
6558 }
6559 
6560 
6561 //
6562 // QgsProcessingParameterScale
6563 //
6564 
6565 QgsProcessingParameterScale::QgsProcessingParameterScale( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
6566  : QgsProcessingParameterNumber( name, description, Double, defaultValue, optional )
6567 {
6568 
6569 }
6570 
6572 {
6573  return new QgsProcessingParameterScale( *this );
6574 }
6575 
6577 {
6578  return typeName();
6579 }
6580 
6582 {
6583  switch ( outputType )
6584  {
6586  {
6587  QString code = QStringLiteral( "QgsProcessingParameterScale('%1', '%2'" ).arg( name(), description() );
6588  if ( mFlags & FlagOptional )
6589  code += QLatin1String( ", optional=True" );
6591  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
6592  return code;
6593  }
6594  }
6595  return QString();
6596 }
6597 
6598 QgsProcessingParameterScale *QgsProcessingParameterScale::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
6599 {
6600  return new QgsProcessingParameterScale( name, description, definition.isEmpty() ? QVariant()
6601  : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
6602 }
6603 
6604 
6605 //
6606 // QgsProcessingParameterLayout
6607 //
6608 
6609 QgsProcessingParameterLayout::QgsProcessingParameterLayout( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
6610  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
6611 {}
6612 
6614 {
6615  return new QgsProcessingParameterLayout( *this );
6616 }
6617 
6619 {
6620  if ( !value.isValid() || value.isNull() )
6621  return QStringLiteral( "None" );
6622 
6623  if ( value.canConvert<QgsProperty>() )
6624  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
6625 
6626  QString s = value.toString();
6628 }
6629 
6631 {
6632  QString code = QStringLiteral( "##%1=" ).arg( mName );
6633  if ( mFlags & FlagOptional )
6634  code += QLatin1String( "optional " );
6635  code += QLatin1String( "layout " );
6636 
6637  code += mDefault.toString();
6638  return code.trimmed();
6639 }
6640 
6642 {
6643  switch ( outputType )
6644  {
6646  {
6647  QString code = QStringLiteral( "QgsProcessingParameterLayout('%1', '%2'" ).arg( name(), description() );
6648  if ( mFlags & FlagOptional )
6649  code += QLatin1String( ", optional=True" );
6651  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
6652  return code;
6653  }
6654  }
6655  return QString();
6656 }
6657 
6658 QgsProcessingParameterLayout *QgsProcessingParameterLayout::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
6659 {
6660  QString def = definition;
6661 
6662  if ( def.startsWith( '"' ) || def.startsWith( '\'' ) )
6663  def = def.mid( 1 );
6664  if ( def.endsWith( '"' ) || def.endsWith( '\'' ) )
6665  def.chop( 1 );
6666 
6667  QVariant defaultValue = def;
6668  if ( def == QLatin1String( "None" ) )
6669  defaultValue = QVariant();
6670 
6671  return new QgsProcessingParameterLayout( name, description, defaultValue, isOptional );
6672 }
6673 
6674 
6675 //
6676 // QString mParentLayerParameterName;
6677 //
6678 
6679 QgsProcessingParameterLayoutItem::QgsProcessingParameterLayoutItem( const QString &name, const QString &description, const QVariant &defaultValue, const QString &parentLayoutParameterName, int itemType, bool optional )
6680  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
6681  , mParentLayoutParameterName( parentLayoutParameterName )
6682  , mItemType( itemType )
6683 {
6684 
6685 }
6686 
6688 {
6689  return new QgsProcessingParameterLayoutItem( *this );
6690 }
6691 
6693 {
6694  if ( !value.isValid() || value.isNull() )
6695  return QStringLiteral( "None" );
6696 
6697  if ( value.canConvert<QgsProperty>() )
6698  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
6699 
6700  QString s = value.toString();
6702 }
6703 
6705 {
6706  QString code = QStringLiteral( "##%1=" ).arg( mName );
6707  if ( mFlags & FlagOptional )
6708  code += QLatin1String( "optional " );
6709  code += QLatin1String( "layoutitem " );
6710  if ( mItemType >= 0 )
6711  code += QString::number( mItemType ) + ' ';
6712 
6713  code += mParentLayoutParameterName + ' ';
6714 
6715  code += mDefault.toString();
6716  return code.trimmed();
6717 }
6718 
6720 {
6721  switch ( outputType )
6722  {
6724  {
6725  QString code = QStringLiteral( "QgsProcessingParameterLayoutItem('%1', '%2'" ).arg( name(), description() );
6726  if ( mFlags & FlagOptional )
6727  code += QLatin1String( ", optional=True" );
6728 
6729  if ( mItemType >= 0 )
6730  code += QStringLiteral( ", itemType=%1" ).arg( mItemType );
6731 
6732  code += QStringLiteral( ", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
6733 
6735  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
6736  return code;
6737  }
6738  }
6739  return QString();
6740 }
6741 
6743 {
6745  map.insert( QStringLiteral( "parent_layout" ), mParentLayoutParameterName );
6746  map.insert( QStringLiteral( "item_type" ), mItemType );
6747  return map;
6748 }
6749 
6751 {
6753  mParentLayoutParameterName = map.value( QStringLiteral( "parent_layout" ) ).toString();
6754  mItemType = map.value( QStringLiteral( "item_type" ) ).toInt();
6755  return true;
6756 }
6757 
6759 {
6760  QStringList depends;
6761  if ( !mParentLayoutParameterName.isEmpty() )
6762  depends << mParentLayoutParameterName;
6763  return depends;
6764 }
6765 
6766 QgsProcessingParameterLayoutItem *QgsProcessingParameterLayoutItem::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
6767 {
6768  QString parent;
6769  QString def = definition;
6770  int itemType = -1;
6771  QRegularExpression re( QStringLiteral( "(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
6772  QRegularExpressionMatch m = re.match( def );
6773  if ( m.hasMatch() )
6774  {
6775  itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
6776  parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
6777  def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
6778  }
6779  else
6780  {
6781  parent = def;
6782  def.clear();
6783  }
6784 
6785  return new QgsProcessingParameterLayoutItem( name, description, def.isEmpty() ? QVariant() : def, parent, itemType, isOptional );
6786 }
6787 
6789 {
6790  return mParentLayoutParameterName;
6791 }
6792 
6794 {
6795  mParentLayoutParameterName = name;
6796 }
6797 
6799 {
6800  return mItemType;
6801 }
6802 
6804 {
6805  mItemType = type;
6806 }
6807 
6808 //
6809 // QgsProcessingParameterColor
6810 //
6811 
6812 QgsProcessingParameterColor::QgsProcessingParameterColor( const QString &name, const QString &description, const QVariant &defaultValue, bool opacityEnabled, bool optional )
6813  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
6814  , mAllowOpacity( opacityEnabled )
6815 {
6816 
6817 }
6818 
6820 {
6821  return new QgsProcessingParameterColor( *this );
6822 }
6823 
6825 {
6826  if ( !value.isValid() || value.isNull() )
6827  return QStringLiteral( "None" );
6828 
6829  if ( value.canConvert<QgsProperty>() )
6830  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
6831 
6832  if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
6833  return QStringLiteral( "QColor()" );
6834 
6835  if ( value.canConvert< QColor >() )
6836  {
6837  QColor c = value.value< QColor >();
6838  if ( !mAllowOpacity || c.alpha() == 255 )
6839  return QStringLiteral( "QColor(%1, %2, %3)" ).arg( c.red() ).arg( c.green() ).arg( c.blue() );
6840  else
6841  return QStringLiteral( "QColor(%1, %2, %3, %4)" ).arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() );
6842  }
6843 
6844  QString s = value.toString();
6846 }
6847 
6849 {
6850  QString code = QStringLiteral( "##%1=" ).arg( mName );
6851  if ( mFlags & FlagOptional )
6852  code += QLatin1String( "optional " );
6853  code += QLatin1String( "color " );
6854 
6855  if ( mAllowOpacity )
6856  code += QLatin1String( "withopacity " );
6857 
6858  code += mDefault.toString();
6859  return code.trimmed();
6860 }
6861 
6863 {
6864  switch ( outputType )
6865  {
6867  {
6868  QString code = QStringLiteral( "QgsProcessingParameterColor('%1', '%2'" ).arg( name(), description() );
6869  if ( mFlags & FlagOptional )
6870  code += QLatin1String( ", optional=True" );
6871 
6872  code += QStringLiteral( ", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral( "True" ) : QStringLiteral( "False" ) );
6873 
6875  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
6876  return code;
6877  }
6878  }
6879  return QString();
6880 }
6881 
6883 {
6884  if ( !input.isValid() && ( mDefault.isValid() && ( !mDefault.toString().isEmpty() || mDefault.value< QColor >().isValid() ) ) )
6885  return true;
6886 
6887  if ( !input.isValid() )
6888  return mFlags & FlagOptional;
6889 
6890  if ( input.type() == QVariant::Color )
6891  {
6892  return true;
6893  }
6894  else if ( input.canConvert<QgsProperty>() )
6895  {
6896  return true;
6897  }
6898 
6899  if ( input.type() != QVariant::String || input.toString().isEmpty() )
6900  return mFlags & FlagOptional;
6901 
6902  bool containsAlpha = false;
6903  return QgsSymbolLayerUtils::parseColorWithAlpha( input.toString(), containsAlpha ).isValid();
6904 }
6905 
6907 {
6909  map.insert( QStringLiteral( "opacityEnabled" ), mAllowOpacity );
6910  return map;
6911 }
6912 
6913 bool QgsProcessingParameterColor::fromVariantMap( const QVariantMap &map )
6914 {
6916  mAllowOpacity = map.value( QStringLiteral( "opacityEnabled" ) ).toBool();
6917  return true;
6918 }
6919 
6921 {
6922  return mAllowOpacity;
6923 }
6924 
6926 {
6927  mAllowOpacity = enabled;
6928 }
6929 
6930 QgsProcessingParameterColor *QgsProcessingParameterColor::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
6931 {
6932  QString def = definition;
6933 
6934  bool allowOpacity = false;
6935  if ( def.startsWith( QLatin1String( "withopacity" ), Qt::CaseInsensitive ) )
6936  {
6937  allowOpacity = true;
6938  def = def.mid( 12 );
6939  }
6940 
6941  if ( def.startsWith( '"' ) || def.startsWith( '\'' ) )
6942  def = def.mid( 1 );
6943  if ( def.endsWith( '"' ) || def.endsWith( '\'' ) )
6944  def.chop( 1 );
6945 
6946  QVariant defaultValue = def;
6947  if ( def == QLatin1String( "None" ) )
6948  defaultValue = QVariant();
6949 
6950  return new QgsProcessingParameterColor( name, description, defaultValue, allowOpacity, isOptional );
6951 }
6952 
6953 //
6954 // QgsProcessingParameterCoordinateOperation
6955 //
6956 QgsProcessingParameterCoordinateOperation::QgsProcessingParameterCoordinateOperation( const QString &name, const QString &description, const QVariant &defaultValue, const QString &sourceCrsParameterName, const QString &destinationCrsParameterName, const QVariant &staticSourceCrs, const QVariant &staticDestinationCrs, bool optional )
6957  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
6958  , mSourceParameterName( sourceCrsParameterName )
6959  , mDestParameterName( destinationCrsParameterName )
6960  , mSourceCrs( staticSourceCrs )
6961  , mDestCrs( staticDestinationCrs )
6962 {
6963 
6964 }
6965 
6967 {
6968  return new QgsProcessingParameterCoordinateOperation( * this );
6969 }
6970 
6972 {
6973  if ( !value.isValid() || value.isNull() )
6974  return QStringLiteral( "None" );
6975 
6976  if ( value.canConvert<QgsCoordinateReferenceSystem>() )
6977  {
6978  if ( !value.value< QgsCoordinateReferenceSystem >().isValid() )
6979  return QStringLiteral( "QgsCoordinateReferenceSystem()" );
6980  else
6981  return QStringLiteral( "QgsCoordinateReferenceSystem('%1')" ).arg( value.value< QgsCoordinateReferenceSystem >().authid() );
6982  }
6983 
6984  if ( value.canConvert<QgsProperty>() )
6985  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
6986 
6987  QVariantMap p;
6988  p.insert( name(), value );
6989  QgsMapLayer *layer = QgsProcessingParameters::parameterAsLayer( this, p, context );
6990  if ( layer )
6992 
6993  QString s = value.toString();
6995 }
6996 
6998 {
6999  QString code = QStringLiteral( "##%1=" ).arg( mName );
7000  if ( mFlags & FlagOptional )
7001  code += QLatin1String( "optional " );
7002  code += QLatin1String( "coordinateoperation " );
7003 
7004  code += mDefault.toString();
7005  return code.trimmed();
7006 }
7007 
7009 {
7010  switch ( outputType )
7011  {
7013  {
7015  QString code = QStringLiteral( "QgsProcessingParameterCoordinateOperation('%1', '%2'" ).arg( name(), description() );
7016  if ( mFlags & FlagOptional )
7017  code += QLatin1String( ", optional=True" );
7018  if ( !mSourceParameterName.isEmpty() )
7019  code += QStringLiteral( ", sourceCrsParameterName=%1" ).arg( valueAsPythonString( mSourceParameterName, c ) );
7020  if ( !mDestParameterName.isEmpty() )
7021  code += QStringLiteral( ", destinationCrsParameterName=%1" ).arg( valueAsPythonString( mDestParameterName, c ) );
7022 
7023  if ( mSourceCrs.isValid() )
7024  code += QStringLiteral( ", staticSourceCrs=%1" ).arg( valueAsPythonString( mSourceCrs, c ) );
7025  if ( mDestCrs.isValid() )
7026  code += QStringLiteral( ", staticDestinationCrs=%1" ).arg( valueAsPythonString( mDestCrs, c ) );
7027 
7028  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
7029  return code;
7030  }
7031  }
7032  return QString();
7033 }
7034 
7036 {
7037  QStringList res;
7038  if ( !mSourceParameterName.isEmpty() )
7039  res << mSourceParameterName;
7040  if ( !mDestParameterName.isEmpty() )
7041  res << mDestParameterName;
7042  return res;
7043 }
7044 
7046 {
7048  map.insert( QStringLiteral( "source_crs_parameter_name" ), mSourceParameterName );
7049  map.insert( QStringLiteral( "dest_crs_parameter_name" ), mDestParameterName );
7050  map.insert( QStringLiteral( "static_source_crs" ), mSourceCrs );
7051  map.insert( QStringLiteral( "static_dest_crs" ), mDestCrs );
7052  return map;
7053 }
7054 
7056 {
7058  mSourceParameterName = map.value( QStringLiteral( "source_crs_parameter_name" ) ).toString();
7059  mDestParameterName = map.value( QStringLiteral( "dest_crs_parameter_name" ) ).toString();
7060  mSourceCrs = map.value( QStringLiteral( "static_source_crs" ) );
7061  mDestCrs = map.value( QStringLiteral( "static_dest_crs" ) );
7062  return true;
7063 }
7064 
7065 QgsProcessingParameterCoordinateOperation *QgsProcessingParameterCoordinateOperation::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
7066 {
7067  QString def = definition;
7068 
7069  if ( def.startsWith( '"' ) || def.startsWith( '\'' ) )
7070  def = def.mid( 1 );
7071  if ( def.endsWith( '"' ) || def.endsWith( '\'' ) )
7072  def.chop( 1 );
7073 
7074  QVariant defaultValue = def;
7075  if ( def == QLatin1String( "None" ) )
7076  defaultValue = QVariant();
7077 
7078  return new QgsProcessingParameterCoordinateOperation( name, description, defaultValue, QString(), QString(), QVariant(), QVariant(), isOptional );
7079 }
7080 
7081 
7082 //
7083 // QgsProcessingParameterMapTheme
7084 //
7085 
7086 QgsProcessingParameterMapTheme::QgsProcessingParameterMapTheme( const QString &name, const QString &description, const QVariant &defaultValue, bool optional )
7087  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
7088 {
7089 
7090 }
7091 
7092 
7094 {
7095  return new QgsProcessingParameterMapTheme( *this );
7096 }
7097 
7099 {
7100  if ( !input.isValid() && !mDefault.isValid() )
7101  return mFlags & FlagOptional;
7102 
7103  if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7104  || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) )
7105  return mFlags & FlagOptional;
7106 
7107  return true;
7108 }
7109 
7111 {
7112  if ( !value.isValid() )
7113  return QStringLiteral( "None" );
7114 
7115  if ( value.canConvert<QgsProperty>() )
7116  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
7117 
7118  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
7119 }
7120 
7122 {
7123  QString code = QStringLiteral( "##%1=" ).arg( mName );
7124  if ( mFlags & FlagOptional )
7125  code += QLatin1String( "optional " );
7126  code += QLatin1String( "maptheme " );
7127 
7128  code += mDefault.toString();
7129  return code.trimmed();
7130 }
7131 
7133 {
7134  switch ( outputType )
7135  {
7137  {
7138  QString code = QStringLiteral( "QgsProcessingParameterMapTheme('%1', '%2'" ).arg( name(), description() );
7139  if ( mFlags & FlagOptional )
7140  code += QLatin1String( ", optional=True" );
7141 
7143  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
7144 
7145  return code;
7146  }
7147  }
7148  return QString();
7149 }
7150 
7152 {
7154  return map;
7155 }
7156 
7158 {
7160  return true;
7161 }
7162 
7163 QgsProcessingParameterMapTheme *QgsProcessingParameterMapTheme::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
7164 {
7165  QString parent;
7166 
7167  QString def = definition;
7168  if ( def.startsWith( '"' ) || def.startsWith( '\'' ) )
7169  def = def.mid( 1 );
7170  if ( def.endsWith( '"' ) || def.endsWith( '\'' ) )
7171  def.chop( 1 );
7172 
7173  QVariant defaultValue = def;
7174 
7175  if ( defaultValue == QLatin1String( "None" ) || defaultValue.toString().isEmpty() )
7176  defaultValue = QVariant();
7177 
7178  return new QgsProcessingParameterMapTheme( name, description, defaultValue, isOptional );
7179 }
7180 
7181 
7182 //
7183 // QgsProcessingParameterDateTime
7184 //
7185 
7186 QgsProcessingParameterDateTime::QgsProcessingParameterDateTime( const QString &name, const QString &description, Type type, const QVariant &defaultValue, bool optional, const QDateTime &minValue, const QDateTime &maxValue )
7187  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
7188  , mMin( minValue )
7189  , mMax( maxValue )
7190  , mDataType( type )
7191 {
7192  if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
7193  {
7194  QgsMessageLog::logMessage( QObject::tr( "Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg( name, mMin.toString(), mMax.toString() ), QObject::tr( "Processing" ) );
7195  }
7196 }
7197 
7199 {
7200  return new QgsProcessingParameterDateTime( *this );
7201 }
7202 
7204 {
7205  QVariant input = value;
7206  if ( !input.isValid() )
7207  {
7208  if ( !defaultValue().isValid() )
7209  return mFlags & FlagOptional;
7210 
7211  input = defaultValue();
7212  }
7213 
7214  if ( input.canConvert<QgsProperty>() )
7215  {
7216  return true;
7217  }
7218 
7219  if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
7220  return false;
7221 
7222  if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType == Time )
7223  return false;
7224 
7225  if ( input.type() == QVariant::String )
7226  {
7227  QString s = input.toString();
7228  if ( s.isEmpty() )
7229  return mFlags & FlagOptional;
7230 
7231  input = QDateTime::fromString( s, Qt::ISODate );
7232  if ( mDataType == Time )
7233  {
7234  if ( !input.toDateTime().isValid() )
7235  input = QTime::fromString( s );
7236  else
7237  input = input.toDateTime().time();
7238  }
7239  }
7240 
7241  if ( mDataType != Time )
7242  {
7243  QDateTime res = input.toDateTime();
7244  return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
7245  }
7246  else
7247  {
7248  QTime res = input.toTime();
7249  return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
7250  }
7251 }
7252 
7254 {
7255  if ( !value.isValid() )
7256  return QStringLiteral( "None" );
7257 
7258  if ( value.canConvert<QgsProperty>() )
7259  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
7260 
7261  if ( value.type() == QVariant::DateTime )
7262  {
7263  const QDateTime dt = value.toDateTime();
7264  if ( !dt.isValid() )
7265  return QStringLiteral( "QDateTime()" );
7266  else
7267  return QStringLiteral( "QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
7268  .arg( dt.date().month() )
7269  .arg( dt.date().day() )
7270  .arg( dt.time().hour() )
7271  .arg( dt.time().minute() )
7272  .arg( dt.time().second() );
7273  }
7274  else if ( value.type() == QVariant::Date )
7275  {
7276  const QDate dt = value.toDate();
7277  if ( !dt.isValid() )
7278  return QStringLiteral( "QDate()" );
7279  else
7280  return QStringLiteral( "QDate(%1, %2, %3)" ).arg( dt.year() )
7281  .arg( dt.month() )
7282  .arg( dt.day() );
7283  }
7284  else if ( value.type() == QVariant::Time )
7285  {
7286  const QTime dt = value.toTime();
7287  if ( !dt.isValid() )
7288  return QStringLiteral( "QTime()" );
7289  else
7290  return QStringLiteral( "QTime(%4, %5, %6)" )
7291  .arg( dt.hour() )
7292  .arg( dt.minute() )
7293  .arg( dt.second() );
7294  }
7295  return value.toString();
7296 }
7297 
7299 {
7301  QStringList parts;
7302  if ( mMin.isValid() )
7303  parts << QObject::tr( "Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
7304  if ( mMax.isValid() )
7305  parts << QObject::tr( "Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
7306  if ( mDefault.isValid() )
7307  parts << QObject::tr( "Default value: %1" ).arg( mDataType == DateTime ? mDefault.toDateTime().toString( Qt::ISODate ) :
7308  ( mDataType == Date ? mDefault.toDate().toString( Qt::ISODate ) : mDefault.toTime( ).toString() ) );
7309  QString extra = parts.join( QLatin1String( "<br />" ) );
7310  if ( !extra.isEmpty() )
7311  text += QStringLiteral( "<p>%1</p>" ).arg( extra );
7312  return text;
7313 }
7314 
7316 {
7317  switch ( outputType )
7318  {
7320  {
7321  QString code = QStringLiteral( "QgsProcessingParameterDateTime('%1', '%2'" ).arg( name(), description() );
7322  if ( mFlags & FlagOptional )
7323  code += QLatin1String( ", optional=True" );
7324 
7325  code += QStringLiteral( ", type=%1" ).arg( mDataType == DateTime ? QStringLiteral( "QgsProcessingParameterDateTime.DateTime" )
7326  : mDataType == Date ? QStringLiteral( "QgsProcessingParameterDateTime.Date" )
7327  : QStringLiteral( "QgsProcessingParameterDateTime.Time" ) );
7328 
7330  if ( mMin.isValid() )
7331  code += QStringLiteral( ", minValue=%1" ).arg( valueAsPythonString( mMin, c ) );
7332  if ( mMax.isValid() )
7333  code += QStringLiteral( ", maxValue=%1" ).arg( valueAsPythonString( mMax, c ) );
7334  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
7335  return code;
7336  }
7337  }
7338  return QString();
7339 }
7340 
7342 {
7343  return mMin;
7344 }
7345 
7347 {
7348  mMin = min;
7349 }
7350 
7352 {
7353  return mMax;
7354 }
7355 
7357 {
7358  mMax = max;
7359 }
7360 
7362 {
7363  return mDataType;
7364 }
7365 
7367 {
7368  mDataType = dataType;
7369 }
7370 
7372 {
7374  map.insert( QStringLiteral( "min" ), mMin );
7375  map.insert( QStringLiteral( "max" ), mMax );
7376  map.insert( QStringLiteral( "data_type" ), mDataType );
7377  return map;
7378 }
7379 
7381 {
7383  mMin = map.value( QStringLiteral( "min" ) ).toDateTime();
7384  mMax = map.value( QStringLiteral( "max" ) ).toDateTime();
7385  mDataType = static_cast< Type >( map.value( QStringLiteral( "data_type" ) ).toInt() );
7386  return true;
7387 }
7388 
7389 QgsProcessingParameterDateTime *QgsProcessingParameterDateTime::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
7390 {
7391  return new QgsProcessingParameterDateTime( name, description, DateTime, definition.isEmpty() ? QVariant()
7392  : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional );
7393 }
7394 
7395 
7396 
7397 //
7398 // QgsProcessingParameterProviderConnection
7399 //
7400 
7401 QgsProcessingParameterProviderConnection::QgsProcessingParameterProviderConnection( const QString &name, const QString &description, const QString &provider, const QVariant &defaultValue, bool optional )
7402  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
7403  , mProviderId( provider )
7404 {
7405 
7406 }
7407 
7408 
7410 {
7411  return new QgsProcessingParameterProviderConnection( *this );
7412 }
7413 
7415 {
7416  if ( !input.isValid() && !mDefault.isValid() )
7417  return mFlags & FlagOptional;
7418 
7419  if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7420  || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) )
7421  return mFlags & FlagOptional;
7422 
7423  return true;
7424 }
7425 
7427 {
7428  if ( !value.isValid() )
7429  return QStringLiteral( "None" );
7430 
7431  if ( value.canConvert<QgsProperty>() )
7432  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
7433 
7434  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
7435 }
7436 
7438 {
7439  QString code = QStringLiteral( "##%1=" ).arg( mName );
7440  if ( mFlags & FlagOptional )
7441  code += QLatin1String( "optional " );
7442  code += QLatin1String( "providerconnection " );
7443  code += mProviderId + ' ';
7444 
7445  code += mDefault.toString();
7446  return code.trimmed();
7447 }
7448 
7450 {
7451  switch ( outputType )
7452  {
7454  {
7455  QString code = QStringLiteral( "QgsProcessingParameterProviderConnection('%1', '%2', '%3'" ).arg( name(), description(), mProviderId );
7456  if ( mFlags & FlagOptional )
7457  code += QLatin1String( ", optional=True" );
7458 
7460  code += QStringLiteral( ", defaultValue=%1)" ).arg( valueAsPythonString( mDefault, c ) );
7461 
7462  return code;
7463  }
7464  }
7465  return QString();
7466 }
7467 
7469 {
7471  map.insert( QStringLiteral( "provider" ), mProviderId );
7472  return map;
7473 }
7474 
7476 {
7478  mProviderId = map.value( QStringLiteral( "provider" ) ).toString();
7479  return true;
7480 }
7481 
7482 QgsProcessingParameterProviderConnection *QgsProcessingParameterProviderConnection::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
7483 {
7484  QString parent;
7485 
7486  QString def = definition;
7487  QString provider;
7488  if ( def.contains( ' ' ) )
7489  {
7490  provider = def.left( def.indexOf( ' ' ) );
7491  def = def.mid( def.indexOf( ' ' ) + 1 );
7492  }
7493  else
7494  {
7495  provider = def;
7496  def.clear();
7497  }
7498 
7499  if ( def.startsWith( '"' ) || def.startsWith( '\'' ) )
7500  def = def.mid( 1 );
7501  if ( def.endsWith( '"' ) || def.endsWith( '\'' ) )
7502  def.chop( 1 );
7503 
7504  QVariant defaultValue = def;
7505 
7506  if ( defaultValue == QLatin1String( "None" ) || defaultValue.toString().isEmpty() )
7507  defaultValue = QVariant();
7508 
7510 }
7511 
7512 
7513 //
7514 // QgsProcessingParameterDatabaseSchema
7515 //
7516 
7517 QgsProcessingParameterDatabaseSchema::QgsProcessingParameterDatabaseSchema( const QString &name, const QString &description, const QString &parentLayerParameterName, const QVariant &defaultValue, bool optional )
7518  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
7519  , mParentConnectionParameterName( parentLayerParameterName )
7520 {
7521 
7522 }
7523 
7524 
7526 {
7527  return new QgsProcessingParameterDatabaseSchema( *this );
7528 }
7529 
7531 {
7532  if ( !input.isValid() && !mDefault.isValid() )
7533  return mFlags & FlagOptional;
7534 
7535  if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7536  || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) )
7537  return mFlags & FlagOptional;
7538 
7539  return true;
7540 }
7541 
7543 {
7544  if ( !value.isValid() )
7545  return QStringLiteral( "None" );
7546 
7547  if ( value.canConvert<QgsProperty>() )
7548  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
7549 
7550  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
7551 }
7552 
7554 {
7555  QString code = QStringLiteral( "##%1=" ).arg( mName );
7556  if ( mFlags & FlagOptional )
7557  code += QLatin1String( "optional " );
7558  code += QLatin1String( "databaseschema " );
7559 
7560  code += mParentConnectionParameterName + ' ';
7561 
7562  code += mDefault.toString();
7563  return code.trimmed();
7564 }
7565 
7567 {
7568  switch ( outputType )
7569  {
7571  {
7572  QString code = QStringLiteral( "QgsProcessingParameterDatabaseSchema('%1', '%2'" ).arg( name(), description() );
7573  if ( mFlags & FlagOptional )
7574  code += QLatin1String( ", optional=True" );
7575 
7576  code += QStringLiteral( ", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7578  code += QStringLiteral( ", defaultValue=%1" ).arg( valueAsPythonString( mDefault, c ) );
7579 
7580  code += ')';
7581 
7582  return code;
7583  }
7584  }
7585  return QString();
7586 }
7587 
7589 {
7590  QStringList depends;
7591  if ( !mParentConnectionParameterName.isEmpty() )
7592  depends << mParentConnectionParameterName;
7593  return depends;
7594 }
7595 
7597 {
7598  return mParentConnectionParameterName;
7599 }
7600 
7602 {
7603  mParentConnectionParameterName = name;
7604 }
7605 
7607 {
7609  map.insert( QStringLiteral( "mParentConnectionParameterName" ), mParentConnectionParameterName );
7610  return map;
7611 }
7612 
7614 {
7616  mParentConnectionParameterName = map.value( QStringLiteral( "mParentConnectionParameterName" ) ).toString();
7617  return true;
7618 }
7619 
7620 QgsProcessingParameterDatabaseSchema *QgsProcessingParameterDatabaseSchema::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
7621 {
7622  QString parent;
7623  QString def = definition;
7624 
7625  QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*)$" ) );
7626  QRegularExpressionMatch m = re.match( def );
7627  if ( m.hasMatch() )
7628  {
7629  parent = m.captured( 1 ).trimmed();
7630  def = m.captured( 2 );
7631  }
7632  else
7633  {
7634  parent = def;
7635  def.clear();
7636  }
7637 
7638  return new QgsProcessingParameterDatabaseSchema( name, description, parent, def.isEmpty() ? QVariant() : def, isOptional );
7639 }
7640 
7641 //
7642 // QgsProcessingParameterDatabaseTable
7643 //
7644 
7645 QgsProcessingParameterDatabaseTable::QgsProcessingParameterDatabaseTable( const QString &name, const QString &description,
7646  const QString &connectionParameterName,
7647  const QString &schemaParameterName,
7648  const QVariant &defaultValue, bool optional, bool allowNewTableNames )
7649  : QgsProcessingParameterDefinition( name, description, defaultValue, optional )
7650  , mParentConnectionParameterName( connectionParameterName )
7651  , mParentSchemaParameterName( schemaParameterName )
7652  , mAllowNewTableNames( allowNewTableNames )
7653 {
7654 
7655 }
7656 
7657 
7659 {
7660  return new QgsProcessingParameterDatabaseTable( *this );
7661 }
7662 
7664 {
7665  if ( !input.isValid() && !mDefault.isValid() )
7666  return mFlags & FlagOptional;
7667 
7668  if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7669  || ( !input.isValid() && mDefault.type() == QVariant::String && mDefault.toString().isEmpty() ) )
7670  return mFlags & FlagOptional;
7671 
7672  return true;
7673 }
7674 
7676 {
7677  if ( !value.isValid() )
7678  return QStringLiteral( "None" );
7679 
7680  if ( value.canConvert<QgsProperty>() )
7681  return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() );
7682 
7683  return QgsProcessingUtils::stringToPythonLiteral( value.toString() );
7684 }
7685 
7687 {
7688  QString code = QStringLiteral( "##%1=" ).arg( mName );
7689  if ( mFlags & FlagOptional )
7690  code += QLatin1String( "optional " );
7691  code += QLatin1String( "databasetable " );
7692 
7693  code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral( "none" ) : mParentConnectionParameterName ) + ' ';
7694  code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral( "none" ) : mParentSchemaParameterName ) + ' ';
7695 
7696  code += mDefault.toString();
7697  return code.trimmed();
7698 }
7699 
7701 {
7702  switch ( outputType )
7703  {
7705  {
7706  QString code = QStringLiteral( "QgsProcessingParameterDatabaseTable('%1', '%2'" ).arg( name(), description() );
7707  if ( mFlags & FlagOptional )
7708  code += QLatin1String( ", optional=True" );
7709 
7710  if ( mAllowNewTableNames )
7711  code += QLatin1String( ", allowNewTableNames=True" );
7712 
7713  code += QStringLiteral( ", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7714  code += QStringLiteral( ", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
7716  code += QStringLiteral( ", defaultValue=%1" ).arg( valueAsPythonString( mDefault, c ) );
7717 
7718  code += ')';
7719 
7720  return code;
7721  }
7722  }
7723  return QString();
7724 }
7725 
7727 {
7728  QStringList depends;
7729  if ( !mParentConnectionParameterName.isEmpty() )
7730  depends << mParentConnectionParameterName;
7731  if ( !mParentSchemaParameterName.isEmpty() )
7732  depends << mParentSchemaParameterName;
7733  return depends;
7734 }
7735 
7737 {
7738  return mParentConnectionParameterName;
7739 }
7740 
7742 {
7743  mParentConnectionParameterName = name;
7744 }
7745 
7747 {
7748  return mParentSchemaParameterName;
7749 }
7750 
7752 {
7753  mParentSchemaParameterName = name;
7754 }
7755 
7757 {
7759  map.insert( QStringLiteral( "mParentConnectionParameterName" ), mParentConnectionParameterName );
7760  map.insert( QStringLiteral( "mParentSchemaParameterName" ), mParentSchemaParameterName );
7761  map.insert( QStringLiteral( "mAllowNewTableNames" ), mAllowNewTableNames );
7762  return map;
7763 }
7764 
7766 {
7768  mParentConnectionParameterName = map.value( QStringLiteral( "mParentConnectionParameterName" ) ).toString();
7769  mParentSchemaParameterName = map.value( QStringLiteral( "mParentSchemaParameterName" ) ).toString();
7770  mAllowNewTableNames = map.value( QStringLiteral( "mAllowNewTableNames" ), false ).toBool();
7771  return true;
7772 }
7773 
7774 QgsProcessingParameterDatabaseTable *QgsProcessingParameterDatabaseTable::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition )
7775 {
7776  QString connection;
7777  QString schema;
7778  QString def = definition;
7779 
7780  QRegularExpression re( QStringLiteral( "(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
7781  QRegularExpressionMatch m = re.match( def );
7782  if ( m.hasMatch() )
7783  {
7784  connection = m.captured( 1 ).trimmed();
7785  if ( connection == QLatin1String( "none" ) )
7786  connection.clear();
7787  schema = m.captured( 2 ).trimmed();
7788  if ( schema == QLatin1String( "none" ) )
7789  schema.clear();
7790  def = m.captured( 3 );
7791  }
7792 
7793  return new QgsProcessingParameterDatabaseTable( name, description, connection, schema, def.isEmpty() ? QVariant() : def, isOptional );
7794 }
7795 
7797 {
7798  return mAllowNewTableNames;
7799 }
7800 
7802 {
7803  mAllowNewTableNames = allowNewTableNames;
7804 }
QgsProcessingParameterPoint::fromScriptCode
static QgsProcessingParameterPoint * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:2954
QgsProcessingParameterDistance::parentParameterName
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:6534
QgsProcessingParameterRasterLayer::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4064
QgsProcessingParameterMapLayer::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:2553
QgsProcessingFeatureSourceDefinition::selectedFeaturesOnly
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
Definition: qgsprocessingparameters.h:122
QgsProcessingParameterMatrix
A table (matrix) parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1792
QgsProcessingParameterLayout::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:6641
QgsGeometry::lastError
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
Definition: qgsgeometry.cpp:2995
QgsProcessingParameterColor::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6819
QgsProcessingParameterDefinition::mHelp
QString mHelp
Parameter help.
Definition: qgsprocessingparameters.h:727
QgsProcessingParameterFeatureSink::toOutputDefinition
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Definition: qgsprocessingparameters.cpp:5450
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:89
QgsProcessingProvider::isSupportedOutputValue
virtual bool isSupportedOutputValue(const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error) const
Returns true if the specified outputValue is of a supported file format for the given destination par...
Definition: qgsprocessingprovider.cpp:120
QgsProcessingParameterFeatureSink::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5566
QgsProcessingParameterType::create
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
QgsProcessingParameterLayoutItem::setItemType
void setItemType(int type)
Sets the acceptable item type, or -1 if any item type is allowed.
Definition: qgsprocessingparameters.cpp:6803
QgsProcessingParameterBoolean::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:2406
QgsApplication::processingRegistry
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
Definition: qgsapplication.cpp:2253
QgsProcessingParameterDatabaseSchema::parentConnectionParameterName
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:7596
QgsProcessingParameters::parameterAsMatrix
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
Definition: qgsprocessingparameters.cpp:1619
QgsProcessingParameterFile::setFileFilter
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
Definition: qgsprocessingparameters.cpp:3311
qgsprocessingparametertype.h
QgsProcessingParameterColor::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:6848
QgsProcessingParameters::parameterAsCompatibleSourceLayerPath
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...
Definition: qgsprocessingparameters.cpp:741
QgsProcessingParameterVectorDestination::QgsProcessingParameterVectorDestination
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorDestination.
Definition: qgsprocessingparameters.cpp:6049
QgsProcessingParameterFileDestination::toOutputDefinition
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Definition: qgsprocessingparameters.cpp:5822
QgsProcessingParameterNumber::Double
@ Double
Double/float values.
Definition: qgsprocessingparameters.h:1967
QgsProcessingParameterField::String
@ String
Accepts string fields.
Definition: qgsprocessingparameters.h:2625
QgsProcessingParameterField::DataType
DataType
Field data types.
Definition: qgsprocessingparameters.h:2622
QgsPointXY::y
double y
Definition: qgspointxy.h:48
QgsProcessingUtils::defaultVectorExtension
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e....
Definition: qgsprocessingutils.cpp:1194
QgsProcessingParameterField::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4839
QgsProcessingUtils::createFeatureSink
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
Definition: qgsprocessingutils.cpp:695
QgsGeometry::transform
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
Definition: qgsgeometry.cpp:2813
QgsProcessingParameters::parameterAsCrs
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Definition: qgsprocessingparameters.cpp:956
QgsProcessingParameterVectorDestination::supportedOutputVectorLayerExtensions
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
Definition: qgsprocessingparameters.cpp:6209
QgsProcessingParameterDistance::setParentParameterName
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
Definition: qgsprocessingparameters.cpp:6539
QgsProcessingParameters::parameterAsConnectionName
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
Definition: qgsprocessingparameters.cpp:2028
QgsProcessingParameterDefinition::toVariantMap
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2357
QgsProcessingParameterGeometry::QgsProcessingParameterGeometry
QgsProcessingParameterGeometry(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &geometryTypes=QList< int >())
Constructor for QgsProcessingParameterGeometry.
Definition: qgsprocessingparameters.cpp:2959
QgsProcessingParameterRasterDestination::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3083
QgsProcessingParameterMultipleLayers::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:3515
QgsProcessingParameterEnum::allowMultiple
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
Definition: qgsprocessingparameters.cpp:4285
QgsProcessingParameterDistance::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.cpp:6497
QgsProcessingParameterFileDestination::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5892
QgsProcessingParameterField::Numeric
@ Numeric
Accepts numeric fields.
Definition: qgsprocessingparameters.h:2624
QgsProcessingParameterLayoutItem::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:6719
QgsProcessingParameterRasterLayer::QgsProcessingParameterRasterLayer
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
Definition: qgsprocessingparameters.cpp:4058
QgsProcessingParameterScale::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.cpp:6576
QgsProcessingParameterRasterDestination::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:5638
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsProcessingParameterDateTime::setMinimum
void setMinimum(const QDateTime &minimum)
Sets the minimum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:7346
QgsProcessingParameterNumber::setDataType
void setDataType(Type type)
Sets the acceptable data type for the parameter.
Definition: qgsprocessingparameters.cpp:3906
QgsProcessingParameterString::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4341
QgsFeatureRequest::GeometryAbortOnInvalid
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
Definition: qgsfeaturerequest.h:103
QgsProcessingUtils::variantToSource
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
Definition: qgsprocessingutils.cpp:349
QgsProcessingParameterDatabaseTable::parentConnectionParameterName
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:7736
QgsProcessingParameterGeometry::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3184
QgsProcessingParameterNumber::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3920
QgsProcessingParameterVectorDestination::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:3010
QgsProcessingParameterDefinition::mAlgorithm
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
Definition: qgsprocessingparameters.h:739
QgsProcessingParameterString::multiLine
bool multiLine() const
Returns true if the parameter allows multiline strings.
Definition: qgsprocessingparameters.cpp:4391
QgsProcessingParameterFolderDestination::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:5914
QgsProcessingParameterFile::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3326
QgsProcessingParameters::parameterAsEnums
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
Definition: qgsprocessingparameters.cpp:445
QgsRemappingSinkDefinition
Defines the parameters used to remap features when creating a QgsRemappingProxyFeatureSink.
Definition: qgsremappingproxyfeaturesink.h:38
QgsProcessingParameterBoolean::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:2411
QgsProcessingParameterDatabaseSchema::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:7553
QgsProcessingParameterMatrix::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3489
QgsProcessingParameters::isDynamic
static bool isDynamic(const QVariantMap &parameters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
Definition: qgsprocessingparameters.cpp:111
QgsProcessingParameters::parameterAsGeometry
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
Definition: qgsprocessingparameters.cpp:1420
QgsWkbTypes::NullGeometry
@ NullGeometry
Definition: qgswkbtypes.h:146
QgsProcessingParameterNumber
A numeric parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1960
QgsProcessingContext::project
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Definition: qgsprocessingcontext.h:105
QgsProcessingParameterFolderDestination::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:5909
QgsProcessingParameterRasterDestination::toOutputDefinition
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Definition: qgsprocessingparameters.cpp:5696
QgsProcessingParameterExpression::setParentLayerParameterName
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
Definition: qgsprocessingparameters.cpp:4550
QgsProcessingParameterFeatureSource::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:2749
QgsProcessingParameterDefinition::valueAsPythonString
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:2312
QgsLayout::itemByUuid
QgsLayoutItem * itemByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not...
Definition: qgslayout.cpp:238
QgsReferencedRectangle
A QgsRectangle with associated coordinate reference system.
Definition: qgsreferencedgeometry.h:74
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
QgsProcessingParameterVectorDestination::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:6061
QgsProcessingFeedback
Base class for providing feedback from a processing algorithm.
Definition: qgsprocessingfeedback.h:38
QgsProcessingParameterCoordinateOperation::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7045
QgsProcessingParameterFile::setExtension
void setExtension(const QString &extension)
Sets a file extension for the parameter.
Definition: qgsprocessingparameters.cpp:3300
QgsProcessingParameterDefinition::description
QString description() const
Returns the description for the parameter.
Definition: qgsprocessingparameters.h:474
QgsProcessingParameterMatrix::numberRows
int numberRows() const
Returns the fixed number of rows in the table.
Definition: qgsprocessingparameters.cpp:3460
QgsLayout::itemById
QgsLayoutItem * itemById(const QString &id) const
Returns a layout item given its id.
Definition: qgslayout.cpp:266
QgsProcessingDestinationParameter::originalProvider
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
Definition: qgsprocessingparameters.h:2865
QgsProcessingParameterField::setAllowMultiple
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
Definition: qgsprocessingparameters.cpp:4988
QgsProcessingParameterString::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4401
QgsProcessingParameterDatabaseTable::setAllowNewTableNames
void setAllowNewTableNames(bool allowed)
Sets whether the parameter allows users to enter names for a new (non-existing) tables.
Definition: qgsprocessingparameters.cpp:7801
QgsProcessingParameterVectorDestination::defaultFileExtension
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
Definition: qgsprocessingparameters.cpp:6153
QgsProcessingParameterAuthConfig::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4447
QgsProcessingParameterVectorLayer::fromScriptCode
static QgsProcessingParameterVectorLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4705
QgsProcessingParameterDistance::QgsProcessingParameterDistance
QgsProcessingParameterDistance(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDistance.
Definition: qgsprocessingparameters.cpp:6485
QgsProcessingParameterDatabaseTable::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:7700
QgsProcessingParameterMapTheme::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7151
QgsCoordinateReferenceSystem::WKT_PREFERRED
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
Definition: qgscoordinatereferencesystem.h:679
QgsProcessingParameterColor::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:6824
QgsProcessingParameterExpression::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4562
QgsProcessingParameterLayoutItem::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6750
QgsProcessingParameters::parameterAsDatabaseTableName
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
Definition: qgsprocessingparameters.cpp:2058
QgsGeometry::isNull
Q_GADGET bool isNull
Definition: qgsgeometry.h:126
QgsProcessingParameterDatabaseTable::parentSchemaParameterName
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:7746
QgsProcessingParameterMapTheme::QgsProcessingParameterMapTheme
QgsProcessingParameterMapTheme(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapTheme.
Definition: qgsprocessingparameters.cpp:7086
QgsPointXY::x
Q_GADGET double x
Definition: qgspointxy.h:47
QgsProcessingParameterCoordinateOperation::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:6997
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsProcessingParameterBand::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:6382
QgsProcessingParameters::parameterAsFields
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
Definition: qgsprocessingparameters.cpp:1873
QgsProcessingParameterMapTheme::fromScriptCode
static QgsProcessingParameterMapTheme * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:7163
QgsProcessingParameterMultipleLayers::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:3510
QgsProcessingParameterDefinition::flags
Flags flags() const
Returns any flags associated with the parameter.
Definition: qgsprocessingparameters.h:522
QgsProcessingParameterDefinition::mMetadata
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
Definition: qgsprocessingparameters.h:736
QgsProcessingParameterRasterDestination
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
Definition: qgsprocessingparameters.h:3066
QgsProcessingParameterExtent::QgsProcessingParameterExtent
QgsProcessingParameterExtent(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterExtent.
Definition: qgsprocessingparameters.cpp:2739
QgsProcessingParameterMapLayer::fromScriptCode
static QgsProcessingParameterMapLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:2635
QgsProcessingParameterColor::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:6882
QgsProcessingDestinationParameter::QgsProcessingDestinationParameter
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
Definition: qgsprocessingparameters.cpp:5957
QgsProcessingUtils::convertToCompatibleFormatAndLayerName
static QString convertToCompatibleFormatAndLayerName(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString &layerName, long long featureLimit=-1)
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
Definition: qgsprocessingutils.cpp:1121
QgsProcessingDestinationParameter::setCreateByDefault
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
Definition: qgsprocessingparameters.cpp:6044
QgsProcessingParameterFile::Folder
@ Folder
Parameter is a folder.
Definition: qgsprocessingparameters.h:1696
QgsProcessingParameterMapTheme
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
Definition: qgsprocessingparameters.h:3582
QgsProcessingParameterFile::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1712
QgsProcessingParameterProviderConnection::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:7426
QgsProcessingParameterField::setDefaultToAllFields
void setDefaultToAllFields(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
Definition: qgsprocessingparameters.cpp:4998
qgssymbollayerutils.h
QgsProcessingParameterField::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:4955
QgsProcessing::TypeVectorPolygon
@ TypeVectorPolygon
Vector polygon layers.
Definition: qgsprocessing.h:50
QgsProcessingParameterString::setMultiLine
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
Definition: qgsprocessingparameters.cpp:4396
QgsProcessingUtils::normalizeLayerSource
static QString normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
Definition: qgsprocessingutils.cpp:514
QgsProcessingParameterVectorDestination::fromScriptCode
static QgsProcessingParameterVectorDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:6275
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsRectangle::yMinimum
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:177
QgsProcessingParameterDistance::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6544
QgsProcessingOutputFile
A file output for processing algorithms.
Definition: qgsprocessingoutputs.h:386
QgsProcessingParameterCoordinateOperation::fromScriptCode
static QgsProcessingParameterCoordinateOperation * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:7065
QgsProcessingOutputVectorLayer
A vector layer output for processing algorithms.
Definition: qgsprocessingoutputs.h:180
QgsGeometry::fromPointXY
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
Definition: qgsgeometry.cpp:164
QgsProcessingParameterFeatureSink::dataType
QgsProcessing::SourceType dataType() const
Returns the layer type for sinks associated with the parameter.
Definition: qgsprocessingparameters.cpp:5536
QgsProcessingParameterBand::parentLayerParameterName
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:6427
QgsProcessingParameterMultipleLayers::layerType
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:3731
QgsProcessingParameterDatabaseTable::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:7675
QgsProcessingParameters::parameterAsLayer
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.
Definition: qgsprocessingparameters.cpp:759
QgsProcessingParameterVectorDestination::toOutputDefinition
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Definition: qgsprocessingparameters.cpp:6148
QgsProcessingParameterAuthConfig::QgsProcessingParameterAuthConfig
QgsProcessingParameterAuthConfig(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAuthConfig.
Definition: qgsprocessingparameters.cpp:4441
QgsProcessingProvider
Abstract base class for processing providers.
Definition: qgsprocessingprovider.h:35
QgsExpression::isValid
bool isValid() const
Checks if this expression is valid.
Definition: qgsexpression.cpp:197
QgsProcessingParameterProviderConnection::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7468
QgsGeometry::centroid
QgsGeometry centroid() const
Returns the center of mass of a geometry.
Definition: qgsgeometry.cpp:2138
QgsProcessingParameters::parameterAsExtentCrs
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
Definition: qgsprocessingparameters.cpp:1220
qgslayoutmanager.h
QgsProperty::asExpression
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
Definition: qgsproperty.cpp:332
QgsProcessingParameterLayoutItem::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3352
QgsProcessingParameters::parameterAsDate
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
Definition: qgsprocessingparameters.cpp:343
QgsProcessingDestinationParameter::isSupportedOutputValue
virtual bool isSupportedOutputValue(const QVariant &value, QgsProcessingContext &context, QString &error) const
Tests whether a value is a supported value for this parameter.
Definition: qgsprocessingparameters.cpp:6029
QgsProcessingParameterExpression::QgsProcessingParameterExpression
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
Definition: qgsprocessingparameters.cpp:4493
QgsProcessingParameterNumber::toolTip
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
Definition: qgsprocessingparameters.cpp:3841
QgsProcessingParameterVectorDestination::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:6176
QgsProcessingParameterMultipleLayers::minimumNumberInputs
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
Definition: qgsprocessingparameters.cpp:3741
QgsProcessingParameterVectorDestination::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3008
QgsReferencedGeometry
A QgsGeometry with associated coordinate reference system.
Definition: qgsreferencedgeometry.h:156
QgsProcessingParameterGeometry::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:2967
QgsProcessingParameterMapLayer::QgsProcessingParameterMapLayer
QgsProcessingParameterMapLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterMapLayer.
Definition: qgsprocessingparameters.cpp:2510
QgsProcessingParameterFeatureSink::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:5393
QgsProcessingParameterLimitedDataTypes
Can be inherited by parameters which require limits to their acceptable data types.
Definition: qgsprocessingparameters.h:2470
QgsProcessingParameterEnum::QgsProcessingParameterEnum
QgsProcessingParameterEnum(const QString &name, const QString &description=QString(), const QStringList &options=QStringList(), bool allowMultiple=false, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterEnum.
Definition: qgsprocessingparameters.cpp:4123
QgsProcessingFeatureSourceDefinition::flags
Flags flags
Flags which dictate source behavior.
Definition: qgsprocessingparameters.h:137
QgsProviderRegistry::fileMeshFilters
virtual QString fileMeshFilters() const
Returns mesh file filter string.
Definition: qgsproviderregistry.cpp:689
QgsProcessingParameterMultipleLayers::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1891
QgsProcessingParameterExpression::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4500
QgsProcessingParameterFile::fileFilter
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Definition: qgsprocessingparameters.cpp:3306
QgsProcessingParameterDefinition
Base class for the definition of processing parameters.
Definition: qgsprocessingparameters.h:331
QgsProcessingParameterLimitedDataTypes::QgsProcessingParameterLimitedDataTypes
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types.
Definition: qgsprocessingparameters.cpp:5287
QgsProcessing::TypeVectorLine
@ TypeVectorLine
Vector line layers.
Definition: qgsprocessing.h:49
QgsProcessingParameterMeshLayer::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:4778
QgsProcessingParameterGeometry::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2972
QgsProcessingParameterLayoutItem::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6742
QgsProcessingParameterFeatureSource
An input feature source (such as vector layers) parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2734
QgsProcessingParameterExpression::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:4525
QgsProcessingOutputLayerDefinition
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
Definition: qgsprocessingparameters.h:200
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QgsProcessingParameterBand::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6306
QgsProcessingParameterMatrix::setNumberRows
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
Definition: qgsprocessingparameters.cpp:3465
QgsProcessingParameterLayoutItem::setParentLayoutParameterName
void setParentLayoutParameterName(const QString &name)
Sets the name of the parent layout parameter.
Definition: qgsprocessingparameters.cpp:6793
QgsProcessingParameterMatrix::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3480
QgsProcessingParameterMapLayer
A map layer parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2578
QgsProcessingParameterLayout::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6613
QgsProcessing::sourceTypeToString
static QString sourceTypeToString(SourceType type)
Converts a source type to a string representation.
Definition: qgsprocessing.h:68
QgsProcessingParameterVectorLayer::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4693
QgsProcessingFeatureSourceDefinition::geometryCheck
QgsFeatureRequest::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
Definition: qgsprocessingparameters.h:147
QgsProcessingParameterNumber::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:3801
QgsApplication::instance
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
Definition: qgsapplication.cpp:411
QgsProcessingParameterFile::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:3277
QgsProcessingParameterColor::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:6862
QgsProcessingParameterRasterLayer::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:4113
QgsProcessingParameterFileDestination::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:5757
QgsProcessingUtils::LayerHint
LayerHint
Layer type hints.
Definition: qgsprocessingutils.h:137
QgsProcessingParameterFeatureSink::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5574
QgsFeatureRequest::InvalidGeometryCheck
InvalidGeometryCheck
Handling of features with invalid geometries.
Definition: qgsfeaturerequest.h:100
QgsFeatureRequest::GeometrySkipInvalid
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
Definition: qgsfeaturerequest.h:102
QgsProperty::propertyType
Type propertyType() const
Returns the property type.
Definition: qgsproperty.cpp:261
QgsProcessingParameterCrs::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2447
QgsProcessingUtils::encodeProviderKeyAndUri
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri()
Definition: qgsprocessingutils.cpp:137
QgsUnitTypes::DistanceUnit
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:68
QgsProperty::loadVariant
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
Definition: qgsproperty.cpp:733
QgsProcessingParameterLayout::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3312
QgsProcessingParameterFeatureSink::setSupportsAppend
void setSupportsAppend(bool supportsAppend)
Sets whether the sink supports appending features to an existing table.
Definition: qgsprocessingparameters.cpp:5623
QgsProcessingParameterString::fromScriptCode
static QgsProcessingParameterString * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4415
QgsCoordinateTransform::transform
QgsPointXY transform(const QgsPointXY &point, TransformDirection direction=ForwardTransform) const SIP_THROW(QgsCsException)
Transform the point from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:239
QgsProcessingParameterMultipleLayers::setMinimumNumberInputs
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
Definition: qgsprocessingparameters.cpp:3746
QgsProcessing::TypeVectorPoint
@ TypeVectorPoint
Vector point layers.
Definition: qgsprocessing.h:48
QgsProcessingUtils::stringToPythonLiteral
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
Definition: qgsprocessingutils.cpp:611
QgsProcessingParameterBand::fromScriptCode
static QgsProcessingParameterBand * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:6453
QgsMasterLayoutInterface::PrintLayout
@ PrintLayout
Individual print layout (QgsPrintLayout)
Definition: qgsmasterlayoutinterface.h:68
QgsProcessingParameterField::defaultToAllFields
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
Definition: qgsprocessingparameters.cpp:4993
QgsProcessingParameterMultipleLayers
A parameter for processing algorithms which accepts multiple map layers.
Definition: qgsprocessingparameters.h:1878
QgsProcessingParameterDatabaseSchema::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:7566
QgsProcessingParameters::parameterAsSchema
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
Definition: qgsprocessingparameters.cpp:2043
QgsProcessingParameters::parameterAsRasterLayer
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
Definition: qgsprocessingparameters.cpp:816
QgsProcessingDestinationParameter::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5964
QgsProcessingParameterProviderConnection::fromScriptCode
static QgsProcessingParameterProviderConnection * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:7482
QgsProcessingFeatureSourceDefinition::source
QgsProperty source
Source definition.
Definition: qgsprocessingparameters.h:117
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsProcessingParameterMapLayer::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:2683
QgsProcessingParameterVectorLayer::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:4666
QgsProcessingParameterMatrix::fromScriptCode
static QgsProcessingParameterMatrix * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:3498
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:144
QgsProcessingParameterField::allowMultiple
bool allowMultiple() const
Returns whether multiple field selections are permitted.
Definition: qgsprocessingparameters.cpp:4983
QgsProperty::value
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...
Definition: qgsproperty.cpp:519
QgsProcessingParameterDateTime::toolTip
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
Definition: qgsprocessingparameters.cpp:7298
QgsProcessingParameterMeshLayer::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2558
QgsProcessingParameterField::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4799
QgsProcessingParameterDatabaseTable::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7756
QgsProcessingParameterDatabaseTable::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:7658
QgsCoordinateTransform::transformBoundingBox
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, TransformDirection direction=ForwardTransform, bool handle180Crossover=false) const SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:511
qgsDoubleToString
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition: qgis.h:275
QgsProcessingParameters::parameterFromVariantMap
static QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map.
Definition: qgsprocessingparameters.cpp:2073
QgsProcessingParameterMapLayer::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:2589
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsProcessingParameterCoordinateOperation::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:7035
QgsProcessingParameterMapLayer::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2715
QgsProcessingParameterExpression::fromScriptCode
static QgsProcessingParameterExpression * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4569
QgsProcessingParameterRange::setDataType
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
Definition: qgsprocessingparameters.cpp:4033
QgsProcessingUtils::LayerHint::Raster
@ Raster
Raster layer type.
QgsProcessingParameterFile::QgsProcessingParameterFile
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Behavior behavior=File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &fileFilter=QString())
Constructor for QgsProcessingParameterFile.
Definition: qgsprocessingparameters.cpp:3213
QgsProcessingParameterExtent::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2750
QgsProcessingParameterType
Makes metadata of processing parameters available.
Definition: qgsprocessingparametertype.h:34
QgsProcessingParameterLayout::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:6630
QgsProcessingParameterField::fromScriptCode
static QgsProcessingParameterField * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:5023
QgsProcessingParameterRange::dataType
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
Definition: qgsprocessingparameters.cpp:4028
QgsProcessingParameterNumber::dataType
Type dataType() const
Returns the acceptable data type for the parameter.
Definition: qgsprocessingparameters.cpp:3901
QgsProcessingParameterBand::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3239
QgsProcessingUtils::LayerHint::Mesh
@ Mesh
Mesh layer type, since QGIS 3.6.
qgsrasterfilewriter.h
QgsProcessingParameterAuthConfig
A string parameter for authentication configuration ID values.
Definition: qgsprocessingparameters.h:2384
QgsProcessingParameterColor
A color parameter for processing algorithms.
Definition: qgsprocessingparameters.h:3412
QgsProcessingParameterFeatureSink::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2910
QgsProcessingParameterDatabaseTable
A database table name parameter for processing algorithms, allowing users to select from existing dat...
Definition: qgsprocessingparameters.h:3862
QgsProcessingParameterRange::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:3947
QgsProcessingParameterFileDestination::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:5870
QgsProcessingParameterFile::File
@ File
Parameter is a single file.
Definition: qgsprocessingparameters.h:1695
QgsProcessingParameterFeatureSink::setDataType
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
Definition: qgsprocessingparameters.cpp:5561
QgsProcessingParameterRasterLayer::fromScriptCode
static QgsProcessingParameterRasterLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4118
QgsProcessingParameterFeatureSink
A feature sink output for processing algorithms.
Definition: qgsprocessingparameters.h:2895
QgsProcessingParameters::parameterAsRange
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
Definition: qgsprocessingparameters.cpp:1807
QgsProcessingDestinationParameter
Base class for all parameter definitions which represent file or layer destinations,...
Definition: qgsprocessingparameters.h:2774
qgsapplication.h
QgsProcessingParameterLayoutItem::fromScriptCode
static QgsProcessingParameterLayoutItem * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:6766
QgsProcessingParameterDateTime::setDataType
void setDataType(Type type)
Sets the acceptable data type for the parameter.
Definition: qgsprocessingparameters.cpp:7366
QgsProcessingParameterScale::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:6581
QgsProcessingParameterFeatureSink::generateTemporaryDestination
QString generateTemporaryDestination() const override
Generates a temporary destination value for this parameter.
Definition: qgsprocessingparameters.cpp:5582
QgsProcessingParameters::parameterAsFile
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
Definition: qgsprocessingparameters.cpp:1597
QgsProcessingParameterMeshLayer::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4719
QgsProcessingOutputLayerDefinition::loadVariant
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
Definition: qgsprocessingparameters.cpp:84
QgsMasterLayoutInterface::layoutType
virtual QgsMasterLayoutInterface::Type layoutType() const =0
Returns the master layout type.
QgsProcessingOutputDefinition
Base class for the definition of processing outputs.
Definition: qgsprocessingoutputs.h:42
QgsProcessingParameters::parameterAsLayerList
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
Definition: qgsprocessingparameters.cpp:1658
QgsProcessingParameterEnum::options
QStringList options() const
Returns the list of acceptable options for the parameter.
Definition: qgsprocessingparameters.cpp:4275
QgsProcessingParameterFile::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:3222
QgsProcessingParameterMapLayer::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2522
QgsProcessingFeatureSourceDefinition
Encapsulates settings relating to a feature source input to a processing algorithm.
Definition: qgsprocessingparameters.h:56
QgsRectangle::xMaximum
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:162
QgsProcessingParameterFeatureSink::hasGeometry
bool hasGeometry() const
Returns true if sink is likely to include geometries.
Definition: qgsprocessingparameters.cpp:5541
QgsProcessingParameterProviderConnection::QgsProcessingParameterProviderConnection
QgsProcessingParameterProviderConnection(const QString &name, const QString &description, const QString &provider, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterProviderConnection, for the specified provider type.
Definition: qgsprocessingparameters.cpp:7401
QgsProcessingParameterFeatureSource::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:5282
QgsProcessingParameterFile::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:3267
QgsProcessingParameterBand::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6437
QgsProcessingParameterFeatureSink::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:5478
QgsProcessingParameterFileDestination::setFileFilter
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
Definition: qgsprocessingparameters.cpp:5880
QgsProcessingParameterFile::fromScriptCode
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior=File)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:3335
QgsProcessingParameterRasterDestination::QgsProcessingParameterRasterDestination
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
Definition: qgsprocessingparameters.cpp:5628
QgsProcessingDestinationParameter::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5972
QgsProcessingParameterColor::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3427
QgsProcessingParameterString::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:4358
QgsProcessingParameterScale
A double numeric parameter for map scale values.
Definition: qgsprocessingparameters.h:2136
QgsProcessingParameterBand::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:6406
QgsProcessingParameters::parameterAsExtentGeometry
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...
Definition: qgsprocessingparameters.cpp:1102
QgsProcessingParameterDateTime::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:7253
QgsProcessingParameterVectorDestination::dataType
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
Definition: qgsprocessingparameters.cpp:6231
QgsProcessingParameterRange
A numeric range parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2170
QgsProcessingParameterMultipleLayers::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:3594
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
QgsProcessingParameterBand::QgsProcessingParameterBand
QgsProcessingParameterBand(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false, bool allowMultiple=false)
Constructor for QgsProcessingParameterBand.
Definition: qgsprocessingparameters.cpp:6298
QgsProcessingOutputLayerDefinition::setRemappingDefinition
void setRemappingDefinition(const QgsRemappingSinkDefinition &definition)
Sets the remapping definition to use when adding features to the output layer.
Definition: qgsprocessingparameters.cpp:68
QgsProcessingParameterCrs::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:2480
QgsProcessingParameterRange::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2184
QgsProcessingParameterLayout::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:6618
QgsPrintLayout
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Definition: qgsprintlayout.h:31
QgsProcessing::TypeMapLayer
@ TypeMapLayer
Any map layer type (raster or vector or mesh)
Definition: qgsprocessing.h:46
QgsProperty::toVariant
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
Definition: qgsproperty.cpp:695
QgsProcessingParameterVectorLayer::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4625
QgsProcessing::PythonQgsProcessingAlgorithmSubclass
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
Definition: qgsprocessing.h:60
QgsProcessingParameterRange::fromScriptCode
static QgsProcessingParameterRange * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4052
QgsProcessingParameters::parameterAsExtent
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.
Definition: qgsprocessingparameters.cpp:972
QgsGeometry::densifyByCount
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
Definition: qgsgeometry.cpp:2117
QgsProcessingParameterMultipleLayers::setLayerType
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:3736
QgsProcessingOutputLayerDefinition::toVariant
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
Definition: qgsprocessingparameters.cpp:74
QgsProcessing::TypeVector
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
Definition: qgsprocessing.h:53
QgsProcessingParameterDefinition::fromVariantMap
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2370
QgsRasterFileWriter::supportedFormatExtensions
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
Definition: qgsrasterfilewriter.cpp:1203
QgsProcessingParameterAuthConfig::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:4461
QgsProcessingParameterAuthConfig::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2396
qgsproviderregistry.h
QgsProcessingParameterFileDestination::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:5798
QgsProcessingParameterMapTheme::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:7110
QgsProcessingParameterDatabaseTable::fromScriptCode
static QgsProcessingParameterDatabaseTable * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:7774
QgsProcessingParameterMeshLayer
A mesh layer parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2544
QgsProcessingUtils::convertToCompatibleFormat
static QString convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1)
Converts a source vector layer to a file path of a vector layer of compatible format.
Definition: qgsprocessingutils.cpp:1116
QgsProcessingParameterVectorDestination::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6056
QgsProcessingParameterDistance::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:6510
QgsProcessingParameterBand::allowMultiple
bool allowMultiple() const
Returns whether multiple band selections are permitted.
Definition: qgsprocessingparameters.cpp:6340
QgsProcessingParameterDateTime::DateTime
@ DateTime
Datetime values.
Definition: qgsprocessingparameters.h:3631
QgsProcessingParameterBoolean::fromScriptCode
static QgsProcessingParameterBoolean * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:2431
QgsProcessingParameterCrs
A coordinate reference system parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1538
QgsProcessingParameterBand::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:6311
QgsProcessingParameterRasterLayer::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2235
QgsProcessingParameterPoint::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1615
QgsProcessingParameterDefinition::mFlags
Flags mFlags
Parameter flags.
Definition: qgsprocessingparameters.h:733
QgsProcessingParameterString::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4408
QgsProcessingParameterMapLayer::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2727
QgsProcessingParameterExtent::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1582
QgsProcessingParameters::parameterAsVectorLayer
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
Definition: qgsprocessingparameters.cpp:946
QgsProcessingParameters::parameterAsPoint
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
Definition: qgsprocessingparameters.cpp:1302
QgsProcessingParameters::parameterAsDateTime
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
Definition: qgsprocessingparameters.cpp:306
QgsProcessingParameterDatabaseTable::setParentSchemaParameterName
void setParentSchemaParameterName(const QString &name)
Sets the name of the parent schema parameter.
Definition: qgsprocessingparameters.cpp:7751
QgsProcessingParameterField::QgsProcessingParameterField
QgsProcessingParameterField(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), DataType type=Any, bool allowMultiple=false, bool optional=false, bool defaultToAllFields=false)
Constructor for QgsProcessingParameterField.
Definition: qgsprocessingparameters.cpp:4788
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:44
QgsProcessingParameterExpression::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4555
QgsProcessingParameterExtent::fromScriptCode
static QgsProcessingParameterExtent * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:2860
QgsProcessingParameterGeometry
A geometry parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1635
QgsProcessing::TypeMesh
@ TypeMesh
Mesh layers.
Definition: qgsprocessing.h:54
QgsProcessingParameterDefinition::toolTip
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
Definition: qgsprocessingparameters.cpp:2391
QgsProcessingOutputLayerDefinition::operator==
bool operator==(const QgsProcessingOutputLayerDefinition &other) const
Definition: qgsprocessingparameters.cpp:100
QgsProcessingParameterGeometry::fromScriptCode
static QgsProcessingParameterGeometry * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:3208
QgsProcessingParameterBand::setAllowMultiple
void setAllowMultiple(bool allowMultiple)
Sets whether multiple band selections are permitted.
Definition: qgsprocessingparameters.cpp:6345
QgsProcessingParameterMapLayer::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:2593
QgsProcessingParameterDefinition::mDescription
QString mDescription
Parameter description.
Definition: qgsprocessingparameters.h:724
QgsProcessingParameterDateTime::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7371
QgsProcessingParameterFileDestination::fromScriptCode
static QgsProcessingParameterFileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:5900
QgsProcessingParameterMultipleLayers::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:3642
QgsProcessingParameterDatabaseSchema::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7606
QgsProcessingParameterFileDestination
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
Definition: qgsprocessingparameters.h:3127
QgsProcessingParameterFeatureSink::supportedOutputVectorLayerExtensions
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
Definition: qgsprocessingparameters.cpp:5514
QgsProcessingParameterDatabaseTable::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7765
qgsprocessingalgorithm.h
QgsProcessingParameterDatabaseSchema::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:7542
QgsProcessingParameterFolderDestination::toOutputDefinition
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Definition: qgsprocessingparameters.cpp:5942
QgsProcessingParameterProviderConnection::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:7437
QgsProcessingParameterFile::extension
QString extension() const
Returns any specified file extension for the parameter.
Definition: qgsprocessingparameters.h:1738
QgsProcessingParameterDefinition::algorithm
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
Definition: qgsprocessingparameters.cpp:2381
QgsProcessingParameterFolderDestination::defaultFileExtension
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
Definition: qgsprocessingparameters.cpp:5947
QgsProcessingParameterField::parentLayerParameterName
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:4963
QgsProcessingParameterFeatureSink::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:5359
QgsMapLayer::extent
virtual QgsRectangle extent() const
Returns the extent of the layer.
Definition: qgsmaplayer.cpp:197
QgsProcessingParameters::parameterAsBoolean
static bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
Definition: qgsprocessingparameters.cpp:522
QgsProcessingParameterMatrix::setHasFixedNumberRows
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
Definition: qgsprocessingparameters.cpp:3475
QgsProcessingParameterPoint::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:2871
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:95
QgsProcessing::TypeRaster
@ TypeRaster
Raster layers.
Definition: qgsprocessing.h:51
QgsProcessingParameterExtent::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:2817
QgsProcessingParameterDefinition::name
QString name() const
Returns the name of the parameter.
Definition: qgsprocessingparameters.h:460
QgsProcessingParameterMeshLayer::fromScriptCode
static QgsProcessingParameterMeshLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4783
QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerName
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...
Definition: qgsprocessingparameters.cpp:746
QgsProcessingParameterVectorDestination::hasGeometry
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
Definition: qgsprocessingparameters.cpp:6236
QgsProcessingParameterField::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2642
QgsProcessingParameterVectorDestination::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:6095
QgsProcessingParameterDatabaseTable::QgsProcessingParameterDatabaseTable
QgsProcessingParameterDatabaseTable(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QString &schemaParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool allowNewTableNames=false)
Constructor for QgsProcessingParameterDatabaseTable.
Definition: qgsprocessingparameters.cpp:7645
QgsProcessingParameterDistance::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6552
QgsProcessingParameterScale::QgsProcessingParameterScale
QgsProcessingParameterScale(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterScale.
Definition: qgsprocessingparameters.cpp:6565
QgsProcessingParameterFolderDestination::fromScriptCode
static QgsProcessingParameterFolderDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:5952
QgsProcessingParameterLayoutItem
A print layout item parameter, allowing users to select a particular item from a print layout.
Definition: qgsprocessingparameters.h:3338
QgsProcessingParameterField::setDataType
void setDataType(DataType type)
Sets the acceptable data type for the field.
Definition: qgsprocessingparameters.cpp:4978
QgsProcessingOutputLayerDefinition::remappingDefinition
QgsRemappingSinkDefinition remappingDefinition() const
Returns the output remapping definition, if useRemapping() is true.
Definition: qgsprocessingparameters.h:263
QgsProcessingParameterField::setParentLayerParameterName
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
Definition: qgsprocessingparameters.cpp:4968
QgsProcessing::TypeVectorAnyGeometry
@ TypeVectorAnyGeometry
Any vector layer with geometry.
Definition: qgsprocessing.h:47
QgsProcessingParameterExtent::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:2745
QgsCoordinateReferenceSystem::authid
QString authid() const
Returns the authority identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1321
QgsProviderRegistry::fileRasterFilters
virtual QString fileRasterFilters() const
Returns raster file filter string.
Definition: qgsproviderregistry.cpp:684
QgsProcessingParameterField::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5013
QgsProcessingParameterNumber::maximum
double maximum() const
Returns the maximum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:3891
QgsProcessingParameterField::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:4908
QgsProcessingParameterMatrix::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:3349
QgsProcessingParameterDatabaseTable::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:7726
QgsProcessingParameters::parameterAsInts
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.
Definition: qgsprocessingparameters.cpp:249
QgsProcessingParameterString
A string parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2324
QgsProcessingParameterFileDestination::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:5762
QgsProcessingParameterDefinition::help
QString help() const
Returns the help for the parameter.
Definition: qgsprocessingparameters.h:492
QgsProcessingParameterGeometry::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:3133
QgsProcessingParameterMeshLayer::QgsProcessingParameterMeshLayer
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
Definition: qgsprocessingparameters.cpp:4710
QgsProcessingParameterField::DateTime
@ DateTime
Accepts datetime fields.
Definition: qgsprocessingparameters.h:2626
QgsProcessingParameterExtent
A rectangular map extent parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1570
QgsProcessingParameterBoolean::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:1521
QgsProcessingParameterString::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2337
QgsProcessingParameterCrs::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:2442
QgsProcessingParameterMultipleLayers::fromScriptCode
static QgsProcessingParameterMultipleLayers * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:3768
QgsProcessingParameterMatrix::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:3424
QgsCoordinateReferenceSystem::toWkt
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Definition: qgscoordinatereferencesystem.cpp:1954
QgsProcessingParameterMapLayer::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:2517
QgsProcessingRegistry::parameterType
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
Definition: qgsprocessingregistry.cpp:220
QgsProcessingParameterString::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:4372
QgsProcessingParameterEnum::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2270
QgsProcessingParameterMatrix::headers
QStringList headers() const
Returns a list of column headers (if set).
Definition: qgsprocessingparameters.cpp:3450
QgsCoordinateReferenceSystem::isValid
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Definition: qgscoordinatereferencesystem.cpp:924
QgsProcessingParameterRasterLayer
A raster layer parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2223
QgsProcessingParameterField::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5003
QgsProcessingParameterMapTheme::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:7093
QgsProcessingParameterLayoutItem::QgsProcessingParameterLayoutItem
QgsProcessingParameterLayoutItem(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayoutParameterName=QString(), int itemType=-1, bool optional=false)
Constructor for QgsProcessingParameterLayoutItem.
Definition: qgsprocessingparameters.cpp:6679
QgsProperty::valueAsString
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
Definition: qgsproperty.cpp:570
QgsProcessingParameters::parameterAsLayout
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
Definition: qgsprocessingparameters.cpp:1931
QgsProcessingParameters::parameterAsPointCrs
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
Definition: qgsprocessingparameters.cpp:1386
QgsVectorFileWriter::supportedFormatExtensions
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
Definition: qgsvectorfilewriter.cpp:3326
QgsProcessingParameterProviderConnection
A data provider connection parameter for processing algorithms, allowing users to select from availab...
Definition: qgsprocessingparameters.h:3741
QgsProcessingParameterLimitedDataTypes::setDataTypes
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:4676
QgsProcessing::TEMPORARY_OUTPUT
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file.
Definition: qgsprocessing.h:99
qgsvectorlayerfeatureiterator.h
QgsProcessingParameterDateTime::fromScriptCode
static QgsProcessingParameterDateTime * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:7389
QgsProcessingParameterVectorLayer::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4581
QgsProcessingParameterProviderConnection::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:7409
QgsProcessingParameterRasterDestination::fromScriptCode
static QgsProcessingParameterRasterDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:5744
QgsProcessingParameterFile
An input file or folder parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1689
QgsProcessingParameterEnum::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:4136
QgsProcessingParameterLimitedDataTypes::dataTypes
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:4671
QgsProcessingParameterBand::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:6350
QgsProcessingParameterNumber::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:3857
QgsProcessingParameterPoint::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:2920
QgsProcessingParameterRasterLayer::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:4069
QgsProcessingParameterVectorLayer
A vector layer (with or without geometry) parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2504
QgsProcessingParameterFeatureSource::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:5087
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:113
QgsRectangle::xMinimum
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:167
QgsProcessingParameterDatabaseSchema::QgsProcessingParameterDatabaseSchema
QgsProcessingParameterDatabaseSchema(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterDatabaseSchema.
Definition: qgsprocessingparameters.cpp:7517
QgsProcessingParameterEnum::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4303
QgsProcessingParameterFile::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:3227
QgsProcessingParameterFeatureSource::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2747
QgsRasterLayer
Represents a raster layer.
Definition: qgsrasterlayer.h:71
QgsProcessingParameters::parameterAsFileList
static QStringList parameterAsFileList(const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultip...
Definition: qgsprocessingparameters.cpp:1753
QgsProcessingParameterLayoutItem::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:3354
QgsProcessingParameterMatrix::QgsProcessingParameterMatrix
QgsProcessingParameterMatrix(const QString &name, const QString &description=QString(), int numberRows=3, bool hasFixedNumberRows=false, const QStringList &headers=QStringList(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMatrix.
Definition: qgsprocessingparameters.cpp:3340
QgsProcessingParameterPoint::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2876
QgsProcessingContext::LayerDetails
Details for layers to load into projects.
Definition: qgsprocessingcontext.h:231
QgsProcessingParameters::parameterAsGeometryCrs
static QgsCoordinateReferenceSystem parameterAsGeometryCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Returns the coordinate reference system associated with a geometry parameter value.
Definition: qgsprocessingparameters.cpp:1541
QgsProcessingParameterDatabaseTable::allowNewTableNames
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
Definition: qgsprocessingparameters.cpp:7796
QgsProcessingDestinationParameter::defaultFileExtension
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter.
QgsLayoutManager::layoutByName
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
Definition: qgslayoutmanager.cpp:124
QgsGeometry::fromWkt
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
Definition: qgsgeometry.cpp:154
QgsProcessingParameterFolderDestination::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3204
QgsProcessingParameterNumber::Integer
@ Integer
Integer values.
Definition: qgsprocessingparameters.h:1966
QgsProcessingParameterMeshLayer::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:4724
QgsProcessingParameterDateTime::Time
@ Time
Time values.
Definition: qgsprocessingparameters.h:3633
QgsProcessingParameterRange::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4045
qgsfileutils.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsProcessingParameterMatrix::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:3354
QgsProcessingParameterLayout
A print layout parameter, allowing users to select a print layout.
Definition: qgsprocessingparameters.h:3300
QgsProcessingParameterMapTheme::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:7098
QgsProcessingParameterScale::clone
QgsProcessingParameterScale * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6571
QgsProcessingParameterVectorDestination
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
Definition: qgsprocessingparameters.h:2993
QgsProcessingParameterDatabaseSchema
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
Definition: qgsprocessingparameters.h:3800
QgsProcessingParameterMeshLayer::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4763
QgsProcessingParameterField::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:2644
QgsReferencedPointXY
A QgsPointXY with associated coordinate reference system.
Definition: qgsreferencedgeometry.h:115
QgsProcessingParameterFeatureSink::QgsProcessingParameterFeatureSink
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true, bool supportsAppend=false)
Constructor for QgsProcessingParameterFeatureSink.
Definition: qgsprocessingparameters.cpp:5347
QgsProcessingParameterDistance
A double numeric parameter for distance values.
Definition: qgsprocessingparameters.h:2063
QgsProcessingParameterExpression::parentLayerParameterName
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:4545
QgsProcessingParameterEnum::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:4249
QgsProcessingParameters::parameterFromScriptCode
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
Definition: qgsprocessingparameters.cpp:2161
QgsProcessingParameterFeatureSource::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:5082
QgsProcessingParameterPoint
A point parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1603
QgsProcessingParameterFileDestination::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5885
QgsProcessingParameterBoolean::QgsProcessingParameterBoolean
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
Definition: qgsprocessingparameters.cpp:2402
QgsProcessingParameterMultipleLayers::QgsProcessingParameterMultipleLayers
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
Definition: qgsprocessingparameters.cpp:3503
QgsProcessingParameterLayoutItem::itemType
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
Definition: qgsprocessingparameters.cpp:6798
QgsProcessingParameterRasterDestination::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:5672
QgsProcessingParameterCoordinateOperation::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7055
parameterAsCompatibleSourceLayerPathInternal
QString parameterAsCompatibleSourceLayerPathInternal(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName)
Definition: qgsprocessingparameters.cpp:667
QgsProcessingParameterMatrix::setHeaders
void setHeaders(const QStringList &headers)
Sets the list of column headers.
Definition: qgsprocessingparameters.cpp:3455
qgsmeshlayer.h
qgsvectorlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:44
QgsProcessingParameters::parameterAsMeshLayer
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
Definition: qgsprocessingparameters.cpp:826
QgsProcessingParameterFeatureSource::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:5225
QgsProcessingParameterGeometry::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:1651
QgsProcessingParameterRange::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:3987
QgsProcessingParameterFileDestination::QgsProcessingParameterFileDestination
QgsProcessingParameterFileDestination(const QString &name, const QString &description=QString(), const QString &fileFilter=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFileDestination.
Definition: qgsprocessingparameters.cpp:5750
QgsProcessingParameterDistance::clone
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6492
QgsProcessingParameterAuthConfig::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4452
QgsProcessingParameterFileDestination::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3145
QgsProcessingParameterRange::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:3942
QgsGeometry::asPoint
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
Definition: qgsgeometry.cpp:1544
QgsProcessingParameterDateTime::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7380
qgsprocessingoutputs.h
qgsprocessingutils.h
qgsprocessingparameters.h
QgsProcessingParameterDefinition::mName
QString mName
Parameter name.
Definition: qgsprocessingparameters.h:721
QgsProcessingParameterFeatureSource::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5305
QgsReferencedGeometryBase::crs
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
Definition: qgsreferencedgeometry.h:53
QgsMapLayer::source
QString source() const
Returns the source for the layer.
Definition: qgsmaplayer.cpp:192
QgsProcessingUtils::LayerHint::Vector
@ Vector
Vector layer type.
qgsreferencedgeometry.h
QgsProcessingParameterDatabaseTable::setParentConnectionParameterName
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
Definition: qgsprocessingparameters.cpp:7741
QgsProcessingParameterColor::fromScriptCode
static QgsProcessingParameterColor * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:6930
QgsProcessingParameterNumber::minimum
double minimum() const
Returns the minimum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:3881
QgsProcessingFeatureSourceDefinition::featureLimit
long long featureLimit
If set to a value > 0, places a limit on the maximum number of features which will be read from the s...
Definition: qgsprocessingparameters.h:130
QgsProcessingParameterLayoutItem::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6687
QgsProcessingParameterDatabaseSchema::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:7525
QgsProcessingParameterDateTime::dataType
Type dataType() const
Returns the acceptable data type for the parameter.
Definition: qgsprocessingparameters.cpp:7361
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:143
QgsReferencedGeometry::fromReferencedRect
static QgsReferencedGeometry fromReferencedRect(const QgsReferencedRectangle &rectangle)
Construct a new QgsReferencedGeometry from referenced rectangle.
Definition: qgsreferencedgeometry.cpp:64
QgsGeometry::asWkt
QString asWkt(int precision=17) const
Exports the geometry to WKT.
Definition: qgsgeometry.cpp:1288
QgsProcessingParameterColor::QgsProcessingParameterColor
QgsProcessingParameterColor(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool opacityEnabled=true, bool optional=false)
Constructor for QgsProcessingParameterColor.
Definition: qgsprocessingparameters.cpp:6812
QgsProcessingParameterEnum::fromScriptCode
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4311
QgsProcessingParameterBoolean
A boolean parameter for processing algorithms.
Definition: qgsprocessingparameters.h:1507
QgsProcessingParameterFeatureSource::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:5255
QgsProcessingParameterPoint::QgsProcessingParameterPoint
QgsProcessingParameterPoint(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPoint.
Definition: qgsprocessingparameters.cpp:2865
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsProcessingParameterFileDestination::defaultFileExtension
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
Definition: qgsprocessingparameters.cpp:5834
QgsProcessingOutputLayerDefinition::createOptions
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
Definition: qgsprocessingparameters.h:246
QgsProcessingParameterFeatureSink::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:2912
QgsRectangle::yMaximum
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:172
QgsProcessingParameterVectorLayer::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:4586
QgsProcessingContext::addLayerToLoadOnCompletion
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model.
Definition: qgsprocessingcontext.cpp:53
QgsProcessingParameterLayoutItem::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:6758
QgsProcessingDestinationParameter::supportsNonFileBasedOutput
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
Definition: qgsprocessingparameters.h:2803
QgsProcessingUtils::generateTempFilename
static QString generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
Definition: qgsprocessingutils.cpp:964
QgsProcessingParameterDateTime
A datetime (or pure date or time) parameter for processing algorithms.
Definition: qgsprocessingparameters.h:3625
QgsProcessingParameterCoordinateOperation::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:6971
QgsProcessingAlgorithm
Abstract base class for processing algorithms.
Definition: qgsprocessingalgorithm.h:52
QgsProcessingParameterExpression::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:4517
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
QgsProcessingParameterProviderConnection::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:7449
QgsProcessingParameterCoordinateOperation::QgsProcessingParameterCoordinateOperation
QgsProcessingParameterCoordinateOperation(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &sourceCrsParameterName=QString(), const QString &destinationCrsParameterName=QString(), const QVariant &staticSourceCrs=QVariant(), const QVariant &staticDestinationCrs=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCoordinateOperation.
Definition: qgsprocessingparameters.cpp:6956
QgsProcessingParameterMultipleLayers::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:3704
QgsProcessingParameterBand::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6445
QgsProcessingParameterCoordinateOperation::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:6966
QgsProcessingParameterNumber::setMaximum
void setMaximum(double maximum)
Sets the maximum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:3896
QgsProcessingParameterDatabaseTable::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:7663
QgsProcessingParameterCrs::fromScriptCode
static QgsProcessingParameterCrs * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:2505
QgsProcessingParameterDatabaseSchema::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:7530
c
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
Definition: porting_processing.dox:1
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsProcessingParameterMatrix::hasFixedNumberRows
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
Definition: qgsprocessingparameters.cpp:3470
QgsProcessingParameterRasterDestination::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:5633
QgsProcessingOutputRasterLayer
A raster layer output for processing algorithms.
Definition: qgsprocessingoutputs.h:218
QgsProcessingParameterColor::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6913
QgsProcessingParameterFile::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3317
QgsProcessingParameterGeometry::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3196
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsProcessingParameterExpression
An expression parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2416
createAllMapLayerFileFilter
QString createAllMapLayerFileFilter()
Definition: qgsprocessingparameters.cpp:2568
QgsProcessingParameterMapTheme::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7157
QgsProcessingParameterExpression::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2429
QgsProcessingParameterFeatureSink::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:5417
QgsProcessingParameterRasterDestination::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:5717
QgsProcessingParameterMapTheme::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:7121
QgsProcessingParameterLayoutItem::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:6692
QgsProcessingParameterField::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:4871
QgsProcessingParameterString::QgsProcessingParameterString
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
Definition: qgsprocessingparameters.cpp:4334
QgsSymbolLayerUtils::parseColorWithAlpha
static QColor parseColorWithAlpha(const QString &colorStr, bool &containsAlpha, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes,...
Definition: qgssymbollayerutils.cpp:3587
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsProcessingParameterVectorLayer::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4681
QgsProcessingParameterEnum::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4203
QgsProcessingParameters::parameterAsOutputLayer
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
Definition: qgsprocessingparameters.cpp:836
QgsProcessingParameterMultipleLayers::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3752
QgsProcessingParameterDatabaseSchema::setParentConnectionParameterName
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
Definition: qgsprocessingparameters.cpp:7601
QgsProcessingParameterString::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4346
QgsProcessingParameterDistance::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2079
QgsProcessingParameterField::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:4804
QgsProcessingContext::expressionContext
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition: qgsprocessingcontext.h:133
QgsProcessingUtils::variantToCrs
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
Definition: qgsprocessingutils.cpp:426
QgsProcessingParameterDefinition::asScriptCode
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:2323
QgsProcessingParameterDateTime::QgsProcessingParameterDateTime
QgsProcessingParameterDateTime(const QString &name, const QString &description=QString(), Type type=DateTime, const QVariant &defaultValue=QVariant(), bool optional=false, const QDateTime &minValue=QDateTime(), const QDateTime &maxValue=QDateTime())
Constructor for QgsProcessingParameterDateTime.
Definition: qgsprocessingparameters.cpp:7186
QgsProcessingParameterEnum::setAllowMultiple
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
Definition: qgsprocessingparameters.cpp:4290
QgsProcessingParameterFolderDestination::QgsProcessingParameterFolderDestination
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFolderDestination.
Definition: qgsprocessingparameters.cpp:5905
QgsProcessingParameterDatabaseSchema::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:7588
QgsProcessingParameterEnum::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:4233
QgsGeometry::fromRect
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
Definition: qgsgeometry.cpp:229
QgsProcessingParameterMultipleLayers::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3760
QgsProcessingParameterVectorLayer::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:2521
QgsProcessingFeatureSource
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
Definition: qgsprocessingutils.h:471
QgsProcessingParameterDatabaseSchema::fromScriptCode
static QgsProcessingParameterDatabaseSchema * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:7620
QgsProcessingParameterRange::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4038
qgsprintlayout.h
QgsProcessingParameterRange::QgsProcessingParameterRange
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
Definition: qgsprocessingparameters.cpp:3935
QgsProcessingParameterMatrix::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1806
qgssettings.h
QgsProcessingParameterFeatureSource::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:5138
QgsProcessingParameterExpression::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4505
QgsReferencedGeometry::fromReferencedPointXY
static QgsReferencedGeometry fromReferencedPointXY(const QgsReferencedPointXY &point)
Construct a new QgsReferencedGeometry from referenced point.
Definition: qgsreferencedgeometry.cpp:59
QgsProcessingParameterRasterDestination::supportedOutputRasterLayerExtensions
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter.
Definition: qgsprocessingparameters.cpp:5728
QgsProcessingParameterDateTime::Type
Type
Datetime data type.
Definition: qgsprocessingparameters.h:3630
QgsMessageLog::logMessage
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Definition: qgsmessagelog.cpp:27
QgsProcessingParameterDefinition::asPythonString
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:2333
QgsProcessingParameterBoolean::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1519
QgsProcessingParameterDateTime::setMaximum
void setMaximum(const QDateTime &maximum)
Sets the maximum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:7356
QgsProcessing::TypeFile
@ TypeFile
Files (i.e. non map layer sources, such as text files)
Definition: qgsprocessing.h:52
QgsProcessingParameterDistance::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:6502
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:145
QgsProcessingParameterGeometry::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:3100
QgsProcessingParameters::parameterAsLayoutItem
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...
Definition: qgsprocessingparameters.cpp:1955
QgsProcessingParameterDateTime::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:7198
QgsProcessingDestinationParameter::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:6006
QgsProcessingParameterBand
A raster band parameter for Processing algorithms.
Definition: qgsprocessingparameters.h:3225
QgsFeatureRequest::GeometryNoCheck
@ GeometryNoCheck
No invalid geometry checking.
Definition: qgsfeaturerequest.h:101
qgsprocessingcontext.h
QgsProcessingParameterLimitedDataTypes::mDataTypes
QList< int > mDataTypes
List of acceptable data types for the parameter.
Definition: qgsprocessingparameters.h:2493
QgsProcessingParameterFileDestination::fileFilter
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
Definition: qgsprocessingparameters.cpp:5875
QgsProcessingDestinationParameter::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:5980
QgsProcessingParameterNumber::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:3911
QgsProcessingParameterColor::setOpacityEnabled
void setOpacityEnabled(bool enabled)
Sets whether the parameter allows opacity control.
Definition: qgsprocessingparameters.cpp:6925
QgsProcessingParameterMultipleLayers::type
QString type() const override
Unique parameter type name.
Definition: qgsprocessingparameters.h:1893
QgsProcessingParameterDefinition::mDefault
QVariant mDefault
Default value for parameter.
Definition: qgsprocessingparameters.h:730
QgsGeometry::boundingBox
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Definition: qgsgeometry.cpp:996
QgsProcessingParameterVectorDestination::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6261
QgsProcessingParameterFeatureSink::supportsAppend
bool supportsAppend() const
Returns true if the sink supports appending features to an existing table.
Definition: qgsprocessingparameters.cpp:5618
QgsProcessingParameterRange::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:4008
QgsProviderRegistry::fileVectorFilters
virtual QString fileVectorFilters() const
Returns vector file filter string.
Definition: qgsproviderregistry.cpp:679
QgsProcessingUtils::mapLayerFromString
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType)
Interprets a string as a map layer within the supplied context.
Definition: qgsprocessingutils.cpp:316
QgsProcessingParameterVectorLayer::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2519
QgsProcessingParameterScale::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2149
QgsProcessingParameterBand::setParentLayerParameterName
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
Definition: qgsprocessingparameters.cpp:6432
QgsProperty::staticValue
QVariant staticValue() const
Returns the current static value for the property.
Definition: qgsproperty.cpp:284
QgsProcessingParameterFeatureSink::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:5502
QgsProcessingParameters::parameterAsFileOutput
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
Definition: qgsprocessingparameters.cpp:903
QgsProcessingParameterFeatureSource::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:5293
QgsProcessingParameterMatrix::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:3379
QgsProcessingParameterMultipleLayers::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:3683
QgsProcessingParameterCoordinateOperation::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:3490
QgsProcessingParameterGeometry::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:3039
QgsProcessingParameterFeatureSource::fromScriptCode
static QgsProcessingParameterFeatureSource * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:5317
QgsProcessingParameterNumber::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:3806
QgsProcessingParameters::parameterAsExpression
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
Definition: qgsprocessingparameters.cpp:152
QgsProcessingParameters::parameterAsSink
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.
Definition: qgsprocessingparameters.cpp:562
QgsProcessingParameterLayoutItem::parentLayoutParameterName
QString parentLayoutParameterName() const
Returns the name of the parent layout parameter, or an empty string if this is not set.
Definition: qgsprocessingparameters.cpp:6788
QgsProcessingParameterDefinition::provider
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
Definition: qgsprocessingparameters.cpp:2386
QgsProcessingParameterCrs::QgsProcessingParameterCrs
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
Definition: qgsprocessingparameters.cpp:2436
QgsProcessingParameterVectorDestination::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:6119
QgsProcessingParameters::parameterAsColor
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 ...
Definition: qgsprocessingparameters.cpp:1981
QgsProcessingParameterDefinition::type
virtual QString type() const =0
Unique parameter type name.
QgsProject::layoutManager
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
Definition: qgsproject.cpp:3050
QgsMasterLayoutInterface
Interface for master layout type objects, such as print layouts and reports.
Definition: qgsmasterlayoutinterface.h:43
QgsProcessingParameterEnum
An enum based parameter for processing algorithms, allowing for selection from predefined values.
Definition: qgsprocessingparameters.h:2256
QgsProcessingParameterEnum::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:4295
QgsProcessingOutputLayerDefinition::sink
QgsProperty sink
Sink/layer definition.
Definition: qgsprocessingparameters.h:226
QgsProcessingParameterFileDestination::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:5848
QgsProcessingDestinationParameter::createByDefault
bool createByDefault() const
Returns true if the destination should be created by default.
Definition: qgsprocessingparameters.cpp:6039
QgsProcessingOutputHtml
A HTML file output for processing algorithms.
Definition: qgsprocessingoutputs.h:272
QgsProcessingOutputLayerDefinition::destinationName
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
Definition: qgsprocessingparameters.h:238
QgsProcessingParameterVectorDestination::createFileFilter
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
Definition: qgsprocessingparameters.cpp:6198
QgsProcessingParameterDatabaseSchema::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7613
QgsProcessingParameterColor::toVariantMap
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6906
qgsvectorfilewriter.h
QgsProcessingParameterDefinition::FlagOptional
@ FlagOptional
Parameter is optional.
Definition: qgsprocessingparameters.h:425
QgsProcessingParameterLayoutItem::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:6704
QgsProcessingParameterScale::fromScriptCode
static QgsProcessingParameterScale * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:6598
QgsProcessingParameterDefinition::QgsProcessingParameterDefinition
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
Definition: qgsprocessingparameters.cpp:2292
QgsProcessingParameterCoordinateOperation
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
Definition: qgsprocessingparameters.h:3476
QgsProcessingParameterDefinition::defaultValue
QVariant defaultValue() const
Returns the default value for the parameter.
Definition: qgsprocessingparameters.h:509
QgsProcessingParameters::descriptionFromName
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
Definition: qgsprocessingparameters.cpp:2154
QgsProcessingAlgorithm::provider
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
Definition: qgsprocessingalgorithm.cpp:128
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:105
QgsProcessingParameterField::Any
@ Any
Accepts any field.
Definition: qgsprocessingparameters.h:2623
QgsProcessingParameterNumber::Type
Type
Numeric data type.
Definition: qgsprocessingparameters.h:1965
QgsProperty::StaticProperty
@ StaticProperty
Static property (QgsStaticProperty)
Definition: qgsproperty.h:239
QgsProcessingParameterRasterDestination::defaultFileExtension
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
Definition: qgsprocessingparameters.cpp:5701
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53
QgsProcessing::PythonOutputType
PythonOutputType
Available Python output types.
Definition: qgsprocessing.h:59
QgsGeometry::type
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:127
QgsProcessingParameterCoordinateOperation::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:7008
QgsProcessingParameterField::dataType
DataType dataType() const
Returns the acceptable data type for the field.
Definition: qgsprocessingparameters.cpp:4973
QgsProcessingParameters::parameterAsEnum
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
Definition: qgsprocessingparameters.cpp:423
QgsProcessingParameterMapLayer::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:2594
QgsProcessingParameterFile::behavior
Behavior behavior() const
Returns the parameter behavior (e.g.
Definition: qgsprocessingparameters.h:1723
QgsProcessingParameterLayout::QgsProcessingParameterLayout
QgsProcessingParameterLayout(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterLayout.
Definition: qgsprocessingparameters.cpp:6609
QgsProcessingParameterBand::dependsOnOtherParameters
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.cpp:6398
QgsProcessingParameterAuthConfig::fromScriptCode
static QgsProcessingParameterAuthConfig * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:4472
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition: qgsproviderregistry.cpp:48
qgsprocessingprovider.h
QgsProcessingOutputFolder
A folder output for processing algorithms.
Definition: qgsprocessingoutputs.h:362
QgsProcessingParameterFeatureSink::defaultFileExtension
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
Definition: qgsprocessingparameters.cpp:5455
QgsProcessingUtils::defaultRasterExtension
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
Definition: qgsprocessingutils.cpp:1203
QgsProcessingParameterDefinition::checkValueIsAcceptable
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2300
qgsprocessingregistry.h
QgsProcessingParameterEnum::setOptions
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
Definition: qgsprocessingparameters.cpp:4280
QgsProcessingParameterVectorDestination::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:6268
QgsProcessingParameterNumber::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1984
QgsProcessingOutputLayerDefinition::operator!=
bool operator!=(const QgsProcessingOutputLayerDefinition &other) const
Definition: qgsprocessingparameters.cpp:106
QgsProcessing::SourceType
SourceType
Data source types enum.
Definition: qgsprocessing.h:45
QgsProcessingException
Custom exception class for processing related exceptions.
Definition: qgsexception.h:83
QgsProcessingParameterField
A vector layer or feature source field parameter for processing algorithms.
Definition: qgsprocessingparameters.h:2617
QgsProcessingParameterDateTime::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:7315
QgsRectangle::isNull
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
Definition: qgsrectangle.h:447
QgsProcessingParameterFeatureSink::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:5354
QgsProcessingParameterProviderConnection::fromVariantMap
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:7475
QgsProcessingParameterCrs::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:1550
QgsProcessingParameterBoolean::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:2421
QgsProcessingFeatureSourceDefinition::loadVariant
bool loadVariant(const QVariantMap &map)
Loads this source definition from a QVariantMap, wrapped in a QVariant.
Definition: qgsprocessingparameters.cpp:53
QgsProcessingParameters::parameterAsTime
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
Definition: qgsprocessingparameters.cpp:380
QgsProcessingParameterFeatureSink::fromScriptCode
static QgsProcessingParameterFeatureSink * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:5590
QgsProcessingOutputLayerDefinition::useRemapping
bool useRemapping() const
Returns true if the output uses a remapping definition.
Definition: qgsprocessingparameters.h:254
QgsProcessingParameterVectorLayer::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:4640
QgsProcessingParameterProviderConnection::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:7414
QgsFeatureSink
An interface for objects which accept features via addFeature(s) methods.
Definition: qgsfeaturesink.h:34
QgsProcessingParameterDateTime::Date
@ Date
Date values.
Definition: qgsprocessingparameters.h:3632
QgsProcessingParameters::parameterAsDouble
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
Definition: qgsprocessingparameters.cpp:180
QgsProcessingParameterRasterLayer::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:4098
QgsProcessingParameterLayout::fromScriptCode
static QgsProcessingParameterLayout * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:6658
QgsProcessingParameterNumber::fromScriptCode
static QgsProcessingParameterNumber * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Definition: qgsprocessingparameters.cpp:3929
QgsProcessingParameterNumber::setMinimum
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:3886
QgsProcessingDestinationParameter::generateTemporaryDestination
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
Definition: qgsprocessingparameters.cpp:6011
QgsProcessingParameterDatabaseTable::asScriptCode
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Definition: qgsprocessingparameters.cpp:7686
QgsProcessingParameters::parameterAsInt
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
Definition: qgsprocessingparameters.cpp:207
QgsProcessingParameterVectorDestination::setDataType
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
Definition: qgsprocessingparameters.cpp:6256
QgsProcessingParameters::parameterAsSource
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
Definition: qgsprocessingparameters.cpp:651
QgsProcessingFeatureSourceDefinition::toVariant
QVariant toVariant() const
Saves this source definition to a QVariantMap, wrapped in a QVariant.
Definition: qgsprocessingparameters.cpp:42
QgsProcessingParameterEnum::clone
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Definition: qgsprocessingparameters.cpp:4131
QgsProcessingParameterMapLayer::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameters.h:2591
QgsProcessingParameterDateTime::maximum
QDateTime maximum() const
Returns the maximum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:7351
QgsProcessingParameterDateTime::checkValueIsAcceptable
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:7203
QgsProcessingParameterFile::Behavior
Behavior
Parameter behavior.
Definition: qgsprocessingparameters.h:1694
QgsProcessingParameterMapTheme::asPythonString
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:7132
QgsProcessingParameterColor::opacityEnabled
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
Definition: qgsprocessingparameters.cpp:6920
QgsFileUtils::addExtensionFromFilter
static QString addExtensionFromFilter(const QString &fileName, const QString &filter)
Ensures that a fileName ends with an extension from the specified filter string.
Definition: qgsfileutils.cpp:86
QgsProcessingOutputLayerDefinition::destinationProject
QgsProject * destinationProject
Destination project.
Definition: qgsprocessingparameters.h:233
QgsProcessingUtils::LayerHint::UnknownType
@ UnknownType
Unknown layer type.
QgsProcessingParameterVectorLayer::QgsProcessingParameterVectorLayer
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
Definition: qgsprocessingparameters.cpp:4574
QgsProcessingParameterFeatureSource::QgsProcessingParameterFeatureSource
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
Definition: qgsprocessingparameters.cpp:5075
QgsProcessingParameterFolderDestination
A folder destination parameter, for specifying the destination path for a folder created by the algor...
Definition: qgsprocessingparameters.h:3190
QgsProcessingParameters::parameterAsBool
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
Definition: qgsprocessingparameters.cpp:514
QgsProcessingParameters::parameterAsString
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
Definition: qgsprocessingparameters.cpp:120
QgsProcessingParameterNumber::QgsProcessingParameterNumber
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Type type=Integer, const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterNumber.
Definition: qgsprocessingparameters.cpp:3789
QgsProcessingParameterDateTime::minimum
QDateTime minimum() const
Returns the minimum value acceptable by the parameter.
Definition: qgsprocessingparameters.cpp:7341
QgsProcessingParameterNumber::valueAsPythonString
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:3830