@@ -465,6 +465,7 @@ class TestQgsProcessing: public QObject
465
465
void asPythonCommand ();
466
466
void modelerAlgorithm ();
467
467
void modelExecution ();
468
+ void modelVectorOutputIsCompatibleType ();
468
469
void modelAcceptableValues ();
469
470
void tempUtils ();
470
471
void convertCompatible ();
@@ -5682,6 +5683,81 @@ void TestQgsProcessing::modelExecution()
5682
5683
QCOMPARE ( actualParts, expectedParts );
5683
5684
}
5684
5685
5686
+ void TestQgsProcessing::modelVectorOutputIsCompatibleType ()
5687
+ {
5688
+ // IMPORTANT: This method is intended to be "permissive" rather than "restrictive".
5689
+ // I.e. we only reject outputs which we know can NEVER be acceptable, but
5690
+ // if there's doubt then we default to returning true.
5691
+
5692
+ // empty acceptable type list = all are compatible
5693
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVector ) );
5694
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorAnyGeometry ) );
5695
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorPoint ) );
5696
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorLine ) );
5697
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorPolygon ) );
5698
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeMapLayer ) );
5699
+
5700
+ // accept any vector
5701
+ QList< int > dataTypes;
5702
+ dataTypes << QgsProcessing::TypeVector;
5703
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5704
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5705
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5706
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5707
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5708
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5709
+
5710
+ // accept any vector with geometry
5711
+ dataTypes.clear ();
5712
+ dataTypes << QgsProcessing::TypeVectorAnyGeometry;
5713
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5714
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5715
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5716
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5717
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5718
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5719
+
5720
+ // accept any point vector
5721
+ dataTypes.clear ();
5722
+ dataTypes << QgsProcessing::TypeVectorPoint;
5723
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5724
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5725
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5726
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5727
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5728
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5729
+
5730
+ // accept any line vector
5731
+ dataTypes.clear ();
5732
+ dataTypes << QgsProcessing::TypeVectorLine;
5733
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5734
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5735
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5736
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5737
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5738
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5739
+
5740
+ // accept any polygon vector
5741
+ dataTypes.clear ();
5742
+ dataTypes << QgsProcessing::TypeVectorPolygon;
5743
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5744
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5745
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5746
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5747
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5748
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5749
+
5750
+ // accept any map layer
5751
+ dataTypes.clear ();
5752
+ dataTypes << QgsProcessing::TypeMapLayer;
5753
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5754
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5755
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5756
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5757
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5758
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5759
+ }
5760
+
5685
5761
void TestQgsProcessing::modelAcceptableValues ()
5686
5762
{
5687
5763
QgsProcessingModelAlgorithm m;
0 commit comments