@@ -495,6 +495,7 @@ class TestQgsProcessing: public QObject
495
495
void asPythonCommand ();
496
496
void modelerAlgorithm ();
497
497
void modelExecution ();
498
+ void modelVectorOutputIsCompatibleType ();
498
499
void modelAcceptableValues ();
499
500
void tempUtils ();
500
501
void convertCompatible ();
@@ -5908,6 +5909,81 @@ void TestQgsProcessing::modelExecution()
5908
5909
QCOMPARE ( actualParts, expectedParts );
5909
5910
}
5910
5911
5912
+ void TestQgsProcessing::modelVectorOutputIsCompatibleType ()
5913
+ {
5914
+ // IMPORTANT: This method is intended to be "permissive" rather than "restrictive".
5915
+ // I.e. we only reject outputs which we know can NEVER be acceptable, but
5916
+ // if there's doubt then we default to returning true.
5917
+
5918
+ // empty acceptable type list = all are compatible
5919
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVector ) );
5920
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorAnyGeometry ) );
5921
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorPoint ) );
5922
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorLine ) );
5923
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeVectorPolygon ) );
5924
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( QList<int >(), QgsProcessing::TypeMapLayer ) );
5925
+
5926
+ // accept any vector
5927
+ QList< int > dataTypes;
5928
+ dataTypes << QgsProcessing::TypeVector;
5929
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5930
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5931
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5932
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5933
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5934
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5935
+
5936
+ // accept any vector with geometry
5937
+ dataTypes.clear ();
5938
+ dataTypes << QgsProcessing::TypeVectorAnyGeometry;
5939
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5940
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5941
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5942
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5943
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5944
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5945
+
5946
+ // accept any point vector
5947
+ dataTypes.clear ();
5948
+ dataTypes << QgsProcessing::TypeVectorPoint;
5949
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5950
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5951
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5952
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5953
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5954
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5955
+
5956
+ // accept any line vector
5957
+ dataTypes.clear ();
5958
+ dataTypes << QgsProcessing::TypeVectorLine;
5959
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5960
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5961
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5962
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5963
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5964
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5965
+
5966
+ // accept any polygon vector
5967
+ dataTypes.clear ();
5968
+ dataTypes << QgsProcessing::TypeVectorPolygon;
5969
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5970
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5971
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5972
+ QVERIFY ( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5973
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5974
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5975
+
5976
+ // accept any map layer
5977
+ dataTypes.clear ();
5978
+ dataTypes << QgsProcessing::TypeMapLayer;
5979
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVector ) );
5980
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorAnyGeometry ) );
5981
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPoint ) );
5982
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorLine ) );
5983
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeVectorPolygon ) );
5984
+ QVERIFY ( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType ( dataTypes, QgsProcessing::TypeMapLayer ) );
5985
+ }
5986
+
5911
5987
void TestQgsProcessing::modelAcceptableValues ()
5912
5988
{
5913
5989
QgsProcessingModelAlgorithm m;
0 commit comments