Skip to content

Commit bef88f3

Browse files
committed
Minor processing parameter evaluation refactoring
1 parent 9a1f129 commit bef88f3

File tree

3 files changed

+565
-20
lines changed

3 files changed

+565
-20
lines changed

python/core/auto_generated/processing/qgsprocessingparameters.sip.in

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,36 +491,85 @@ be evaluated once for every input feature processed.
491491
static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
492492
%Docstring
493493
Evaluates the parameter with matching ``definition`` to a static string value.
494+
%End
495+
496+
static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
497+
%Docstring
498+
Evaluates the parameter with matching ``definition`` and ``value`` to a static string value.
499+
500+
.. versionadded:: 3.4
494501
%End
495502

496503
static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
497504
%Docstring
498505
Evaluates the parameter with matching ``definition`` to an expression.
506+
%End
507+
508+
static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
509+
%Docstring
510+
Evaluates the parameter with matching ``definitionand`` ``value`` to an expression.
511+
512+
.. versionadded:: 3.4
499513
%End
500514

501515
static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
502516
%Docstring
503517
Evaluates the parameter with matching ``definition`` to a static double value.
518+
%End
519+
520+
static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
521+
%Docstring
522+
Evaluates the parameter with matching ``definition`` and ``value`` to a static double value.
523+
524+
.. versionadded:: 3.4
504525
%End
505526

506527
static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
507528
%Docstring
508529
Evaluates the parameter with matching ``definition`` to a static integer value.
530+
%End
531+
532+
static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
533+
%Docstring
534+
Evaluates the parameter with matching ``definition`` and ``value`` to a static integer value.
535+
536+
.. versionadded:: 3.4
509537
%End
510538

511539
static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
512540
%Docstring
513541
Evaluates the parameter with matching ``definition`` to a enum value.
542+
%End
543+
544+
static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
545+
%Docstring
546+
Evaluates the parameter with matching ``definition`` and ``value`` to a enum value.
547+
548+
.. versionadded:: 3.4
514549
%End
515550

516551
static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
517552
%Docstring
518553
Evaluates the parameter with matching ``definition`` to list of enum values.
554+
%End
555+
556+
static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
557+
%Docstring
558+
Evaluates the parameter with matching ``definition`` and ``value`` to list of enum values.
559+
560+
.. versionadded:: 3.4
519561
%End
520562

521563
static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, const QgsProcessingContext &context );
522564
%Docstring
523565
Evaluates the parameter with matching ``definition`` to a static boolean value.
566+
%End
567+
568+
static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
569+
%Docstring
570+
Evaluates the parameter with matching ``definition`` and ``value`` to a static boolean value.
571+
572+
.. versionadded:: 3.4
524573
%End
525574

526575
static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
@@ -538,6 +587,25 @@ argument will be set to a string which can be used to retrieve the layer corresp
538587
to the sink, e.g. via calling :py:func:`QgsProcessingUtils.mapLayerFromString()`
539588

540589
This function creates a new object and the caller takes responsibility for deleting the returned object.
590+
%End
591+
592+
static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value,
593+
const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
594+
QgsProcessingContext &context, QString &destinationIdentifier /Out/ ) /Factory/;
595+
%Docstring
596+
Evaluates the parameter with matching ``definition`` and ``value`` to a feature sink.
597+
598+
The ``fields``, ``geometryType`` and ``crs`` parameters dictate the properties
599+
of the resulting feature sink.
600+
601+
Sinks will either be taken from ``context``'s active project, or created from external
602+
providers and stored temporarily in the ``context``. The ``destinationIdentifier``
603+
argument will be set to a string which can be used to retrieve the layer corresponding
604+
to the sink, e.g. via calling :py:func:`QgsProcessingUtils.mapLayerFromString()`
605+
606+
This function creates a new object and the caller takes responsibility for deleting the returned object.
607+
608+
.. versionadded:: 3.4
541609
%End
542610

543611
static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context ) /Factory/;
@@ -548,6 +616,18 @@ Sources will either be taken from ``context``'s active project, or loaded from e
548616
sources and stored temporarily in the ``context``.
549617

550618
This function creates a new object and the caller takes responsibility for deleting the returned object.
619+
%End
620+
621+
static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context ) /Factory/;
622+
%Docstring
623+
Evaluates the parameter with matching ``definition`` and ``value`` to a feature source.
624+
625+
Sources will either be taken from ``context``'s active project, or loaded from external
626+
sources and stored temporarily in the ``context``.
627+
628+
This function creates a new object and the caller takes responsibility for deleting the returned object.
629+
630+
.. versionadded:: 3.4
551631
%End
552632

553633
static QString parameterAsCompatibleSourceLayerPath( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters,
@@ -572,6 +652,17 @@ Evaluates the parameter with matching ``definition`` to a map layer.
572652
Layers will either be taken from ``context``'s active project, or loaded from external
573653
sources and stored temporarily in the ``context``. In either case, callers do not
574654
need to handle deletion of the returned layer.
655+
%End
656+
657+
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
658+
%Docstring
659+
Evaluates the parameter with matching ``definition`` and ``value`` to a map layer.
660+
661+
Layers will either be taken from ``context``'s active project, or loaded from external
662+
sources and stored temporarily in the ``context``. In either case, callers do not
663+
need to handle deletion of the returned layer.
664+
665+
.. versionadded:: 3.4
575666
%End
576667

577668
static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
@@ -581,16 +672,41 @@ Evaluates the parameter with matching ``definition`` to a raster layer.
581672
Layers will either be taken from ``context``'s active project, or loaded from external
582673
sources and stored temporarily in the ``context``. In either case, callers do not
583674
need to handle deletion of the returned layer.
675+
%End
676+
677+
static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
678+
%Docstring
679+
Evaluates the parameter with matching ``definition`` and ``value`` to a raster layer.
680+
681+
Layers will either be taken from ``context``'s active project, or loaded from external
682+
sources and stored temporarily in the ``context``. In either case, callers do not
683+
need to handle deletion of the returned layer.
684+
685+
.. versionadded:: 3.4
584686
%End
585687

586688
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
587689
%Docstring
588690
Evaluates the parameter with matching ``definition`` to a output layer destination.
691+
%End
692+
693+
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
694+
%Docstring
695+
Evaluates the parameter with matching ``definition`` and ``value`` to a output layer destination.
696+
697+
.. versionadded:: 3.4
589698
%End
590699

591700
static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
592701
%Docstring
593702
Evaluates the parameter with matching ``definition`` to a file based output destination.
703+
%End
704+
705+
static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
706+
%Docstring
707+
Evaluates the parameter with matching ``definition`` and ``value`` to a file based output destination.
708+
709+
.. versionadded:: 3.4
594710
%End
595711

596712
static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
@@ -600,11 +716,29 @@ Evaluates the parameter with matching ``definition`` to a vector layer.
600716
Layers will either be taken from ``context``'s active project, or loaded from external
601717
sources and stored temporarily in the ``context``. In either case, callers do not
602718
need to handle deletion of the returned layer.
719+
%End
720+
721+
static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
722+
%Docstring
723+
Evaluates the parameter with matching ``definition`` and ``value`` to a vector layer.
724+
725+
Layers will either be taken from ``context``'s active project, or loaded from external
726+
sources and stored temporarily in the ``context``. In either case, callers do not
727+
need to handle deletion of the returned layer.
728+
729+
.. versionadded:: 3.4
603730
%End
604731

605732
static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
606733
%Docstring
607734
Evaluates the parameter with matching ``definition`` to a coordinate reference system.
735+
%End
736+
737+
static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
738+
%Docstring
739+
Evaluates the parameter with matching ``definition`` and ``value`` to a coordinate reference system.
740+
741+
.. versionadded:: 3.4
608742
%End
609743

610744
static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
@@ -618,6 +752,21 @@ reprojected so that it is in the specified ``crs``. In this case the extent of t
618752
.. seealso:: :py:func:`parameterAsExtentGeometry`
619753

620754
.. seealso:: :py:func:`parameterAsExtentCrs`
755+
%End
756+
757+
static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
758+
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
759+
%Docstring
760+
Evaluates the parameter with matching ``definition`` and ``value`` to a rectangular extent.
761+
762+
If ``crs`` is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically
763+
reprojected so that it is in the specified ``crs``. In this case the extent of the reproject rectangle will be returned.
764+
765+
.. seealso:: :py:func:`parameterAsExtentGeometry`
766+
767+
.. seealso:: :py:func:`parameterAsExtentCrs`
768+
769+
.. versionadded:: 3.4
621770
%End
622771

623772
static QgsGeometry parameterAsExtentGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context,
@@ -650,6 +799,18 @@ Evaluates the parameter with matching ``definition`` to a point.
650799
If ``crs`` is set then the point will be automatically reprojected so that it is in the specified ``crs``.
651800

652801
.. seealso:: :py:func:`parameterAsPointCrs`
802+
%End
803+
804+
static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
805+
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
806+
%Docstring
807+
Evaluates the parameter with matching ``definition`` and ``value`` to a point.
808+
809+
If ``crs`` is set then the point will be automatically reprojected so that it is in the specified ``crs``.
810+
811+
.. seealso:: :py:func:`parameterAsPointCrs`
812+
813+
.. versionadded:: 3.4
653814
%End
654815

655816
static QgsCoordinateReferenceSystem parameterAsPointCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
@@ -662,27 +823,63 @@ Returns the coordinate reference system associated with an point parameter value
662823
static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
663824
%Docstring
664825
Evaluates the parameter with matching ``definition`` to a file/folder name.
826+
%End
827+
828+
static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
829+
%Docstring
830+
Evaluates the parameter with matching ``definition`` and ``value`` to a file/folder name.
831+
832+
.. versionadded:: 3.4
665833
%End
666834

667835
static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
668836
%Docstring
669837
Evaluates the parameter with matching ``definition`` to a matrix/table of values.
670838
Tables are collapsed to a 1 dimensional list.
839+
%End
840+
841+
static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
842+
%Docstring
843+
Evaluates the parameter with matching ``definition`` and ``value`` to a matrix/table of values.
844+
Tables are collapsed to a 1 dimensional list.
845+
846+
.. versionadded:: 3.4
671847
%End
672848

673849
static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
674850
%Docstring
675851
Evaluates the parameter with matching ``definition`` to a list of map layers.
852+
%End
853+
854+
static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
855+
%Docstring
856+
Evaluates the parameter with matching ``definition`` and ``value`` to a list of map layers.
857+
858+
.. versionadded:: 3.4
676859
%End
677860

678861
static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
679862
%Docstring
680863
Evaluates the parameter with matching ``definition`` to a range of values.
864+
%End
865+
866+
static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
867+
%Docstring
868+
Evaluates the parameter with matching ``definition`` and ``value`` to a range of values.
869+
870+
.. versionadded:: 3.4
681871
%End
682872

683873
static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
684874
%Docstring
685875
Evaluates the parameter with matching ``definition`` to a list of fields.
876+
%End
877+
878+
static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
879+
%Docstring
880+
Evaluates the parameter with matching ``definition`` and ``value`` to a list of fields.
881+
882+
.. versionadded:: 3.4
686883
%End
687884

688885
static QgsProcessingParameterDefinition *parameterFromVariantMap( const QVariantMap &map ) /Factory/;

0 commit comments

Comments
 (0)